diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/core/interpolation/CredHubInterpolationTemplateUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/core/interpolation/CredHubInterpolationTemplateUnitTests.java index 4bb6c58..180c8ed 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/core/interpolation/CredHubInterpolationTemplateUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/core/interpolation/CredHubInterpolationTemplateUnitTests.java @@ -74,24 +74,20 @@ public class CredHubInterpolationTemplateUnitTests { } private ServicesData buildVcapServices(String credHubReferenceName) throws IOException { - // @formatter:off - String vcapServices = "{" + - " \"service-offering\": [" + - " {" + - " \"credentials\": {" + - " \"credhub-ref\": \"((" + credHubReferenceName + "))\"" + - " }," + - " \"label\": \"service-offering\"," + - " \"name\": \"service-instance\"," + - " \"plan\": \"standard\"," + - " \"tags\": [" + - " \"cloud-service\"" + - " ]," + - " \"volume_mounts\": []" + - " }" + - " ]" + - "}"; - // @formatter:on + String vcapServices = """ + { + "service-offering": [{ + "credentials": { + "credhub-ref": "((%s))" + }, + "label": "service-offering", + "name": "service-instance", + "plan": "standard", + "tags": [ "cloud-service" ], + "volume_mounts": [] + }] + } + """.formatted(credHubReferenceName); ObjectMapper mapper = JsonUtils.buildObjectMapper(); return mapper.readValue(vcapServices, ServicesData.class); diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/CertificateSummaryDataTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/CertificateSummaryDataTests.java index 00f39bf..f49b078 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/CertificateSummaryDataTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/CertificateSummaryDataTests.java @@ -26,20 +26,20 @@ public class CertificateSummaryDataTests extends JsonParsingUnitTestsBase { @Test public void deserializeWithCertificates() { - // @formatter:off - String json = "{\n" + - " \"certificates\": [\n" + - " {\n" + - " \"id\": \"2993f622-cb1e-4e00-a267-4b23c273bf3d\",\n" + - " \"name\": \"/example-certificate-1\"\n" + - " },\n" + - " {\n" + - " \"id\": \"b40d3d3b-2cf5-4a73-babd-9dceefa9b0db\",\n" + - " \"name\": \"/example-certificate-2\"\n" + - " }\n" + - " ]\n" + - "}"; - // @formatter:on + String json = """ + { + "certificates": [ + { + "id": "2993f622-cb1e-4e00-a267-4b23c273bf3d", + "name": "/example-certificate-1" + }, + { + "id": "b40d3d3b-2cf5-4a73-babd-9dceefa9b0db", + "name": "/example-certificate-2" + } + ] + } + """; CertificateSummaryData certificates = parseResponse(json, CertificateSummaryData.class); @@ -52,7 +52,11 @@ public class CertificateSummaryDataTests extends JsonParsingUnitTestsBase { @Test public void deserializeWithNoCertificates() { - String json = "{\n" + " \"certificates\": []\n" + "}"; + String json = """ + { + "certificates": [] + } + """; CertificateSummaryData certificates = parseResponse(json, CertificateSummaryData.class); diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/CredentialSummaryDataUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/CredentialSummaryDataUnitTests.java index 1e28a5e..67755f6 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/CredentialSummaryDataUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/CredentialSummaryDataUnitTests.java @@ -26,24 +26,24 @@ public class CredentialSummaryDataUnitTests extends JsonParsingUnitTestsBase { @Test public void deserializationWithCredentials() { - // @formatter:off - String json = "{\n" + - " \"credentials\": [\n" + - " {\n" + - " \"name\": \"/deploy123/example1\",\n" + - " \"version_created_at\": \"" + TEST_DATE_STRING + "\"\n" + - " },\n" + - " {\n" + - " \"name\": \"/deploy123/example2\",\n" + - " \"version_created_at\": \"" + TEST_DATE_STRING + "\"\n" + - " },\n" + - " {\n" + - " \"name\": \"/deploy123/example3\",\n" + - " \"version_created_at\": \"" + TEST_DATE_STRING + "\"\n" + - " }\n" + - " ]\n" + - "}"; - // @formatter:on + String json = """ + { + "credentials": [ + { + "name": "/deploy123/example1", + "version_created_at": "%s" + }, + { + "name": "/deploy123/example2", + "version_created_at": "%s" + }, + { + "name": "/deploy123/example3", + "version_created_at": "%s" + } + ] + } + """.formatted(TEST_DATE_STRING, TEST_DATE_STRING, TEST_DATE_STRING); CredentialSummaryData response = parseResponse(json, CredentialSummaryData.class); @@ -56,13 +56,17 @@ public class CredentialSummaryDataUnitTests extends JsonParsingUnitTestsBase { assertThat(credentials.get(2).getName().getName()).isEqualTo("/deploy123/example3"); for (CredentialSummary credential : credentials) { - assertThat(credential.getVersionCreatedAt()).isEqualTo(testDate); + assertThat(credential.getVersionCreatedAt()).isEqualTo(this.testDate); } } @Test public void deserializationWithEmptyCredentials() { - String json = "{\n" + " \"credentials\": [\n" + " ]\n" + "}"; + String json = """ + { + "credentials": [] + } + """; CredentialSummaryData response = parseResponse(json, CredentialSummaryData.class); diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/JsonParsingUnitTestsBase.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/JsonParsingUnitTestsBase.java index 1e63eee..ccbecbb 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/JsonParsingUnitTestsBase.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/JsonParsingUnitTestsBase.java @@ -27,22 +27,22 @@ public abstract class JsonParsingUnitTestsBase { static final String TEST_DATE_STRING = "2017-01-31T11:22:33Z"; - // @formatter:off - private static final String CREDENTIAL_DETAIL_TEMPLATE = "{" + - " \"version_created_at\": \"" + TEST_DATE_STRING + "\"," + - " \"id\": \"80cbb13f-7562-4e72-92de-f3ccf69eaa59\"," + - " \"name\": \"/service-broker-name/service-instance-name/binding-id/credentials-json\"," + - " %s" + - "}"; - // @formatter:on + private static final String CREDENTIAL_DETAIL_TEMPLATE = """ + { + "version_created_at": "%s", + "id": "80cbb13f-7562-4e72-92de-f3ccf69eaa59", + "name": "/service-broker-name/service-instance-name/binding-id/credentials-json", + %s + } + """.formatted(TEST_DATE_STRING, "%s"); - // @formatter:off - private static final String CREDENTIAL_DETAILS_DATA_TEMPLATE = "{" + - " \"data\": [" + - CREDENTIAL_DETAIL_TEMPLATE + - " ]" + - "}"; - // @formatter:on + private static final String CREDENTIAL_DETAILS_DATA_TEMPLATE = """ + { + "data": [ + %s + ] + } + """.formatted(CREDENTIAL_DETAIL_TEMPLATE); Date testDate; diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/certificate/CertificateCredentialDetailsUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/certificate/CertificateCredentialDetailsUnitTests.java index 28e6a3e..68c39e7 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/certificate/CertificateCredentialDetailsUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/certificate/CertificateCredentialDetailsUnitTests.java @@ -27,15 +27,14 @@ import static org.assertj.core.api.Assertions.assertThat; public class CertificateCredentialDetailsUnitTests extends JsonParsingUnitTestsBase { - // @formatter:off - private static final String CERT_CREDENTIALS = - " \"type\": \"certificate\"," + - " \"value\": {" + - " \"certificate\": \"cert\"," + - " \"ca\": \"authority\"," + - " \"private_key\": \"private-key\"" + - " }"; - // @formatter:on + private static final String CERT_CREDENTIALS = """ + "type": "certificate", + "value": { + "certificate": "cert", + "ca": "authority", + "private_key": "private-key" + } + """; @Test public void deserializeDetailsWithAllValues() { @@ -46,13 +45,12 @@ public class CertificateCredentialDetailsUnitTests extends JsonParsingUnitTestsB @Test public void deserializeDetailsCertOnly() { - // @formatter:off - final String credentials = - " \"type\": \"certificate\"," + - " \"value\": {" + - " \"certificate\": \"cert\"" + - " }"; - // @formatter:on + final String credentials = """ + "type": "certificate", + "value": { + "certificate": "cert" + } + """; CredentialDetails data = parseDetails(credentials); assertDetails(data, "cert", null, null); @@ -60,14 +58,13 @@ public class CertificateCredentialDetailsUnitTests extends JsonParsingUnitTestsB @Test public void deserializeDetailsWithNoCert() { - // @formatter:off - final String credentials = - " \"type\": \"certificate\"," + - " \"value\": {" + - " \"ca\": \"authority\"," + - " \"private_key\": \"private-key\"" + - " }"; - // @formatter:on + final String credentials = """ + "type": "certificate", + "value": { + "ca": "authority", + "private_key": "private-key" + } + """; CredentialDetails data = parseDetails(credentials); assertDetails(data, null, "authority", "private-key"); diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/info/VersionInfoTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/info/VersionInfoTests.java index 7da6dad..48fdb86 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/info/VersionInfoTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/info/VersionInfoTests.java @@ -26,7 +26,11 @@ public class VersionInfoTests extends JsonParsingUnitTestsBase { @Test public void deserializeWithV1() { - String json = "{\n" + " \"version\": \"1.9.0\"\n" + "}"; + String json = """ + { + "version": "1.9.0" + } + """; VersionInfo versionInfo = parseResponse(json, VersionInfo.class); @@ -39,7 +43,11 @@ public class VersionInfoTests extends JsonParsingUnitTestsBase { @Test public void deserializeWithV2_0() { - String json = "{\n" + " \"version\": \"2.0.2\"\n" + "}"; + String json = """ + { + "version": "2.0.2" + } + """; VersionInfo versionInfo = parseResponse(json, VersionInfo.class); @@ -52,7 +60,10 @@ public class VersionInfoTests extends JsonParsingUnitTestsBase { @Test public void deserializeWithV2_1() { - String json = "{\n" + " \"version\": \"2.1.2\"\n" + "}"; + String json = """ + { + "version": "2.1.2" + }"""; VersionInfo versionInfo = parseResponse(json, VersionInfo.class); diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/json/JsonCredentialDetailsUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/json/JsonCredentialDetailsUnitTests.java index 9d63603..a1022b7 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/json/JsonCredentialDetailsUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/json/JsonCredentialDetailsUnitTests.java @@ -27,15 +27,14 @@ import static org.assertj.core.api.Assertions.assertThat; public class JsonCredentialDetailsUnitTests extends JsonParsingUnitTestsBase { - // @formatter:off - private static final String JSON_CREDENTIALS = - " \"type\": \"json\"," + - " \"value\": {" + - " \"client_id\": \"test-id\"," + - " \"client_secret\": \"test-secret\"," + - " \"uri\": \"https://example.com\"" + - " }"; - // @formatter:on + private static final String JSON_CREDENTIALS = """ + "type": "json", + "value": { + "client_id": "test-id", + "client_secret": "test-secret", + "uri": "https://example.com" + } + """; @Test public void deserializeDetails() { diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/password/PasswordCredentialDetailsUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/password/PasswordCredentialDetailsUnitTests.java index 1e42935..af37a89 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/password/PasswordCredentialDetailsUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/password/PasswordCredentialDetailsUnitTests.java @@ -27,7 +27,10 @@ import static org.assertj.core.api.Assertions.assertThat; public class PasswordCredentialDetailsUnitTests extends JsonParsingUnitTestsBase { - private static final String PASSWORD_CREDENTIALS = " \"type\": \"password\"," + " \"value\": \"secret\""; + private static final String PASSWORD_CREDENTIALS = """ + "type": "password", + "value": "secret" + """; @Test public void deserializeDetails() { diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/permissions/CredentialPermissionUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/permissions/CredentialPermissionUnitTests.java index 0e68d05..2cdab79 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/permissions/CredentialPermissionUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/permissions/CredentialPermissionUnitTests.java @@ -33,14 +33,14 @@ public class CredentialPermissionUnitTests extends JsonParsingUnitTestsBase { @Test public void deserializePermission() { - // @formatter:off - String json = "{" + - "\"uuid\": \"uuid\",\n" + - "\"path\": \"/example-directory/example-specific-credential\",\n" + - "\"actor\": \"uaa-user:106f52e2-5d01-4675-8d7a-c05ff9a2c081\",\n" + - "\"operations\": [\"read\",\"write\"]" + - "}"; - // @formatter:on + String json = """ + { + "uuid": "uuid", + "path": "/example-directory/example-specific-credential", + "actor": "uaa-user:106f52e2-5d01-4675-8d7a-c05ff9a2c081", + "operations": ["read","write"] + } + """; CredentialPermission credentialPermission = parsePermission(json); diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/permissions/CredentialPermissionsUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/permissions/CredentialPermissionsUnitTests.java index 31e04e6..454e3da 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/permissions/CredentialPermissionsUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/permissions/CredentialPermissionsUnitTests.java @@ -33,27 +33,27 @@ public class CredentialPermissionsUnitTests extends JsonParsingUnitTestsBase { @Test public void deserializePermissions() { - // @formatter:off - String json = "{\"credential_name\": \"/c/example\"," + - "\"permissions\": [" + - " {" + - " \"actor\": \"mtls-app:appid1\"," + - " \"operations\": [" + - " \"read\"," + - " \"write\"," + - " \"delete\"," + - " \"read_acl\"," + - " \"write_acl\"" + - " ]" + - " }," + - " {" + - " \"actor\": \"uaa-user:zone1/userid\"," + - " \"operations\": [" + - " \"read\"" + - " ]" + - " }" + - " ]}"; - // @formatter:on + String json = """ + { + "credential_name": "/c/example", + "permissions": [ + { + "actor": "mtls-app:appid1", + "operations": [ + "read", + "write", + "delete", + "read_acl", + "write_acl" + ] + }, + { + "actor": "uaa-user:zone1/userid", + "operations": [ "read" ] + } + ] + } + """; CredentialPermissions permissions = parsePermissions(json); @@ -80,7 +80,11 @@ public class CredentialPermissionsUnitTests extends JsonParsingUnitTestsBase { @Test public void deserializeWithNoPermissions() { - String json = "{\"permissions\": []}"; + String json = """ + { + "permissions": [] + } + """; CredentialPermissions permissions = parsePermissions(json); diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/rsa/RsaCredentialDetailsUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/rsa/RsaCredentialDetailsUnitTests.java index ff45414..32fb634 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/rsa/RsaCredentialDetailsUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/rsa/RsaCredentialDetailsUnitTests.java @@ -27,14 +27,13 @@ import static org.assertj.core.api.Assertions.assertThat; public class RsaCredentialDetailsUnitTests extends JsonParsingUnitTestsBase { - // @formatter:off - private static final String RSA_CREDENTIALS = - " \"type\": \"rsa\"," + - " \"value\": {" + - " \"private_key\": \"private-key\"," + - " \"public_key\": \"public-key\"" + - " }"; - // @formatter:on + private static final String RSA_CREDENTIALS = """ + "type": "rsa", + "value": { + "private_key": "private-key", + "public_key": "public-key" + } + """; @Test public void deserializeDetailsWithPublicAndPrivateKeys() { @@ -45,13 +44,12 @@ public class RsaCredentialDetailsUnitTests extends JsonParsingUnitTestsBase { @Test public void deserializeDetailsWithPublicKey() { - // @formatter:off - final String credentials = - " \"type\": \"rsa\"," + - " \"value\": {" + - " \"public_key\": \"public-key\"" + - " }"; - // @formatter:on + final String credentials = """ + "type": "rsa", + "value": { + "public_key": "public-key" + } + """; CredentialDetails data = parseDetails(credentials); assertDetails(data, "public-key", null); @@ -59,13 +57,12 @@ public class RsaCredentialDetailsUnitTests extends JsonParsingUnitTestsBase { @Test public void deserializeDetailsWithPrivateKey() { - // @formatter:off - final String credentials = - " \"type\": \"rsa\"," + - " \"value\": {" + - " \"private_key\": \"private-key\"" + - " }"; - // @formatter:on + final String credentials = """ + "type": "rsa", + "value": { + "private_key": "private-key" + } + """; CredentialDetails data = parseDetails(credentials); assertDetails(data, null, "private-key"); diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/ssh/SshCredentialDetailsUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/ssh/SshCredentialDetailsUnitTests.java index a6ee6f1..f13d13c 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/ssh/SshCredentialDetailsUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/ssh/SshCredentialDetailsUnitTests.java @@ -27,15 +27,14 @@ import static org.assertj.core.api.Assertions.assertThat; public class SshCredentialDetailsUnitTests extends JsonParsingUnitTestsBase { - // @formatter:off - private static final String SSH_CREDENTIALS = - " \"type\": \"ssh\"," + - " \"value\": {" + - " \"private_key\": \"private-key\"," + - " \"public_key\": \"public-key\"," + - " \"public_key_fingerprint\": \"fingerprint\"" + - " }"; - // @formatter:on + private static final String SSH_CREDENTIALS = """ + "type": "ssh", + "value": { + "private_key": "private-key", + "public_key": "public-key", + "public_key_fingerprint": "fingerprint" + } + """; @Test public void deserializeDetailsWithPublicAndPrivateKeys() { @@ -46,13 +45,12 @@ public class SshCredentialDetailsUnitTests extends JsonParsingUnitTestsBase { @Test public void deserializeDetailsWithPublicKey() { - // @formatter:off - final String credentials = - " \"type\": \"ssh\"," + - " \"value\": {" + - " \"public_key\": \"public-key\"" + - " }"; - // @formatter:on + final String credentials = """ + "type": "ssh", + "value": { + "public_key": "public-key" + } + """; CredentialDetails data = parseDetails(credentials); assertDetails(data, "public-key", null, null); @@ -60,13 +58,12 @@ public class SshCredentialDetailsUnitTests extends JsonParsingUnitTestsBase { @Test public void deserializeDetailsWithPrivateKey() { - // @formatter:off - final String credentials = - " \"type\": \"ssh\"," + - " \"value\": {" + - " \"private_key\": \"private-key\"" + - " }"; - // @formatter:on + final String credentials = """ + "type": "ssh", + "value": { + "private_key": "private-key" + } + """; CredentialDetails data = parseDetails(credentials); assertDetails(data, null, "private-key", null); diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/user/UserCredentialDetailsUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/user/UserCredentialDetailsUnitTests.java index 9e143d1..b3adb14 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/user/UserCredentialDetailsUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/user/UserCredentialDetailsUnitTests.java @@ -27,15 +27,14 @@ import static org.assertj.core.api.Assertions.assertThat; public class UserCredentialDetailsUnitTests extends JsonParsingUnitTestsBase { - // @formatter:off - private static final String USER_CREDENTIALS = - " \"type\": \"user\"," + - " \"value\": {" + - " \"username\": \"myname\"," + - " \"password\": \"secret\"," + - " \"password_hash\": \"secret-hash\"" + - " }"; - // @formatter:on + private static final String USER_CREDENTIALS = """ + "type": "user", + "value": { + "username": "myname", + "password": "secret", + "password_hash": "secret-hash" + } + """; @Test public void deserializeDetails() { diff --git a/spring-credhub-core/src/test/java/org/springframework/credhub/support/value/ValueCredentialDetailsUnitTests.java b/spring-credhub-core/src/test/java/org/springframework/credhub/support/value/ValueCredentialDetailsUnitTests.java index 1638507..61f3474 100644 --- a/spring-credhub-core/src/test/java/org/springframework/credhub/support/value/ValueCredentialDetailsUnitTests.java +++ b/spring-credhub-core/src/test/java/org/springframework/credhub/support/value/ValueCredentialDetailsUnitTests.java @@ -27,11 +27,10 @@ import static org.assertj.core.api.Assertions.assertThat; public class ValueCredentialDetailsUnitTests extends JsonParsingUnitTestsBase { - // @formatter:off - private static final String VALUE_CREDENTIALS = - " \"type\": \"value\"," + - " \"value\": \"somevalue\""; - // @formatter:on + private static final String VALUE_CREDENTIALS = """ + "type": "value", + "value": "somevalue" + """; @Test public void deserializeDetails() { diff --git a/spring-credhub-demo/src/main/java/org/springframework/credhub/demo/CredHubDemoController.java b/spring-credhub-demo/src/main/java/org/springframework/credhub/demo/CredHubDemoController.java index 8d4cbb6..c97534e 100644 --- a/spring-credhub-demo/src/main/java/org/springframework/credhub/demo/CredHubDemoController.java +++ b/spring-credhub-demo/src/main/java/org/springframework/credhub/demo/CredHubDemoController.java @@ -196,24 +196,22 @@ public class CredHubDemoController { } private ServicesData buildServicesData(String credHubReferenceName) throws IOException { - // @formatter:off - String vcapServices = "{" + - " \"service-offering\": [" + - " {" + - " \"credentials\": {" + - " \"credhub-ref\": \"((" + credHubReferenceName + "))\"" + - " }," + - " \"label\": \"service-offering\"," + - " \"name\": \"service-instance\"," + - " \"plan\": \"standard\"," + - " \"tags\": [" + - " \"cloud-service\"" + - " ]," + - " \"volume_mounts\": []" + - " }" + - " ]" + - "}"; - // @formatter:on + String vcapServices = """ + { + "service-offering": [ + { + "credentials": { + "credhub-ref": "((%s))" + }, + "label": "service-offering", + "name": "service-instance", + "plan": "standard", + "tags": [ "cloud-service" ], + "volume_mounts": [] + } + ] + } + """.formatted(credHubReferenceName); ObjectMapper mapper = new ObjectMapper(); return mapper.readValue(vcapServices, ServicesData.class); diff --git a/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/InterpolationIntegrationTests.java b/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/InterpolationIntegrationTests.java index 2761010..3709494 100644 --- a/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/InterpolationIntegrationTests.java +++ b/spring-credhub-integration-tests/src/test/java/org/springframework/credhub/integration/InterpolationIntegrationTests.java @@ -88,24 +88,20 @@ public class InterpolationIntegrationTests extends CredHubIntegrationTests { } private ServicesData buildVcapServices(String credHubReferenceName) throws IOException { - // @formatter:off - String vcapServices = "{" + - " \"service-offering\": [" + - " {" + - " \"credentials\": {" + - " \"credhub-ref\": \"((" + credHubReferenceName + "))\"" + - " }," + - " \"label\": \"service-offering\"," + - " \"name\": \"service-instance\"," + - " \"plan\": \"standard\"," + - " \"tags\": [" + - " \"cloud-service\"" + - " ]," + - " \"volume_mounts\": []" + - " }" + - " ]" + - "}"; - // @formatter:on + String vcapServices = """ + { + "service-offering": [{ + "credentials": { + "credhub-ref": "((%s))" + }, + "label": "service-offering", + "name": "service-instance", + "plan": "standard", + "tags": [ "cloud-service" ], + "volume_mounts": [] + }] + } + """.formatted(credHubReferenceName); ObjectMapper mapper = JsonUtils.buildObjectMapper(); return mapper.readValue(vcapServices, ServicesData.class); diff --git a/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactiveInterpolationIntegrationTests.java b/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactiveInterpolationIntegrationTests.java index fac183b..086d60c 100644 --- a/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactiveInterpolationIntegrationTests.java +++ b/spring-credhub-reactive-integration-tests/src/test/java/org/springframework/credhub/integration/ReactiveInterpolationIntegrationTests.java @@ -91,24 +91,20 @@ public class ReactiveInterpolationIntegrationTests extends ReactiveCredHubIntegr } private ServicesData buildVcapServices(String credHubReferenceName) throws IOException { - // @formatter:off - String vcapServices = "{" + - " \"service-offering\": [" + - " {" + - " \"credentials\": {" + - " \"credhub-ref\": \"((" + credHubReferenceName + "))\"" + - " }," + - " \"label\": \"service-offering\"," + - " \"name\": \"service-instance\"," + - " \"plan\": \"standard\"," + - " \"tags\": [" + - " \"cloud-service\"" + - " ]," + - " \"volume_mounts\": []" + - " }" + - " ]" + - "}"; - // @formatter:on + String vcapServices = """ + { + "service-offering": [{ + "credentials": { + "credhub-ref": "((%s))" + }, + "label": "service-offering", + "name": "service-instance", + "plan": "standard", + "tags": [ "cloud-service" ], + "volume_mounts": [] + }] + } + """.formatted(credHubReferenceName); ObjectMapper mapper = JsonUtils.buildObjectMapper(); return mapper.readValue(vcapServices, ServicesData.class);