DefaultJsonMetadata extends JsonMetadata { public static MetadataBuilder metadataBuilderFrom(final Metadata metadata) { return new DefaultJsonMetadata.Builder(metadata); } private  DefaultJsonMetadata(final JsonObject metadata); static MetadataBuilder metadataBuilder(); static MetadataBuilder metadataBuilderFrom(final Metadata metadata); static MetadataBuilder metadataBuilderFrom(final JsonObject jsonObject); @Override UUID id(); @Override String name(); @Override Optional<String> clientCorrelationId(); @Override List<UUID> causation(); @Override Optional<String> userId(); @Override Optional<String> sessionId(); @Override Optional<UUID> streamId(); @Override Optional<Long> version(); @Override Optional<Long> position(); @Override JsonObject asJsonObject(); @Override Optional<ZonedDateTime> createdAt(); @Override Optional<String> source(); @Override Optional<Long> eventNumber(); @Override Optional<Long> previousEventNumber(); @Override @SuppressWarnings({"squid:MethodCyclomaticComplexity", "squid:S1067", "squid:S00122"}) boolean equals(final Object o); @Override int hashCode();  }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionOnMissingId() throws Exception { final JsonObject joEnvelope = new StringToJsonObjectConverter().convert(jsonFromFile("json/envelope-missing-id.json")); metadataBuilderFrom(joEnvelope.getJsonObject(METADATA)); }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionOnMissingName() throws Exception { final JsonObject joEnvelope = new StringToJsonObjectConverter().convert(jsonFromFile("json/envelope-missing-name")); metadataBuilderFrom(joEnvelope.getJsonObject(METADATA)); }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionIfIdIsMissing() throws Exception { metadataBuilderFrom(createObjectBuilder() .build() ).build(); }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionIfIdIsNotUUID() throws Exception { metadataBuilderFrom(createObjectBuilder() .add(ID, "blah") .build() ).build(); }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionIfIdIsNull() throws Exception { metadataBuilderFrom(createObjectBuilder() .add(ID, NULL) .build() ).build(); }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionIfNameIsMissing() throws Exception { metadataBuilderFrom(createObjectBuilder() .add(ID, UUID_ID) .build() ).build(); }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionIfNameIsEmpty() throws Exception { metadataBuilderFrom(createObjectBuilder() .add(ID, UUID_ID) .add(NAME, "") .build() ).build(); }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionIfNameIsNull() throws Exception { metadataBuilderFrom(createObjectBuilder() .add(ID, UUID_ID) .add(NAME, NULL) .build() ).build(); }