Codota Logo
DeserializationException
Code IndexAdd Codota to your IDE (free)

How to use
DeserializationException
in
com.nextdoor.bender.deserializer

Best Java code snippets using com.nextdoor.bender.deserializer.DeserializationException (Showing top 10 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
List l =
  • Codota Iconnew LinkedList()
  • Codota IconCollections.emptyList()
  • Codota Iconnew ArrayList()
  • Smart code suggestions by Codota
}
origin: Nextdoor/bender

@Override
public DeserializedEvent deserialize(String raw) {
 Matcher m = this.pattern.matcher(raw);
 if (!m.matches()) {
  throw new DeserializationException("raw event does not match string");
 }
 int groups = m.groupCount();
 JsonObject obj = new JsonObject();
 for (int i = 0; i < groups && i < fields.size(); i++) {
  String str = m.group(i + 1);
  ReFieldConfig field = this.fields.get(i);
  switch (field.getType()) {
   case BOOLEAN:
    obj.addProperty(field.getName(), Boolean.parseBoolean(str));
    break;
   case NUMBER:
    obj.addProperty(field.getName(), NumberUtils.createNumber(str));
    break;
   case STRING:
    obj.addProperty(field.getName(), str);
    break;
   default:
    obj.addProperty(field.getName(), str);
    break;
  }
 }
 return new GenericJsonEvent(obj);
}
origin: Nextdoor/bender

