*/
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)
-public class ControlPanelTestServer {
+class ControlPanelTestServer {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@SuppressWarnings("squid:S2699") // To avoid warning about missing assertion.
@EnabledIfSystemProperty(named = "org.oransc.portal.nonrtric.controlpanel", matches = "mock")
@Test
- public void keepServerAlive() {
+ void keepServerAlive() {
logger.warn("Keeping server alive!");
try {
synchronized (this) {
import org.springframework.test.context.ActiveProfiles;
@ActiveProfiles("test")
-public class ControlPanelUserManagerTest {
+class ControlPanelUserManagerTest {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
}
@Test
- public void testUserMgr() throws Exception {
+ void testUserMgr() throws Exception {
final String loginId = "demo";
ControlPanelUserManager dum = new ControlPanelUserManager(true);
EcompUser user = createEcompUser(loginId);
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
// Need the fake answers from the backend
@ActiveProfiles("test")
-public class AbstractControllerTest {
+class AbstractControllerTest {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
// Because I put the annotations on this parent class,
// must define at least one test here.
@Test
- public void contextLoads() {
+ void contextLoads() {
// Silence Sonar warning about missing assertion.
Assertions.assertTrue(logger.isWarnEnabled());
logger.info("Context loads on mock profile");
*/
@ExtendWith(SpringExtension.class)
@SpringBootTest
-public class DefaultContextTest {
+class DefaultContextTest {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@Test
- public void contextLoads() {
+ void contextLoads() {
// Silence Sonar warning about missing assertion.
Assertions.assertTrue(logger.isWarnEnabled());
logger.info("Context loads on default profile");
import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.http.ResponseEntity;
import org.springframework.web.reactive.function.client.WebClientResponseException;
+import reactor.core.publisher.Mono;
-public class PortalRestCentralServiceTest extends AbstractControllerTest {
+class PortalRestCentralServiceTest extends AbstractControllerTest {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@Test
- public void getAnalyticsTest() {
+ void getAnalyticsTest() {
// paths are hardcoded here exactly like the EPSDK-FW library :(
URI uri = buildUri(null, PortalApiConstants.API_PREFIX, "/analytics");
logger.info("Invoking {}", uri);
+ Mono<ResponseEntity<String>> forEntity = webClient.getForEntity(uri.toString());
WebClientResponseException e = assertThrows(WebClientResponseException.class, () -> {
- webClient.getForEntity(uri.toString()).block();
+ forEntity.block();
});
// No Portal is available so this always fails
Assertions.assertTrue(e.getStatusCode().is4xxClientError());
}
@Test
- public void getErrorPageTest() {
+ void getErrorPageTest() {
// Send unauthorized request
URI uri = buildUri(null, "/favicon.ico");
logger.info("Invoking {}", uri);
+ Mono<ResponseEntity<String>> forEntity = webClient.getForEntity(uri.toString());
WebClientResponseException e = assertThrows(WebClientResponseException.class, () -> {
- webClient.getForEntity(uri.toString()).block();
+ forEntity.block();
});
Assertions.assertTrue(e.getStatusCode().is4xxClientError());
Assertions.assertTrue(e.getResponseBodyAsString().contains("Static error page"));
import org.springframework.web.client.HttpServerErrorException;
import reactor.core.publisher.Mono;
-public class PolicyAgentApiImplTest {
+class PolicyAgentApiImplTest {
private static final String URL_POLICY_SCHEMAS = "/policy_schemas";
private static final String POLICY_TYPE_1_ID = "type1";
private static final String POLICY_TYPE_1_VALID = "{\"title\":\"type1\"}";
AsyncRestClient restClient;
@BeforeEach
- public void init() {
+ void init() {
restClient = mock(AsyncRestClient.class);
apiUnderTest = new PolicyAgentApiImpl(restClient);
}
}
@Test
- public void testGetAllPolicyTypesFailure() {
+ void testGetAllPolicyTypesFailure() {
whenGetReturnFailure(URL_POLICY_SCHEMAS, HttpStatus.NOT_FOUND, "");
ResponseEntity<String> returnedResp = apiUnderTest.getAllPolicyTypes();
assertEquals(HttpStatus.NOT_FOUND, returnedResp.getStatusCode());
}
@Test
- public void testGetAllPolicyTypesSuccessValidJson() {
+ void testGetAllPolicyTypesSuccessValidJson() {
String policyTypes = Arrays.asList(POLICY_TYPE_1_VALID, POLICY_TYPE_2_VALID).toString();
whenGetReturnOK(URL_POLICY_SCHEMAS, HttpStatus.OK, policyTypes);
}
@Test
- public void testGetAllPolicyTypesSuccessInvalidJson() {
+ void testGetAllPolicyTypesSuccessInvalidJson() {
String policyTypes = Arrays.asList(POLICY_TYPE_1_INVALID, POLICY_TYPE_2_VALID).toString();
whenGetReturnOK(URL_POLICY_SCHEMAS, HttpStatus.OK, policyTypes);
}
@Test
- public void testGetPolicyInstancesForTypeFailure() {
+ void testGetPolicyInstancesForTypeFailure() {
whenGetReturnFailure(urlPolicyInstances(POLICY_TYPE_1_ID), HttpStatus.NOT_FOUND, "");
ResponseEntity<String> returnedResp = apiUnderTest.getPolicyInstancesForType(POLICY_TYPE_1_ID);
}
@Test
- public void testGetPolicyInstancesForTypeSuccessValidJson() {
+ void testGetPolicyInstancesForTypeSuccessValidJson() {
String policyInstances = Arrays.asList(POLICY_1_VALID).toString();
String policyInstancesJson = parsePolicyInstancesJson(policyInstances);
}
@Test
- public void testGetPolicyInstancesForTypeSuccessInvalidJson() {
+ void testGetPolicyInstancesForTypeSuccessInvalidJson() {
String policyInstances = Arrays.asList(POLICY_1_INVALID).toString();
whenGetReturnOK(urlPolicyInstances(POLICY_TYPE_1_ID), HttpStatus.OK, policyInstances);
}
@Test
- public void testGetPolicyInstance() {
+ void testGetPolicyInstance() {
whenGetReturnOK(urlPolicyInstance(POLICY_1_ID), HttpStatus.OK, POLICY_1_VALID);
ResponseEntity<Object> returnedResp = apiUnderTest.getPolicyInstance(POLICY_1_ID);
}
@Test
- public void testPutPolicyFailure() {
+ void testPutPolicyFailure() {
String url = urlPutPolicy(POLICY_TYPE_1_ID, POLICY_1_ID, RIC_1_ID);
whenPutReturnFailure(url, POLICY_1_VALID, HttpStatus.NOT_FOUND, CLIENT_ERROR_MESSAGE);
}
@Test
- public void testPutPolicySuccess() {
+ void testPutPolicySuccess() {
String url = urlPutPolicy(POLICY_TYPE_1_ID, POLICY_1_ID, RIC_1_ID);
whenPutReturnOK(url, POLICY_1_VALID, HttpStatus.OK, POLICY_1_VALID);
}
@Test
- public void testDeletePolicyFailure() {
+ void testDeletePolicyFailure() {
whenDeleteReturnFailure(deletePolicyUrl(POLICY_1_ID), HttpStatus.NOT_FOUND, CLIENT_ERROR_MESSAGE);
ResponseEntity<String> returnedResp = apiUnderTest.deletePolicy(POLICY_1_ID);
}
@Test
- public void testDeletePolicySuccess() {
+ void testDeletePolicySuccess() {
whenDeleteReturnOK(deletePolicyUrl(POLICY_1_ID), HttpStatus.OK);
ResponseEntity<String> returnedResp = apiUnderTest.deletePolicy(POLICY_1_ID);
}
@Test
- public void testGetRicsSupportingTypeValidJson() {
+ void testGetRicsSupportingTypeValidJson() {
String rics = Arrays.asList(RIC_1_INFO_VALID).toString();
this.whenGetReturnOK(urlRicInfo(POLICY_TYPE_1_ID), HttpStatus.OK, rics);
}
@Test
- public void testGetRicsSupportingTypeInvalidJson() {
+ void testGetRicsSupportingTypeInvalidJson() {
String rics = Arrays.asList(RIC_1_INFO_INVALID).toString();
this.whenGetReturnOK(urlRicInfo(POLICY_TYPE_1_ID), HttpStatus.OK, rics);
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@ActiveProfiles("test")
-public class PortalAuthManagerTest {
+class PortalAuthManagerTest {
@Value("${portalapi.decryptor}")
private String decryptor;
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@Test
- public void testPortalStuff() throws ClassNotFoundException, InstantiationException, IllegalAccessException,
+ void testPortalStuff() throws ClassNotFoundException, InstantiationException, IllegalAccessException,
InvocationTargetException, NoSuchMethodException, IOException, ServletException {
PortalAuthManager m = new PortalAuthManager("app", "user", "secret", decryptor, "cookie");
import reactor.test.StepVerifier;
import reactor.util.Loggers;
-public class AsyncRestClientTest {
+class AsyncRestClientTest {
private static final String BASE_URL = "BaseUrl";
private static final String REQUEST_URL = "/test";
private static final String TEST_JSON = "{\"type\":\"type1\"}";
}
@Test
- public void testGetNoError() {
+ void testGetNoError() {
mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) //
.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) //
.setBody(TEST_JSON));
}
@Test
- public void testGetError() {
+ void testGetError() {
mockWebServer.enqueue(new MockResponse().setResponseCode(ERROR_CODE));
Mono<String> returnedMono = clientUnderTest.get(REQUEST_URL);
}
@Test
- public void testPutNoError() {
+ void testPutNoError() {
mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) //
.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) //
.setBody(TEST_JSON));
}
@Test
- public void testPutError() {
+ void testPutError() {
mockWebServer.enqueue(new MockResponse().setResponseCode(ERROR_CODE));
Mono<String> returnedMono = clientUnderTest.put(REQUEST_URL, TEST_JSON);
}
@Test
- public void testDeleteNoError() {
+ void testDeleteNoError() {
mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE));
Mono<String> returnedMono = clientUnderTest.delete(REQUEST_URL);
}
@Test
- public void testDeleteError() {
+ void testDeleteError() {
mockWebServer.enqueue(new MockResponse().setResponseCode(ERROR_CODE));
Mono<String> returnedMono = clientUnderTest.delete(REQUEST_URL);