+ @DataProvider
+ public static Object[][] dataToDestroy() {
+ return new Object[][]{
+ {"nothing"}, {"relationship-list"}, {"relationship"}, {"relationship-data"} ,{"owning-entity-id"}
+ };
+ }
+
+
+ @Test(dataProvider = "dataToDestroy")
+ public void relatedOwningEntityId_givenInstanceAndOptionalError_extractCorrectlyOrReturnNull(String dataToDestroy) throws JsonProcessingException {
+ ServiceInstance serviceInstance = new ObjectMapper().readValue((""
+ + "{ "
+ + " \"service-instance-id\": \"5d521981-33be-4bb5-bb20-5616a9c52a5a\", "
+ + " \"service-instance-name\": \"dfgh\", "
+ + " \"service-type\": \"\", "
+ + " \"service-role\": \"\", "
+ + " \"environment-context\": \"null\", "
+ + " \"workload-context\": \"null\", "
+ + " \"model-invariant-id\": \"331a194d-9248-4533-88bc-62c812ccb5c1\", "
+ + " \"model-version-id\": \"171b3887-e73e-479d-8ef8-2690bf74f2aa\", "
+ + " \"resource-version\": \"1508832105498\", "
+ + " \"orchestration-status\": \"Active\", "
+ + " \"relationship-list\": { "
+ + " \"relationship\": [ "
+ + " { "
+ + " \"related-to\": \"project\", "
+ + " \"related-link\": \"/aai/v11/business/projects/project/Kennedy\", "
+ + " \"relationship-data\": [ "
+ + " { "
+ + " \"relationship-key\": \"project.project-name\", "
+ + " \"relationship-value\": \"Kennedy\" "
+ + " } "
+ + " ] "
+ + " }, "
+ + " { "
+ + " \"related-to\": \"owning-entity\", "
+ + " \"related-link\": \"/aai/v11/business/owning-entities/owning-entity/4d4ecf59-41f1-40d4-818d-885234680a42\", "
+ + " \"relationship-data\": [ "
+ + " { "
+ + " \"relationship-key\": \"owning-entity.owning-entity-id\", "
+ + " \"relationship-value\": \"4d4ecf59-41f1-40d4-818d-885234680a42\" "
+ + " } "
+ + " ] "
+ + " } "
+ + " ] "
+ + " } "
+ + "}").replace(dataToDestroy, "omitted"), ServiceInstance.class);
+
+ if (dataToDestroy.equals("nothing")) {
+ assertThat(aaiService.relatedOwningEntityId(serviceInstance), is("4d4ecf59-41f1-40d4-818d-885234680a42"));
+ } else {
+ assertThat(aaiService.relatedOwningEntityId(serviceInstance), is(nullValue()));
+ }
+ }
+