@Override
public DeserializedEvent deserialize(String raw) {
 Matcher m = this.pattern.matcher(raw);
 if (!m.matches()) {
  throw new DeserializationException("raw event does not match string");
 }
 int groups = m.groupCount();
 JsonObject obj = new JsonObject();
 for (int i = 0; i < groups && i < fields.size(); i++) {
  String str = m.group(i + 1);
  ReFieldConfig field = this.fields.get(i);
  switch (field.getType()) {
   case BOOLEAN:
    obj.addProperty(field.getName(), Boolean.parseBoolean(str));
    break;
   case NUMBER:
    obj.addProperty(field.getName(), NumberUtils.createNumber(str));
    break;
   case STRING:
    obj.addProperty(field.getName(), str);
    break;
   default:
    obj.addProperty(field.getName(), str);
    break;
  }
 }
 return new GenericJsonEvent(obj);
}
origin: Nextdoor/bender

 elm = parser.parse(raw);
} catch (JsonSyntaxException e) {
 throw new DeserializationException(e);
 throw new DeserializationException("event is not a json object");
 Object o = JsonPathProvider.read(obj, rootNodeOverridePath);
 if (obj == null || o instanceof JsonNull) {
  throw new DeserializationException(rootNodeOverridePath + " path not found in object");
origin: Nextdoor/bender

 elm = parser.parse(raw);
} catch (JsonSyntaxException e) {
 throw new DeserializationException(e);
 throw new DeserializationException("event is not a json object");
 Object o = JsonPathProvider.read(obj, rootNodeOverridePath);
 if (obj == null || o instanceof JsonNull) {
  throw new DeserializationException(rootNodeOverridePath + " path not found in object");
origin: Nextdoor/bender

@Override
public DeserializedEvent deserialize(String raw) {
 Matcher m = this.pattern.matcher(raw);
 if (!m.matches()) {
  throw new DeserializationException("raw event does not match string");
 }
 int groups = m.groupCount();
 JsonObject obj = new JsonObject();
 for (int i = 0; i < groups && i < fields.size(); i++) {
  String str = m.group(i + 1);
  ReFieldConfig field = this.fields.get(i);
  switch (field.getType()) {
   case BOOLEAN:
    obj.addProperty(field.getName(), Boolean.parseBoolean(str));
    break;
   case NUMBER:
    obj.addProperty(field.getName(), NumberUtils.createNumber(str));
    break;
   case STRING:
    obj.addProperty(field.getName(), str);
    break;
   default:
    obj.addProperty(field.getName(), str);
    break;
  }
 }
 return new GenericJsonEvent(obj);
}
origin: Nextdoor/bender

@Override
public DeserializedEvent deserialize(String raw) {
 Matcher m = this.pattern.matcher(raw);
 if (!m.matches()) {
  throw new DeserializationException("raw event does not match string");
 }
 int groups = m.groupCount();
 JsonObject obj = new JsonObject();
 for (int i = 0; i < groups && i < fields.size(); i++) {
  String str = m.group(i + 1);
  ReFieldConfig field = this.fields.get(i);
  switch (field.getType()) {
   case BOOLEAN:
    obj.addProperty(field.getName(), Boolean.parseBoolean(str));
    break;
   case NUMBER:
    obj.addProperty(field.getName(), NumberUtils.createNumber(str));
    break;
   case STRING:
    obj.addProperty(field.getName(), str);
    break;
   default:
    obj.addProperty(field.getName(), str);
    break;
  }
 }
 return new GenericJsonEvent(obj);
}
origin: Nextdoor/bender

@Test
public void testStatsLoggingOnError() {
 DummyDeserializer mockDeser = mock(DummyDeserializer.class);
 when(mockDeser.deserialize("foo"))
   .thenThrow(new DeserializationException(new RuntimeException("expected")));
 DeserializerProcessor deser = new DeserializerProcessor(mockDeser);
 /*
  * Mock the Stat object
  */
 Stat runtimeStat = mock(Stat.class);
 Stat successStat = mock(Stat.class);
 Stat errorStat = mock(Stat.class);
 deser.setRuntimeStat(runtimeStat);
 deser.setSuccessCountStat(successStat);
 deser.setErrorCountStat(errorStat);
 try {
  deser.deserialize("foo");
 } catch (DeserializationException e) {
  // expected
 }
 /*
  * Verify start, stop are called, increment error count and never increment success count.
  */
 verify(runtimeStat, times(1)).start();
 verify(runtimeStat, times(1)).stop();
 verify(successStat, never()).increment();
 verify(errorStat, times(1)).increment();
}
origin: Nextdoor/bender

@Test
public void testFilterFailedDeserialization() throws HandlerException {
 BaseHandler.CONFIG_FILE = "/config/handler_config.json";
 handler.skipWriteStats = true;
 List<DummyEvent> events = new ArrayList<DummyEvent>(1);
 events.add(new DummyEvent("foo", 0));
 TestContext context = new TestContext();
 context.setInvokedFunctionArn("arn:aws:lambda:us-east-1:123:function:test:tag");
 handler.init(context);
 DeserializerProcessor proc = handler.sources.get(0).getDeserProcessor();
 Deserializer deserSpy = spy(proc.getDeserializer());
 doThrow(new DeserializationException("expected")).when(deserSpy).deserialize(anyString());
 proc.setDeserializer(deserSpy);
 handler.handler(events, context);
 assertEquals(0, BufferedTransporter.output.size());
}
origin: Nextdoor/bender

@Test
public void testSerializationException() throws HandlerException, SerializationException {
 BaseHandler.CONFIG_FILE = "/config/handler_config.json";
 handler.skipWriteStats = true;
 List<DummyEvent> events = new ArrayList<DummyEvent>(1);
 events.add(new DummyEvent("foo", 0));
 TestContext context = new TestContext();
 context.setInvokedFunctionArn("arn:aws:lambda:us-east-1:123:function:test:tag");
 handler.init(context);
 Serializer serSpy = spy(handler.ser.getSerializer());
 doThrow(new DeserializationException("")).when(serSpy).serialize(any());
 handler.ser.setSerializer(serSpy);
 handler.handler(events, context);
 assertEquals(1, handler.ser.getErrorCountStat().getValue());
}
origin: Nextdoor/bender

@Test
public void testDeserializationException() throws HandlerException {
 BaseHandler.CONFIG_FILE = "/config/handler_config.json";
 handler.skipWriteStats = true;
 List<DummyEvent> events = new ArrayList<DummyEvent>(1);
 events.add(new DummyEvent("foo", 0));
 TestContext context = new TestContext();
 context.setInvokedFunctionArn("arn:aws:lambda:us-east-1:123:function:test:tag");
 handler.init(context);
 DeserializerProcessor proc = handler.sources.get(0).getDeserProcessor();
 Deserializer deserSpy = spy(proc.getDeserializer());
 doThrow(new DeserializationException("expected")).when(deserSpy).deserialize(anyString());
 proc.setDeserializer(deserSpy);
 handler.handler(events, context);
 assertEquals(1, proc.getErrorCountStat().getValue());
}
com.nextdoor.bender.deserializerDeserializationException

Most used methods

  • <init>

Popular in Java

  • Finding current android device location
  • putExtra (Intent)
  • notifyDataSetChanged (ArrayAdapter)
  • getSystemService (Context)
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • HashSet (java.util)
    This class implements the Set interface, backed by a hash table (actually a HashMap instance). It m
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • Properties (java.util)
    The Properties class represents a persistent set of properties. The Properties can be saved to a st
  • Join (org.hibernate.mapping)
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now