}
+ @ResponseBody
+ @RequestMapping(value = {"/api/cnf-adapter/v1/instance/{instanceId}/query"}, method = RequestMethod.GET,
+ produces = "application/json")
+ public String getInstanceQueryByInstanceId(@PathVariable("instanceId") String instanceId) {
+ logger.info("getInstanceQueryByInstanceId called.");
+
+ return cnfAdapterService.getInstanceQueryByInstanceId(instanceId);
+ }
+
@RequestMapping(value = {"/api/cnf-adapter/v1/instance"}, method = RequestMethod.GET, produces = "application/json")
public String getInstanceByRBNameOrRBVersionOrProfileName(
@RequestParam(value = "rb-name", required = false) String rbName,
}
throw e;
} catch (HttpStatusCodeException e) {
- logger.error("Error in Multicloud, e");
+ logger.error("Error in Multicloud", e);
throw e;
}
}
}
throw e;
} catch (HttpStatusCodeException e) {
- logger.error("Error in Multicloud, e");
+ logger.error("Error in Multicloud", e);
throw e;
}
}
}
throw e;
} catch (HttpStatusCodeException e) {
- logger.error("Error in Multicloud, e");
+ logger.error("Error in Multicloud", e);
throw e;
}
}
}
throw e;
} catch (HttpStatusCodeException e) {
- logger.error("Error in Multicloud, e");
+ logger.error("Error in Multicloud", e);
throw e;
}
}
+ public String getInstanceQueryByInstanceId(String instanceId) {
+ logger.info("CnfAdapterService getInstanceQueryByInstanceId called");
+ ResponseEntity<String> instanceResponse = null;
+ try {
+ String uri = "http://multicloud-k8s:9015";
+ String path = "/v1/instance/" + instanceId + "/query";
+ String endpoint = UriBuilder.fromUri(uri).path(path).build().toString();
+ HttpEntity<?> requestEntity = new HttpEntity<>(getHttpHeaders());
+ instanceResponse = restTemplate.exchange(endpoint, HttpMethod.GET, requestEntity, String.class);
+ return instanceResponse.getBody();
+ } catch (HttpClientErrorException e) {
+ if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+ throw new EntityNotFoundException(e.getResponseBodyAsString());
+ }
+ throw e;
+ }
+ }
+
public String getInstanceByRBNameOrRBVersionOrProfileName(String rbName, String rbVersion, String profileName)
throws JsonParseException, JsonMappingException, IOException {
}
throw e;
} catch (HttpStatusCodeException e) {
- logger.error("Error in Multicloud, e");
+ logger.error("Error in Multicloud", e);
throw e;
}
}
}
throw e;
} catch (HttpStatusCodeException e) {
- logger.error("Error in Multicloud, e");
+ logger.error("Error in Multicloud", e);
throw e;
}
}
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;
-import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertEquals;
+import static org.assertj.core.api.Java6Assertions.assertThat;
@RunWith(SpringRunner.class)
assertEquals(HttpStatus.OK, instanceStatusResponse.getStatusCode());
}
+ @Test
+ public void getInstanceQueryByInstanceIdTest() {
+ String instanceId = "123";
+ String queryResponseMock = "queryResponseMock";
+
+ Mockito.when(cnfAdapterService.getInstanceQueryByInstanceId(instanceId)).thenReturn(queryResponseMock);
+
+ String result = cnfAdapterRest.getInstanceQueryByInstanceId(instanceId);
+ assertThat(result).isEqualTo(queryResponseMock);
+ }
+
@Test
public void getInstanceByRBNameOrRBVersionOrProfileNameTest() throws Exception {
}
+