@Test
    public void shouldAddNullSubprojectIfProjectIsDefined() throws IOException {
        Event event = EventBuilder.create(0, "11203800-63fd-11e8-83e2-3a587d902000").
                tag("description", Variant.ofString("This is the annotation")).
                tag("tags", Variant.ofVector(Vector.ofContainers(
                        Container.builder().tag("key", Variant.ofString("environment")).tag("value", Variant.ofString("staging")).build(),
                        Container.builder().tag("key", Variant.ofString("project")).tag("value", Variant.ofString("test")).build()))).
                build();
        Properties properties = new Properties();
        properties.setProperty("file", "resource://annotation-event.mapping");
        EventToJsonFormatter formatter = new EventToJsonFormatter(properties);
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        DocumentWriter.writeTo(stream, formatter.format(event));
        assertEquals("{" +
                        "\"@timestamp\":\"1970-01-01T00:00:00.000000000Z\"," +
                        "\"environment\":\"staging\"," +
                        "\"project\":\"test\"," +
                        "\"tags\":\"environment=staging,project=test,subproject=null\"," +
                        "\"description\":\"This is the annotation\"" +
                        "}",
                stream.toString(StandardCharsets.UTF_8.name())
        );
    }
@Test
    public void shouldAddNullSubprojectIfProjectIsDefined() throws IOException {
        Event event = EventBuilder.create(0, "11203800-63fd-11e8-83e2-3a587d902000").
                tag("description", Variant.ofString("This is the annotation")).
                tag("tags", Variant.ofVector(Vector.ofContainers(
                        Container.builder().tag("key", Variant.ofString("environment")).tag("value", Variant.ofString("staging")).build(),
                        Container.builder().tag("key", Variant.ofString("project")).tag("value", Variant.ofString("test")).build()))).
                build();
        Properties properties = new Properties();
        properties.setProperty("file", "resource://annotation-event.mapping");
        EventToJsonFormatter formatter = new EventToJsonFormatter(properties);
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        DocumentWriter.writeTo(stream, formatter.format(event));
        assertEquals("{" +
                        "\"@timestamp\":\"1970-01-01T00:00:00.000000000Z\"," +
                        "\"environment\":\"staging\"," +
                        "\"project\":\"test\"," +
                        "\"tags\":\"environment=staging,project=test,subproject=null\"," +
                        "\"description\":\"This is the annotation\"" +
                        "}",
                stream.toString(StandardCharsets.UTF_8.name())
        );
    }
@test public void shouldaddnullsubprojectifprojectisdefined() throws ioexception { event event = eventbuilder.create(0, "11203800-63fd-11e8-83e2-3a587d902000"). tag("description", variant.ofstring("this is the annotation")). tag("tags", variant.ofvector(vector.ofcontainers( container.builder().tag("key", variant.ofstring("environment")).tag("value", variant.ofstring("staging")).build(), container.builder().tag("key", variant.ofstring("project")).tag("value", variant.ofstring("test")).build()))). build(); properties properties = new properties(); properties.setproperty("file", "resource://annotation-event.mapping"); eventtojsonformatter formatter = new eventtojsonformatter(properties); bytearrayoutputstream stream = new bytearrayoutputstream(); documentwriter.writeto(stream, formatter.format(event)); assertequals("{" + "\"@timestamp\":\"1970-01-01t00:00:00.000000000z\"," + "\"environment\":\"staging\"," + "\"project\":\"test\"," + "\"tags\":\"environment=staging,project=test,subproject=null\"," + "\"description\":\"this is the annotation\"" + "}", stream.tostring(standardcharsets.utf_8.name()) ); }