org.springframework.boot.test.json.JsonContent Java Examples
The following examples show how to use
org.springframework.boot.test.json.JsonContent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InstanceStatusChangedEventMixinTest.java From spring-boot-admin with Apache License 2.0 | 6 votes |
@Test public void verifySerializeWithOnlyRequiredProperties() throws IOException { InstanceId id = InstanceId.of("test123"); Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS); StatusInfo statusInfo = StatusInfo.valueOf("OFFLINE"); InstanceStatusChangedEvent event = new InstanceStatusChangedEvent(id, 0L, timestamp, statusInfo); JsonContent<InstanceStatusChangedEvent> jsonContent = jsonTester.write(event); assertThat(jsonContent).extractingJsonPathStringValue("$.instance").isEqualTo("test123"); assertThat(jsonContent).extractingJsonPathNumberValue("$.version").isEqualTo(0); assertThat(jsonContent).extractingJsonPathNumberValue("$.timestamp").isEqualTo(1587751031.000000000); assertThat(jsonContent).extractingJsonPathStringValue("$.type").isEqualTo("STATUS_CHANGED"); assertThat(jsonContent).extractingJsonPathValue("$.statusInfo").isNotNull(); assertThat(jsonContent).extractingJsonPathStringValue("$.statusInfo.status").isEqualTo("OFFLINE"); assertThat(jsonContent).extractingJsonPathMapValue("$.statusInfo.details").isEmpty(); }
Example #2
Source File: ConfigServerTest.java From spring-cloud-config-aws-kms with Apache License 2.0 | 6 votes |
@Test void testGetConfigFromServer() { final ResponseEntity<String> response = rest.getForEntity("/my-test-app/default", String.class); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); final JsonContent<?> jsonBody = json.from(response.getBody()); System.out.println(jsonBody.getJson()); assertThat(jsonBody).extractingJsonPathValue("$.name") .isEqualTo("my-test-app"); assertThat(jsonBody).extractingJsonPathArrayValue("$.profiles") .containsExactly("default"); assertThat(jsonBody).extractingJsonPathArrayValue("$.propertySources..source['info.foo']") .containsExactly("bar"); assertThat(jsonBody).extractingJsonPathArrayValue("$.propertySources..source['top.secret']") .containsExactly("Hello World"); final DecryptRequest expectedRequest = new DecryptRequest() .withCiphertextBlob(ByteBuffer.wrap(Base64.getDecoder().decode("c2VjcmV0".getBytes()))); verify(mockKms, atLeastOnce()).decrypt(eq(expectedRequest)); }
Example #3
Source File: EndpointsMixinTest.java From spring-boot-admin with Apache License 2.0 | 6 votes |
@Test public void verifySerialize() throws IOException { Endpoints endpoints = Endpoints.single("info", "http://localhost:8080/info").withEndpoint("health", "http://localhost:8080/health"); JsonContent<Endpoints> jsonContent = jsonTester.write(endpoints); assertThat(jsonContent).extractingJsonPathArrayValue("$").hasSize(2); assertThat(jsonContent).extractingJsonPathStringValue("$[0].id").isIn("info", "health"); assertThat(jsonContent).extractingJsonPathStringValue("$[0].url").isIn("http://localhost:8080/info", "http://localhost:8080/health"); assertThat(jsonContent).extractingJsonPathStringValue("$[1].id").isIn("info", "health"); assertThat(jsonContent).extractingJsonPathStringValue("$[1].url").isIn("http://localhost:8080/info", "http://localhost:8080/health"); }
Example #4
Source File: TrendingWidgetTest.java From find with MIT License | 6 votes |
@Override protected void validateJson(final JsonContent<TrendingWidget> jsonContent) { jsonContent.assertThat() .hasJsonPathStringValue("$.name", "Test Widget") .hasJsonPathStringValue("$.type", "TrendingWidget") .hasJsonPathNumberValue("$.x", 1) .hasJsonPathNumberValue("$.y", 1) .hasJsonPathNumberValue("$.width", 1) .hasJsonPathNumberValue("$.height", 1) .hasJsonPathNumberValue("$.datasource.config.id", 123) .hasJsonPathStringValue("$.datasource.config.type", "QUERY") .hasJsonPathStringValue("$.widgetSettings.parametricField", "/DOCUMENT/CONTENT_TYPE") .hasJsonPathStringValue("$.widgetSettings.dateField", "/DOCUMENT/AUTN_DATE") .hasJsonPathNumberValue("$.widgetSettings.maxValues", 5) .hasJsonPathStringValue("$.widgetSettings.maxDate", "2010-04-05T00:00:00Z") .hasJsonPathStringValue("$.widgetSettings.minDate", "2009-04-05T00:00:00Z") .hasJsonPathNumberValue("$.widgetSettings.numberOfBuckets", 12); }
Example #5
Source File: InstanceRegistrationUpdatedEventMixinTest.java From spring-boot-admin with Apache License 2.0 | 6 votes |
@Test public void verifySerializeWithOnlyRequiredProperties() throws IOException { InstanceId id = InstanceId.of("test123"); Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS); Registration registration = Registration.create("test", "http://localhost:9080/heath").build(); InstanceRegistrationUpdatedEvent event = new InstanceRegistrationUpdatedEvent(id, 0L, timestamp, registration); JsonContent<InstanceRegistrationUpdatedEvent> jsonContent = jsonTester.write(event); assertThat(jsonContent).extractingJsonPathStringValue("$.instance").isEqualTo("test123"); assertThat(jsonContent).extractingJsonPathNumberValue("$.version").isEqualTo(0); assertThat(jsonContent).extractingJsonPathNumberValue("$.timestamp").isEqualTo(1587751031.000000000); assertThat(jsonContent).extractingJsonPathStringValue("$.type").isEqualTo("REGISTRATION_UPDATED"); assertThat(jsonContent).extractingJsonPathValue("$.registration").isNotNull(); assertThat(jsonContent).extractingJsonPathStringValue("$.registration.name").isEqualTo("test"); assertThat(jsonContent).extractingJsonPathStringValue("$.registration.managementUrl").isNull(); assertThat(jsonContent).extractingJsonPathStringValue("$.registration.healthUrl") .isEqualTo("http://localhost:9080/heath"); assertThat(jsonContent).extractingJsonPathStringValue("$.registration.serviceUrl").isNull(); assertThat(jsonContent).extractingJsonPathStringValue("$.registration.source").isNull(); assertThat(jsonContent).extractingJsonPathMapValue("$.registration.metadata").isEmpty(); }
Example #6
Source File: InstanceRegisteredEventMixinTest.java From spring-boot-admin with Apache License 2.0 | 6 votes |
@Test public void verifySerializeWithOnlyRequiredProperties() throws IOException { InstanceId id = InstanceId.of("test123"); Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS); Registration registration = Registration.create("test", "http://localhost:9080/heath").build(); InstanceRegisteredEvent event = new InstanceRegisteredEvent(id, 0L, timestamp, registration); JsonContent<InstanceRegisteredEvent> jsonContent = jsonTester.write(event); assertThat(jsonContent).extractingJsonPathStringValue("$.instance").isEqualTo("test123"); assertThat(jsonContent).extractingJsonPathNumberValue("$.version").isEqualTo(0); assertThat(jsonContent).extractingJsonPathNumberValue("$.timestamp").isEqualTo(1587751031.000000000); assertThat(jsonContent).extractingJsonPathStringValue("$.type").isEqualTo("REGISTERED"); assertThat(jsonContent).extractingJsonPathValue("$.registration").isNotNull(); assertThat(jsonContent).extractingJsonPathStringValue("$.registration.name").isEqualTo("test"); assertThat(jsonContent).extractingJsonPathStringValue("$.registration.managementUrl").isNull(); assertThat(jsonContent).extractingJsonPathStringValue("$.registration.healthUrl") .isEqualTo("http://localhost:9080/heath"); assertThat(jsonContent).extractingJsonPathStringValue("$.registration.serviceUrl").isNull(); assertThat(jsonContent).extractingJsonPathStringValue("$.registration.source").isNull(); assertThat(jsonContent).extractingJsonPathMapValue("$.registration.metadata").isEmpty(); }
Example #7
Source File: InstanceEndpointsDetectedEventMixinTest.java From spring-boot-admin with Apache License 2.0 | 6 votes |
@Test public void verifySerialize() throws IOException { InstanceId id = InstanceId.of("test123"); Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS); Endpoints endpoints = Endpoints.single("info", "http://localhost:8080/info").withEndpoint("health", "http://localhost:8080/health"); InstanceEndpointsDetectedEvent event = new InstanceEndpointsDetectedEvent(id, 12345678L, timestamp, endpoints); JsonContent<InstanceEndpointsDetectedEvent> jsonContent = jsonTester.write(event); assertThat(jsonContent).extractingJsonPathStringValue("$.instance").isEqualTo("test123"); assertThat(jsonContent).extractingJsonPathNumberValue("$.version").isEqualTo(12345678); assertThat(jsonContent).extractingJsonPathNumberValue("$.timestamp").isEqualTo(1587751031.000000000); assertThat(jsonContent).extractingJsonPathStringValue("$.type").isEqualTo("ENDPOINTS_DETECTED"); assertThat(jsonContent).extractingJsonPathArrayValue("$.endpoints").hasSize(2); assertThat(jsonContent).extractingJsonPathStringValue("$.endpoints[0].id").isIn("info", "health"); assertThat(jsonContent).extractingJsonPathStringValue("$.endpoints[0].url").isIn("http://localhost:8080/info", "http://localhost:8080/health"); assertThat(jsonContent).extractingJsonPathStringValue("$.endpoints[1].id").isIn("info", "health"); assertThat(jsonContent).extractingJsonPathStringValue("$.endpoints[1].url").isIn("http://localhost:8080/info", "http://localhost:8080/health"); }
Example #8
Source File: InstanceInfoChangedEventMixinTest.java From spring-boot-admin with Apache License 2.0 | 6 votes |
@Test public void verifySerialize() throws IOException { InstanceId id = InstanceId.of("test123"); Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS); Map<String, Object> data = new HashMap<>(); data.put("build", Collections.singletonMap("version", "1.0.0")); data.put("foo", "bar"); InstanceInfoChangedEvent event = new InstanceInfoChangedEvent(id, 12345678L, timestamp, Info.from(data)); JsonContent<InstanceInfoChangedEvent> jsonContent = jsonTester.write(event); assertThat(jsonContent).extractingJsonPathStringValue("$.instance").isEqualTo("test123"); assertThat(jsonContent).extractingJsonPathNumberValue("$.version").isEqualTo(12345678); assertThat(jsonContent).extractingJsonPathNumberValue("$.timestamp").isEqualTo(1587751031.000000000); assertThat(jsonContent).extractingJsonPathStringValue("$.type").isEqualTo("INFO_CHANGED"); assertThat(jsonContent).extractingJsonPathMapValue("$.info").containsOnlyKeys("build", "foo"); assertThat(jsonContent).extractingJsonPathStringValue("$.info['build'].['version']").isEqualTo("1.0.0"); assertThat(jsonContent).extractingJsonPathStringValue("$.info['foo']").isEqualTo("bar"); }
Example #9
Source File: InstanceStatusChangedEventMixinTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void verifySerialize() throws IOException { InstanceId id = InstanceId.of("test123"); Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS); StatusInfo statusInfo = StatusInfo.valueOf("OFFLINE", Collections.singletonMap("foo", "bar")); InstanceStatusChangedEvent event = new InstanceStatusChangedEvent(id, 12345678L, timestamp, statusInfo); JsonContent<InstanceStatusChangedEvent> jsonContent = jsonTester.write(event); assertThat(jsonContent).extractingJsonPathStringValue("$.instance").isEqualTo("test123"); assertThat(jsonContent).extractingJsonPathNumberValue("$.version").isEqualTo(12345678); assertThat(jsonContent).extractingJsonPathNumberValue("$.timestamp").isEqualTo(1587751031.000000000); assertThat(jsonContent).extractingJsonPathStringValue("$.type").isEqualTo("STATUS_CHANGED"); assertThat(jsonContent).extractingJsonPathValue("$.statusInfo").isNotNull(); assertThat(jsonContent).extractingJsonPathStringValue("$.statusInfo.status").isEqualTo("OFFLINE"); assertThat(jsonContent).extractingJsonPathMapValue("$.statusInfo.details").containsOnly(entry("foo", "bar")); }
Example #10
Source File: ExportConfigTest.java From find with MIT License | 5 votes |
@Override protected void validateJson(final JsonContent<ExportConfig> jsonContent) { jsonContent.assertThat().hasJsonPathNumberValue("@.powerpoint.marginLeft", 0.1); jsonContent.assertThat().hasJsonPathNumberValue("@.powerpoint.marginRight", 0.1); jsonContent.assertThat().hasJsonPathNumberValue("@.powerpoint.marginTop", 0.1); jsonContent.assertThat().hasJsonPathNumberValue("@.powerpoint.marginBottom", 0.1); }
Example #11
Source File: InstanceStatusChangedEventMixinTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void verifySerializeWithoutStatusInfo() throws IOException { InstanceId id = InstanceId.of("test123"); Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS); InstanceStatusChangedEvent event = new InstanceStatusChangedEvent(id, 12345678L, timestamp, null); JsonContent<InstanceStatusChangedEvent> jsonContent = jsonTester.write(event); assertThat(jsonContent).extractingJsonPathStringValue("$.instance").isEqualTo("test123"); assertThat(jsonContent).extractingJsonPathNumberValue("$.version").isEqualTo(12345678); assertThat(jsonContent).extractingJsonPathNumberValue("$.timestamp").isEqualTo(1587751031.000000000); assertThat(jsonContent).extractingJsonPathStringValue("$.type").isEqualTo("STATUS_CHANGED"); assertThat(jsonContent).extractingJsonPathValue("$.statusInfo").isNull(); }
Example #12
Source File: InstanceRegisteredEventMixinTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void verifySerialize() throws IOException { InstanceId id = InstanceId.of("test123"); Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS); Registration registration = Registration.create("test", "http://localhost:9080/heath") .managementUrl("http://localhost:9080/").serviceUrl("http://localhost:8080/").source("http-api") .metadata("PASSWORD", "qwertz123").metadata("user", "humptydumpty").build(); InstanceRegisteredEvent event = new InstanceRegisteredEvent(id, 12345678L, timestamp, registration); JsonContent<InstanceRegisteredEvent> jsonContent = jsonTester.write(event); assertThat(jsonContent).extractingJsonPathStringValue("$.instance").isEqualTo("test123"); assertThat(jsonContent).extractingJsonPathNumberValue("$.version").isEqualTo(12345678); assertThat(jsonContent).extractingJsonPathNumberValue("$.timestamp").isEqualTo(1587751031.000000000); assertThat(jsonContent).extractingJsonPathStringValue("$.type").isEqualTo("REGISTERED"); assertThat(jsonContent).extractingJsonPathValue("$.registration").isNotNull(); assertThat(jsonContent).extractingJsonPathStringValue("$.registration.name").isEqualTo("test"); assertThat(jsonContent).extractingJsonPathStringValue("$.registration.managementUrl") .isEqualTo("http://localhost:9080/"); assertThat(jsonContent).extractingJsonPathStringValue("$.registration.healthUrl") .isEqualTo("http://localhost:9080/heath"); assertThat(jsonContent).extractingJsonPathStringValue("$.registration.serviceUrl") .isEqualTo("http://localhost:8080/"); assertThat(jsonContent).extractingJsonPathStringValue("$.registration.source").isEqualTo("http-api"); assertThat(jsonContent).extractingJsonPathMapValue("$.registration.metadata") .containsOnly(entry("PASSWORD", "******"), entry("user", "humptydumpty")); }
Example #13
Source File: InstanceRegisteredEventMixinTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void verifySerializeWithoutRegistration() throws IOException { InstanceId id = InstanceId.of("test123"); Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS); InstanceRegisteredEvent event = new InstanceRegisteredEvent(id, 12345678L, timestamp, null); JsonContent<InstanceRegisteredEvent> jsonContent = jsonTester.write(event); assertThat(jsonContent).extractingJsonPathStringValue("$.instance").isEqualTo("test123"); assertThat(jsonContent).extractingJsonPathNumberValue("$.version").isEqualTo(12345678); assertThat(jsonContent).extractingJsonPathNumberValue("$.timestamp").isEqualTo(1587751031.000000000); assertThat(jsonContent).extractingJsonPathStringValue("$.type").isEqualTo("REGISTERED"); assertThat(jsonContent).extractingJsonPathValue("$.registration").isNull(); }
Example #14
Source File: StatusInfoMixinTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void verifySerialize() throws IOException { StatusInfo statusInfo = StatusInfo.valueOf("OFFLINE", Collections.singletonMap("foo", "bar")); JsonContent<StatusInfo> jsonContent = jsonTester.write(statusInfo); assertThat(jsonContent).extractingJsonPathStringValue("$.status").isEqualTo("OFFLINE"); assertThat(jsonContent).extractingJsonPathMapValue("$.details").containsOnly(entry("foo", "bar")); assertThat(jsonContent).doesNotHaveJsonPath("$.up"); assertThat(jsonContent).doesNotHaveJsonPath("$.offline"); assertThat(jsonContent).doesNotHaveJsonPath("$.down"); assertThat(jsonContent).doesNotHaveJsonPath("$.unknown"); }
Example #15
Source File: EndpointMixinTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void verifySerialize() throws IOException { Endpoint endpoint = Endpoint.of("info", "http://localhost:8080/info"); JsonContent<Endpoint> jsonContent = jsonTester.write(endpoint); assertThat(jsonContent).extractingJsonPathStringValue("$.id").isEqualTo("info"); assertThat(jsonContent).extractingJsonPathStringValue("$.url").isEqualTo("http://localhost:8080/info"); }
Example #16
Source File: InfoMixinTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void verifySerialize() throws IOException { Map<String, Object> data = new HashMap<>(); data.put("build", Collections.singletonMap("version", "1.0.0")); data.put("foo", "bar"); Info info = Info.from(data); JsonContent<Info> jsonContent = jsonTester.write(info); assertThat(jsonContent).extractingJsonPathMapValue("$").containsOnlyKeys("build", "foo"); assertThat(jsonContent).extractingJsonPathStringValue("$['build'].['version']").isEqualTo("1.0.0"); assertThat(jsonContent).extractingJsonPathStringValue("$['foo']").isEqualTo("bar"); }
Example #17
Source File: InstanceInfoChangedEventMixinTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void verifySerializeWithOnlyRequiredProperties() throws IOException { InstanceId id = InstanceId.of("test123"); Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS); InstanceInfoChangedEvent event = new InstanceInfoChangedEvent(id, 0L, timestamp, null); JsonContent<InstanceInfoChangedEvent> jsonContent = jsonTester.write(event); assertThat(jsonContent).extractingJsonPathStringValue("$.instance").isEqualTo("test123"); assertThat(jsonContent).extractingJsonPathNumberValue("$.version").isEqualTo(0); assertThat(jsonContent).extractingJsonPathNumberValue("$.timestamp").isEqualTo(1587751031.000000000); assertThat(jsonContent).extractingJsonPathStringValue("$.type").isEqualTo("INFO_CHANGED"); assertThat(jsonContent).extractingJsonPathMapValue("$.info").isNull(); }
Example #18
Source File: InstanceInfoChangedEventMixinTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void verifySerializeWithEmptyInfo() throws IOException { InstanceId id = InstanceId.of("test123"); Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS); InstanceInfoChangedEvent event = new InstanceInfoChangedEvent(id, 12345678L, timestamp, Info.from(Collections.emptyMap())); JsonContent<InstanceInfoChangedEvent> jsonContent = jsonTester.write(event); assertThat(jsonContent).extractingJsonPathStringValue("$.instance").isEqualTo("test123"); assertThat(jsonContent).extractingJsonPathNumberValue("$.version").isEqualTo(12345678); assertThat(jsonContent).extractingJsonPathNumberValue("$.timestamp").isEqualTo(1587751031.000000000); assertThat(jsonContent).extractingJsonPathStringValue("$.type").isEqualTo("INFO_CHANGED"); assertThat(jsonContent).extractingJsonPathMapValue("$.info").isEmpty(); }
Example #19
Source File: InstanceEndpointsDetectedEventMixinTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void verifySerializeWithOnlyRequiredProperties() throws IOException { InstanceId id = InstanceId.of("test123"); Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS); InstanceEndpointsDetectedEvent event = new InstanceEndpointsDetectedEvent(id, 0L, timestamp, null); JsonContent<InstanceEndpointsDetectedEvent> jsonContent = jsonTester.write(event); assertThat(jsonContent).extractingJsonPathStringValue("$.instance").isEqualTo("test123"); assertThat(jsonContent).extractingJsonPathNumberValue("$.version").isEqualTo(0); assertThat(jsonContent).extractingJsonPathNumberValue("$.timestamp").isEqualTo(1587751031.000000000); assertThat(jsonContent).extractingJsonPathStringValue("$.type").isEqualTo("ENDPOINTS_DETECTED"); assertThat(jsonContent).extractingJsonPathArrayValue("$.endpoints").isNull(); }
Example #20
Source File: InstanceEndpointsDetectedEventMixinTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void verifySerializeWithEmptyEndpoints() throws IOException { InstanceId id = InstanceId.of("test123"); Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS); InstanceEndpointsDetectedEvent event = new InstanceEndpointsDetectedEvent(id, 0L, timestamp, Endpoints.empty()); JsonContent<InstanceEndpointsDetectedEvent> jsonContent = jsonTester.write(event); assertThat(jsonContent).extractingJsonPathStringValue("$.instance").isEqualTo("test123"); assertThat(jsonContent).extractingJsonPathNumberValue("$.version").isEqualTo(0); assertThat(jsonContent).extractingJsonPathNumberValue("$.timestamp").isEqualTo(1587751031.000000000); assertThat(jsonContent).extractingJsonPathStringValue("$.type").isEqualTo("ENDPOINTS_DETECTED"); assertThat(jsonContent).extractingJsonPathArrayValue("$.endpoints").isEmpty(); }
Example #21
Source File: InstanceRegistrationUpdatedEventMixinTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void verifySerialize() throws IOException { InstanceId id = InstanceId.of("test123"); Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS); Registration registration = Registration.create("test", "http://localhost:9080/heath") .managementUrl("http://localhost:9080/").serviceUrl("http://localhost:8080/").source("http-api") .metadata("PASSWORD", "qwertz123").metadata("user", "humptydumpty").build(); InstanceRegistrationUpdatedEvent event = new InstanceRegistrationUpdatedEvent(id, 12345678L, timestamp, registration); JsonContent<InstanceRegistrationUpdatedEvent> jsonContent = jsonTester.write(event); assertThat(jsonContent).extractingJsonPathStringValue("$.instance").isEqualTo("test123"); assertThat(jsonContent).extractingJsonPathNumberValue("$.version").isEqualTo(12345678); assertThat(jsonContent).extractingJsonPathNumberValue("$.timestamp").isEqualTo(1587751031.000000000); assertThat(jsonContent).extractingJsonPathStringValue("$.type").isEqualTo("REGISTRATION_UPDATED"); assertThat(jsonContent).extractingJsonPathValue("$.registration").isNotNull(); assertThat(jsonContent).extractingJsonPathStringValue("$.registration.name").isEqualTo("test"); assertThat(jsonContent).extractingJsonPathStringValue("$.registration.managementUrl") .isEqualTo("http://localhost:9080/"); assertThat(jsonContent).extractingJsonPathStringValue("$.registration.healthUrl") .isEqualTo("http://localhost:9080/heath"); assertThat(jsonContent).extractingJsonPathStringValue("$.registration.serviceUrl") .isEqualTo("http://localhost:8080/"); assertThat(jsonContent).extractingJsonPathStringValue("$.registration.source").isEqualTo("http-api"); assertThat(jsonContent).extractingJsonPathMapValue("$.registration.metadata") .containsOnly(entry("PASSWORD", "******"), entry("user", "humptydumpty")); }
Example #22
Source File: InstanceRegistrationUpdatedEventMixinTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void verifySerializeWithoutRegistration() throws IOException { InstanceId id = InstanceId.of("test123"); Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS); InstanceRegistrationUpdatedEvent event = new InstanceRegistrationUpdatedEvent(id, 12345678L, timestamp, null); JsonContent<InstanceRegistrationUpdatedEvent> jsonContent = jsonTester.write(event); assertThat(jsonContent).extractingJsonPathStringValue("$.instance").isEqualTo("test123"); assertThat(jsonContent).extractingJsonPathNumberValue("$.version").isEqualTo(12345678); assertThat(jsonContent).extractingJsonPathNumberValue("$.timestamp").isEqualTo(1587751031.000000000); assertThat(jsonContent).extractingJsonPathStringValue("$.type").isEqualTo("REGISTRATION_UPDATED"); assertThat(jsonContent).extractingJsonPathMapValue("$.registration").isNull(); }
Example #23
Source File: TagsMixinTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void verifySerialize() throws IOException { Map<String, Object> data = new HashMap<>(); data.put("env", "test"); data.put("foo", "bar"); Tags tags = Tags.from(data); JsonContent<Tags> jsonContent = jsonTester.write(tags); assertThat(jsonContent).extractingJsonPathMapValue("$").containsOnly(entry("env", "test"), entry("foo", "bar")); }
Example #24
Source File: InstanceDeregisteredEventMixinTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void verifySerialize() throws IOException { InstanceId id = InstanceId.of("test123"); Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS); InstanceDeregisteredEvent event = new InstanceDeregisteredEvent(id, 12345678L, timestamp); JsonContent<InstanceDeregisteredEvent> jsonContent = jsonTester.write(event); assertThat(jsonContent).extractingJsonPathStringValue("$.instance").isEqualTo("test123"); assertThat(jsonContent).extractingJsonPathNumberValue("$.version").isEqualTo(12345678); assertThat(jsonContent).extractingJsonPathNumberValue("$.timestamp").isEqualTo(1587751031.000000000); assertThat(jsonContent).extractingJsonPathStringValue("$.type").isEqualTo("DEREGISTERED"); }
Example #25
Source File: InstanceDeregisteredEventMixinTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void verifySerializeWithOnlyRequiredProperties() throws IOException { InstanceId id = InstanceId.of("test123"); Instant timestamp = Instant.ofEpochSecond(1587751031).truncatedTo(ChronoUnit.SECONDS); InstanceDeregisteredEvent event = new InstanceDeregisteredEvent(id, 0L, timestamp); JsonContent<InstanceDeregisteredEvent> jsonContent = jsonTester.write(event); assertThat(jsonContent).extractingJsonPathStringValue("$.instance").isEqualTo("test123"); assertThat(jsonContent).extractingJsonPathNumberValue("$.version").isEqualTo(0); assertThat(jsonContent).extractingJsonPathNumberValue("$.timestamp").isEqualTo(1587751031.000000000); assertThat(jsonContent).extractingJsonPathStringValue("$.type").isEqualTo("DEREGISTERED"); }
Example #26
Source File: MapWidgetTest.java From find with MIT License | 5 votes |
@Override protected void validateJson(final JsonContent<MapWidget> jsonContent) { jsonContent.assertThat() .hasJsonPathStringValue("$.name", "Test Widget") .hasJsonPathStringValue("$.type", "MapWidget") .hasJsonPathNumberValue("$.x", 1) .hasJsonPathNumberValue("$.y", 1) .hasJsonPathNumberValue("$.width", 1) .hasJsonPathNumberValue("$.height", 1) .hasJsonPathNumberValue("$.datasource.config.id", 123) .hasJsonPathStringValue("$.datasource.config.type", "QUERY"); }
Example #27
Source File: CarDetailsJsonTest.java From blog-tutorials with MIT License | 5 votes |
@Test public void testSerialize() throws Exception { CarDetails carDetails = new CarDetails("Audi", "A3", "gray"); JsonContent<CarDetails> result = this.json.write(carDetails); System.out.println(result); assertThat(result).extractingJsonPathStringValue("$.type").contains("Audi", "A3", "gray"); }
Example #28
Source File: UserDetailsJsonTest.java From blog-tutorials with MIT License | 5 votes |
@Test public void testSerialize() throws Exception { UserDetails userDetails = new UserDetails(1L, "Duke", "Java", LocalDate.of(1995, 1, 1), true); JsonContent<UserDetails> result = this.json.write(userDetails); assertThat(result).hasJsonPathStringValue("$.firstname"); assertThat(result).extractingJsonPathStringValue("$.firstname").isEqualTo("Duke"); assertThat(result).extractingJsonPathStringValue("$.lastname").isEqualTo("Java"); assertThat(result).extractingJsonPathStringValue("$.dateofbirth").isEqualTo("01.01.1995"); assertThat(result).doesNotHaveJsonPath("$.enabled"); }
Example #29
Source File: HodConfigTest.java From find with MIT License | 5 votes |
@Override protected void validateJson(final JsonContent<HodConfig> jsonContent) { jsonContent.assertThat().hasJsonPathStringValue("@.activeIndexes[0].domain", ResourceName.WIKI_CHI.getDomain()); jsonContent.assertThat().hasJsonPathStringValue("@.activeIndexes[0].name", ResourceName.WIKI_CHI.getName()); jsonContent.assertThat().hasJsonPathBooleanValue("@.publicIndexesEnabled", true); // jsonContent.assertThat().hasJsonPathStringValue("@.apiKey", "api-key-abc"); TODO: see other to-do comment below jsonContent.assertThat().hasJsonPathStringValue("@.ssoPageGetUrl", "https://dev.havenapps.io/sso.html"); jsonContent.assertThat().hasJsonPathStringValue("@.ssoPagePostUrl", "https://dev.havenapps.io/sso"); jsonContent.assertThat().hasJsonPathStringValue("@.endpointUrl", "https://api.int.havenondemand.com"); }
Example #30
Source File: TimeLastRefreshedWidgetTest.java From find with MIT License | 5 votes |
@Override protected void validateJson(final JsonContent<TimeLastRefreshedWidget> jsonContent) { jsonContent.assertThat() .hasJsonPathStringValue("$.name", "Test Widget") .hasJsonPathStringValue("$.type", "TimeLastRefreshedWidget") .hasJsonPathNumberValue("$.x", 1) .hasJsonPathNumberValue("$.y", 1) .hasJsonPathNumberValue("$.width", 1) .hasJsonPathNumberValue("$.height", 1) .hasJsonPathStringValue("$.widgetSettings.dateFormat", "HH:mm z") .hasJsonPathStringValue("$.widgetSettings.timeZone", "Europe/London") .hasJsonPathStringValue("$.widgetSettings.testing", "testing"); }