public SELF hasJsonAttribute(String attribute, Object object) throws UnsupportedEncodingException { JsonFluentAssert.assertThatJson(actual.getContentAsString()).node(attribute).isEqualTo(object); return myself; }
public SELF hasJsonBody(Object expected) throws UnsupportedEncodingException { JsonFluentAssert.assertThatJson(actual.getContentAsString()).isEqualTo(expected); return myself; }
@Test public void shouldMigrateV1ToV2_ByChangingEnablePipelineLockingFalse_To_LockBehaviorNone() throws Exception { ConfigRepoDocumentMother documentMother = new ConfigRepoDocumentMother(); String oldJSON = documentMother.versionOneWithLockingSetTo(false); String transformedJSON = migrator.migrate(oldJSON, 2); assertThatJson(transformedJSON).node("target_version").isEqualTo("\"2\""); assertThatJson(transformedJSON).node("pipelines[0].name").isEqualTo("firstpipe"); assertThatJson(transformedJSON).node("pipelines[0].lock_behavior").isEqualTo("none"); assertThatJson(transformedJSON).node("errors").isArray().ofLength(0); }
@Test public void shouldConstructValidationRequest() { HashMap<String, String> configuration = new HashMap<>(); configuration.put("key1", "value1"); configuration.put("key2", "value2"); configuration.put("key3", null); String requestBody = new ElasticAgentExtensionConverterV4().validateElasticProfileRequestBody(configuration); assertThatJson(requestBody).isEqualTo("{\"key3\":null,\"key2\":\"value2\",\"key1\":\"value1\"}"); }
@Test public void shouldMigrateV1ToV2_ByChangingEnablePipelineLockingTrue_To_LockBehaviorLockOnFailure() throws Exception { ConfigRepoDocumentMother documentMother = new ConfigRepoDocumentMother(); String oldJSON = documentMother.versionOneWithLockingSetTo(true); String transformedJSON = migrator.migrate(oldJSON, 2); assertThatJson(transformedJSON).node("target_version").isEqualTo("\"2\""); assertThatJson(transformedJSON).node("pipelines[0].name").isEqualTo("firstpipe"); assertThatJson(transformedJSON).node("pipelines[0].lock_behavior").isEqualTo("lockOnFailure"); assertThatJson(transformedJSON).node("errors").isArray().ofLength(0); }
public SELF hasJsonMessage(String message) throws UnsupportedEncodingException { JsonFluentAssert.assertThatJson(actual.getContentAsString()).node("message").isEqualTo(message); return myself; }
@Test public void shouldConstructValidationRequest() { HashMap<String, String> configuration = new HashMap<>(); configuration.put("key1", "value1"); configuration.put("key2", "value2"); configuration.put("key3", null); String requestBody = new ElasticAgentExtensionConverterV3().validateElasticProfileRequestBody(configuration); assertThatJson(requestBody).isEqualTo("{\"key3\":null,\"key2\":\"value2\",\"key1\":\"value1\"}"); }
@Test public void validateConfigurationRequestBody_shouldSerializeConfigurationToJson() { final ArtifactMessageConverterV1 converter = new ArtifactMessageConverterV1(); final String requestBody = converter.validateConfigurationRequestBody(Collections.singletonMap("Foo", "Bar")); assertThatJson("{\"Foo\":\"Bar\"}").isEqualTo(requestBody); }
@Test public void shouldJSONizeElasticAgentStatusReportRequestBodyWhenElasticAgentIdIsProvided() throws Exception { String elasticAgentId = "my-fancy-elastic-agent-id"; String actual = new ElasticAgentExtensionConverterV4().getAgentStatusReportRequestBody(null, elasticAgentId); String expected = format("{" + " \"elastic_agent_id\": \"%s\"" + "}", elasticAgentId); assertThatJson(expected).isEqualTo(actual); }
@Test public void shouldJSONizeElasticAgentStatusReportRequestBodyWhenElasticAgentIdIsProvided() throws Exception { String elasticAgentId = "my-fancy-elastic-agent-id"; String actual = new ElasticAgentExtensionConverterV3().getAgentStatusReportRequestBody(null, elasticAgentId); String expected = format("{" + " \"elastic_agent_id\": \"%s\"" + "}", elasticAgentId); assertThatJson(expected).isEqualTo(actual); }
@Test public void shouldBeAbleToSerializeToJson() { ValidationBean bean = ValidationBean.notValid("ErrorMessage"); String output = render(bean); assertThatJson(output).isEqualTo("{ \"isValid\": \"false\",\"error\": \"ErrorMessage\" }"); } }
@Test public void shouldDoNothingIfMigratingFromV2ToV2() throws Exception { ConfigRepoDocumentMother documentMother = new ConfigRepoDocumentMother(); String oldJSON = documentMother.versionTwoComprehensive(); String transformedJSON = migrator.migrate(oldJSON, 2); assertThatJson(oldJSON).isEqualTo(transformedJSON); }
private void assertRequest(GoPluginApiRequest goPluginApiRequest, String extensionName, String version, String requestName, String requestBody) { Assert.assertThat(goPluginApiRequest.extension(), is(extensionName)); Assert.assertThat(goPluginApiRequest.extensionVersion(), is(version)); Assert.assertThat(goPluginApiRequest.requestName(), is(requestName)); assertThatJson(requestBody).isEqualTo(goPluginApiRequest.requestBody()); } }
private void assertRequest(GoPluginApiRequest goPluginApiRequest, String extensionName, String version, String requestName, String requestBody) { Assert.assertThat(goPluginApiRequest.extension(), is(extensionName)); Assert.assertThat(goPluginApiRequest.extensionVersion(), is(version)); Assert.assertThat(goPluginApiRequest.requestName(), is(requestName)); assertThatJson(requestBody).isEqualTo(goPluginApiRequest.requestBody()); } }
private void assertRequest(GoPluginApiRequest goPluginApiRequest, String extensionName, String version, String requestName, String requestBody) { assertThat(goPluginApiRequest.extension(), is(extensionName)); assertThat(goPluginApiRequest.extensionVersion(), is(version)); assertThat(goPluginApiRequest.requestName(), is(requestName)); assertThatJson(requestBody).isEqualTo(goPluginApiRequest.requestBody()); } }
private void assertRequest(GoPluginApiRequest goPluginApiRequest, String extensionName, String version, String requestName, String requestBody) { Assert.assertThat(goPluginApiRequest.extension(), is(extensionName)); Assert.assertThat(goPluginApiRequest.extensionVersion(), is(version)); Assert.assertThat(goPluginApiRequest.requestName(), is(requestName)); assertThatJson(requestBody).isEqualTo(goPluginApiRequest.requestBody()); } }
private void assertRequest(GoPluginApiRequest goPluginApiRequest, String extensionName, String version, String requestName, String requestBody) { Assert.assertThat(goPluginApiRequest.extension(), is(extensionName)); Assert.assertThat(goPluginApiRequest.extensionVersion(), is(version)); Assert.assertThat(goPluginApiRequest.requestName(), is(requestName)); assertThatJson(requestBody).isEqualTo(goPluginApiRequest.requestBody()); } }
@Test public void migrateV2ToV3_shouldAddArtifactOriginOnAllFetchTasks() { ConfigRepoDocumentMother documentMother = new ConfigRepoDocumentMother(); String oldJSON = documentMother.v2WithFetchTask(); String newJson = documentMother.v3WithFetchTask(); String transformedJSON = migrator.migrate(oldJSON, 3); assertThatJson(newJson).isEqualTo(transformedJSON); }
@Test public void migrateV2ToV3_shouldDoNothingIfJsonDoesNotHaveExternalArtifactConfigs() { ConfigRepoDocumentMother documentMother = new ConfigRepoDocumentMother(); String oldJSON = documentMother.versionTwoComprehensive(); String newJSON = documentMother.v3Comprehensive(); String transformedJSON = migrator.migrate(oldJSON, 3); assertThatJson(newJSON).isEqualTo(transformedJSON); }
@Test public void migrateV2ToV3_shouldDoNothingIfFetchExternalArtifactTaskIsConfiguredInV2() { ConfigRepoDocumentMother documentMother = new ConfigRepoDocumentMother(); String oldJSON = documentMother.v2WithFetchExternalArtifactTask(); String newJson = documentMother.v3WithFetchExternalArtifactTask(); String transformedJSON = migrator.migrate(oldJSON, 3); assertThatJson(newJson).isEqualTo(transformedJSON); } }