X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=inline;f=r-app-catalogue%2Fsrc%2Ftest%2Fjava%2Forg%2Foransc%2Frappcatalogue%2Fapi%2FGeneralRappCatalogueControllerAdvisorTest.java;fp=r-app-catalogue%2Fsrc%2Ftest%2Fjava%2Forg%2Foransc%2Frappcatalogue%2Fapi%2FGeneralRappCatalogueControllerAdvisorTest.java;h=0000000000000000000000000000000000000000;hb=f93f9afe8d92bbf00912934d0ee022542b656775;hp=24afa09e9dad9be0fe6ece5c361aca6277e229c1;hpb=c4af20d0ee12a70452a236b02ea9279fdccb4bb7;p=nonrtric.git diff --git a/r-app-catalogue/src/test/java/org/oransc/rappcatalogue/api/GeneralRappCatalogueControllerAdvisorTest.java b/r-app-catalogue/src/test/java/org/oransc/rappcatalogue/api/GeneralRappCatalogueControllerAdvisorTest.java deleted file mode 100644 index 24afa09e..00000000 --- a/r-app-catalogue/src/test/java/org/oransc/rappcatalogue/api/GeneralRappCatalogueControllerAdvisorTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * Copyright (C) 2020 Nordix Foundation. All rights reserved. - * ====================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ========================LICENSE_END=================================== - */ - -package org.oransc.rappcatalogue.api; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.http.HttpStatus.BAD_REQUEST; -import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR; -import static org.springframework.http.HttpStatus.NOT_FOUND; - -import org.junit.jupiter.api.Test; -import org.oransc.rappcatalogue.exception.HeaderException; -import org.oransc.rappcatalogue.exception.InvalidServiceException; -import org.oransc.rappcatalogue.exception.ServiceNotFoundException; -import org.oransc.rappcatalogue.model.ErrorInformation; -import org.springframework.http.ResponseEntity; - -class GeneralRappCatalogueControllerAdvisorTest { - - @Test - void handleInvalidServiceException_shouldReturnBadRequestWithMessage() { - GeneralRappCatalogueControllerAdvisor advisorUnderTest = new GeneralRappCatalogueControllerAdvisor(); - - InvalidServiceException exception = new InvalidServiceException(); - - ResponseEntity response = advisorUnderTest.handleInvalidServiceException(exception); - - assertThat(response.getStatusCode()).isEqualTo(BAD_REQUEST); - ErrorInformation body = (ErrorInformation) response.getBody(); - assertThat(body.getStatus()).isEqualTo(BAD_REQUEST.value()); - assertThat(body.getDetail()).isEqualTo("Service is missing required property: version"); - } - - @Test - void handleServiceNotFoundException_shouldReturnNotFoundWithMessage() { - GeneralRappCatalogueControllerAdvisor advisorUnderTest = new GeneralRappCatalogueControllerAdvisor(); - - ServiceNotFoundException exception = new ServiceNotFoundException("Name"); - - ResponseEntity response = advisorUnderTest.handleServiceNotFoundException(exception); - - assertThat(response.getStatusCode()).isEqualTo(NOT_FOUND); - ErrorInformation body = (ErrorInformation) response.getBody(); - assertThat(body.getStatus()).isEqualTo(NOT_FOUND.value()); - assertThat(body.getDetail()).isEqualTo("Service Name not found"); - } - - @Test - void handleHeaderException_shouldReturnInternalServerErrorWithMessage() { - GeneralRappCatalogueControllerAdvisor advisorUnderTest = new GeneralRappCatalogueControllerAdvisor(); - - String serviceName = "Service"; - HeaderException exception = new HeaderException("Header", serviceName, new Exception("Cause")); - - ResponseEntity response = advisorUnderTest.handleHeaderException(exception); - - assertThat(response.getStatusCode()).isEqualTo(INTERNAL_SERVER_ERROR); - ErrorInformation body = (ErrorInformation) response.getBody(); - assertThat(body.getStatus()).isEqualTo(INTERNAL_SERVER_ERROR.value()); - assertThat(body.getDetail()) - .isEqualTo("Unable to set header Header in put response for service " + serviceName + ". Cause: Cause"); - } -}