Search in sources :

Example 1 with NoKeyParser

use of com.nytimes.android.external.store.util.NoKeyParser in project Store by NYTimes.

the class MultiParserTest method shouldParseChainProperly.

@Test
public void shouldParseChainProperly() {
    List<KeyParser> parsersChain = new ArrayList<>();
    parsersChain.add(new NoKeyParser<>(PARSER_1));
    parsersChain.add(new NoKeyParser<>(PARSER_2));
    parsersChain.add(new NoKeyParser<>(PARSER_3));
    KeyParser<Object, Integer, UUID> parser = new MultiParser<>(parsersChain);
    UUID parsed = parser.call(new Object(), 100);
    assertNotNull(parsed);
}
Also used : ArrayList(java.util.ArrayList) NoKeyParser(com.nytimes.android.external.store.util.NoKeyParser) KeyParser(com.nytimes.android.external.store.util.KeyParser) UUID(java.util.UUID) Test(org.junit.Test)

Example 2 with NoKeyParser

use of com.nytimes.android.external.store.util.NoKeyParser in project Store by NYTimes.

the class MultiParserTest method shouldFailIfOneOfParsersIsInvalid.

@Test
public void shouldFailIfOneOfParsersIsInvalid() {
    expectedException.expect(ParserException.class);
    List<KeyParser> parsersChain = new ArrayList<>();
    parsersChain.add(new NoKeyParser<>(PARSER_1));
    parsersChain.add(new NoKeyParser<>(PARSER_3));
    parsersChain.add(new NoKeyParser<>(PARSER_2));
    KeyParser<Object, Integer, UUID> parser = new MultiParser<>(parsersChain);
    UUID parsed = parser.call(new Object(), 100);
    assertNotNull(parsed);
}
Also used : ArrayList(java.util.ArrayList) NoKeyParser(com.nytimes.android.external.store.util.NoKeyParser) KeyParser(com.nytimes.android.external.store.util.KeyParser) UUID(java.util.UUID) Test(org.junit.Test)

Aggregations

KeyParser (com.nytimes.android.external.store.util.KeyParser)2 NoKeyParser (com.nytimes.android.external.store.util.NoKeyParser)2 ArrayList (java.util.ArrayList)2 UUID (java.util.UUID)2 Test (org.junit.Test)2