Search in sources :

Example 16 with JsonSerializer

use of net.morimekta.providence.serializer.JsonSerializer in project providence by morimekta.

the class MessageProgramParserTest method testParse.

@Test
public void testParse() throws IOException {
    MessageProgramParser parser = new MessageProgramParser(new JsonSerializer());
    ByteArrayInputStream in = new ByteArrayInputStream(("{\n" + "  \"namespaces\": {\n" + "    \"java\": \"net.morimekta.providence\"\n" + "  }\n" + "}").getBytes(StandardCharsets.UTF_8));
    ProgramType program = parser.parse(in, new File("test.json"), ImmutableSet.of());
    assertThat(program.getNamespaces(), is(ImmutableMap.of("java", "net.morimekta.providence")));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) JsonSerializer(net.morimekta.providence.serializer.JsonSerializer) ProgramType(net.morimekta.providence.model.ProgramType) File(java.io.File) Test(org.junit.Test)

Aggregations

JsonSerializer (net.morimekta.providence.serializer.JsonSerializer)16 Test (org.junit.Test)14 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 File (java.io.File)4 IOException (java.io.IOException)3 SizeBasedRollingPolicy (net.morimekta.providence.mio.rolling.SizeBasedRollingPolicy)2 PrettySerializer (net.morimekta.providence.serializer.PrettySerializer)2 CompactFields (net.morimekta.test.providence.core.CompactFields)2 Operation (net.morimekta.test.providence.core.calculator.Operation)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Fairy (io.codearte.jfairy.Fairy)1 BufferedInputStream (java.io.BufferedInputStream)1 InputStream (java.io.InputStream)1 UncheckedIOException (java.io.UncheckedIOException)1 StandardCharsets (java.nio.charset.StandardCharsets)1 ArrayList (java.util.ArrayList)1 Locale (java.util.Locale)1 Random (java.util.Random)1