_build/
.swagger*
docs/offeredapis/swagger/README.md
+a1-policy-management/api/.openapi-generator*
+
<guava.version>31.0.1-jre</guava.version>
<docker-maven-plugin>0.30.0</docker-maven-plugin>
<surefire-maven-plugin.version>3.0.0-M5</surefire-maven-plugin.version>
+ <surefire-report-plugin.version>3.0.0-M8</surefire-report-plugin.version>
<jacoco-maven-plugin.version>0.8.8</jacoco-maven-plugin.version>
<swagger-codegen-maven-plugin.version>3.0.11</swagger-codegen-maven-plugin.version>
<exec.skip>true</exec.skip>
<version>${surefire-maven-plugin.version}</version>
<configuration>
<skipTests>false</skipTests>
+ <statelessTestsetReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5Xml30StatelessReporter">
+ <disable>false</disable>
+ <version>3.0</version>
+ <usePhrasedFileName>false</usePhrasedFileName>
+ <usePhrasedTestSuiteClassName>true</usePhrasedTestSuiteClassName>
+ <usePhrasedTestCaseClassName>true</usePhrasedTestCaseClassName>
+ <usePhrasedTestCaseMethodName>true</usePhrasedTestCaseMethodName>
+ </statelessTestsetReporter>
+ <consoleOutputReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5ConsoleOutputReporter">
+ <disable>false</disable>
+ <encoding>UTF-8</encoding>
+ <usePhrasedFileName>false</usePhrasedFileName>
+ </consoleOutputReporter>
+ <statelessTestsetInfoReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoReporter">
+ <disable>false</disable>
+ <usePhrasedFileName>false</usePhrasedFileName>
+ <usePhrasedClassNameInRunning>true</usePhrasedClassNameInRunning>
+ <usePhrasedClassNameInTestCaseSummary>true</usePhrasedClassNameInTestCaseSummary>
+ </statelessTestsetInfoReporter>
</configuration>
</plugin>
<plugin>
</plugin>
</plugins>
</build>
-</project>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ <version>${surefire-report-plugin.version}</version>
+ </plugin>
+ </plugins>
+ </reporting>
+</project>
\ No newline at end of file
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.reflect.MethodSignature;
+import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
LoggingUtils utils;
@Test
+ @DisplayName("test Executetime Time should Log Time")
void testExecutetimeTime_shouldLogTime() throws Throwable {
when(proceedingJoinPoint.getSignature()).thenReturn(methodSignature);
when(methodSignature.getDeclaringType()).thenReturn(this.getClass());
}
@Test
+ @DisplayName("test Entry Log should Log Entry")
void testEntryLog_shouldLogEntry() throws Throwable {
when(proceedingJoinPoint.getSignature()).thenReturn(methodSignature);
String signature = "signature";
}
@Test
+ @DisplayName("test Exit Log should Log Exit")
void testExitLog_shouldLogExit() throws Throwable {
when(proceedingJoinPoint.getSignature()).thenReturn(methodSignature);
String signature = "signature";
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
}
@Test
+ @DisplayName("test get Protocol Version ok")
void getProtocolVersion_ok() throws ServiceException {
whenGetProtocolVersionThrowException(clientMock1);
whenGetProtocolVersionReturn(clientMock2, A1ProtocolType.STD_V1_1);
}
@Test
+ @DisplayName("test get Protocol Version ok Last")
void getProtocolVersion_ok_Last() throws ServiceException {
whenGetProtocolVersionThrowException(clientMock1, clientMock2, clientMock3);
whenGetProtocolVersionReturn(clientMock4, A1ProtocolType.STD_V1_1);
}
@Test
+ @DisplayName("test Custom Adapter Creation")
void testCustomAdapterCreation() {
Ric ric = new Ric(ricConfig("", CustomA1AdapterFactory.class.getName()));
}
@Test
+ @DisplayName("test get Protocol Version error")
void getProtocolVersion_error() throws ServiceException {
whenGetProtocolVersionThrowException(clientMock1, clientMock2, clientMock3, clientMock4);
doReturn(clientMock1, clientMock2, clientMock3, clientMock4).when(factoryUnderTest).createClient(any(), any());
}
@Test
+ @DisplayName("tes create check types")
void create_check_types() throws ServiceException {
assertTrue(createClient(A1ProtocolType.STD_V1_1) instanceof StdA1ClientVersion1);
assertTrue(createClient(A1ProtocolType.OSC_V1) instanceof OscA1Client);
}
@Test
+ @DisplayName("test create check types controllers")
void create_check_types_controllers() throws ServiceException {
this.ric = new Ric(ricConfig("anythingButEmpty"));
whenGetGetControllerConfigReturn();
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
}
@Test
+ @DisplayName("test Get No Error")
void testGetNoError() {
mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) //
.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) //
}
@Test
+ @DisplayName("test Get Error")
void testGetError() {
mockWebServer.enqueue(new MockResponse().setResponseCode(ERROR_CODE));
}
@Test
+ @DisplayName("test Put No Error")
void testPutNoError() {
mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) //
.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) //
}
@Test
+ @DisplayName("test Put Error")
void testPutError() {
mockWebServer.enqueue(new MockResponse().setResponseCode(ERROR_CODE));
}
@Test
+ @DisplayName("test Delete No Error")
void testDeleteNoError() {
mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE));
}
@Test
+ @DisplayName("test Delete Error")
void testDeleteError() {
mockWebServer.enqueue(new MockResponse().setResponseCode(ERROR_CODE));
}
@Test
+ @DisplayName("test Post No Error")
void testPostNoError() {
mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) //
.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) //
}
@Test
+ @DisplayName("test Post Error")
void testPostError() {
mockWebServer.enqueue(new MockResponse().setResponseCode(ERROR_CODE));
}
@Test
+ @DisplayName("test Post With Auth Header No Error")
void testPostWithAuthHeaderNoError() {
mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) //
.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) //
}
@Test
+ @DisplayName("test Post With Auth Header Error")
void testPostWithAuthHeaderError() {
mockWebServer.enqueue(new MockResponse().setResponseCode(ERROR_CODE));
import java.util.Arrays;
import java.util.List;
+import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
}
@Test
+ @DisplayName("test create Client With Wrong Protocol then Error Is Thrown")
void createClientWithWrongProtocol_thenErrorIsThrown() {
AsyncRestClient asyncRestClient = new AsyncRestClient("", null, null, new SecurityContext(""));
assertThrows(IllegalArgumentException.class, () -> {
}
@Test
+ @DisplayName("test get Policy Type Identities STD V1")
void getPolicyTypeIdentities_STD_V1() {
clientUnderTest = new CcsdkA1AdapterClient(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1, //
A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
}
@Test
+ @DisplayName("test get Policy Type Identities OSC")
void getPolicyTypeIdentities_OSC() {
testGetPolicyTypeIdentities(A1ProtocolType.CCSDK_A1_ADAPTER_OSC_V1, RIC_1_URL + "/a1-p/policytypes");
}
@Test
+ @DisplayName("test get Policy Type Identities STD V2")
void getPolicyTypeIdentities_STD_V2() {
testGetPolicyTypeIdentities(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V2_0_0, RIC_1_URL + "/A1-P/v2/policytypes");
}
@Test
+ @DisplayName("test get Type Schema STD V1")
void getTypeSchema_STD_V1() {
clientUnderTest = new CcsdkA1AdapterClient(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1, //
}
@Test
+ @DisplayName("test get Type Schema OSC")
void getTypeSchema_OSC() throws IOException {
String expUrl = RIC_1_URL + "/a1-p/policytypes/policyTypeId";
testGetTypeSchema(A1ProtocolType.CCSDK_A1_ADAPTER_OSC_V1, expUrl, "policyTypeId",
}
@Test
+ @DisplayName("test get Type Schema STD V2")
void getTypeSchema_STD_V2() throws IOException {
String expUrl = RIC_1_URL + "/A1-P/v2/policytypes/policyTypeId";
testGetTypeSchema(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V2_0_0, expUrl, "policyTypeId",
}
@Test
+ @DisplayName("test parse Json Array Of String")
void parseJsonArrayOfString() {
// One integer and one string
String inputString = "[1, \"1\" ]";
}
@Test
+ @DisplayName("test get Policy Identities STD V1")
void getPolicyIdentities_STD_V1() {
String expUrl = RIC_1_URL + "/A1-P/v1/policies";
getPolicyIdentities(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1, expUrl);
}
@Test
+ @DisplayName("test get Policy Identities STD V2")
void getPolicyIdentities_STD_V2() {
String expUrlPolicies = RIC_1_URL + "/A1-P/v2/policytypes";
String expUrlInstances = RIC_1_URL + "/A1-P/v2/policytypes/xxx/policies";
}
@Test
+ @DisplayName("test get Policy Identities OSC")
void getPolicyIdentities_OSC() {
String expUrlTypes = RIC_1_URL + "/a1-p/policytypes";
String expUrlInstances = RIC_1_URL + "/a1-p/policytypes/xxx/policies";
}
@Test
+ @DisplayName("test put Policy OSC")
void putPolicy_OSC() {
String expUrl = RIC_1_URL + "/a1-p/policytypes/type1/policies/policy1";
putPolicy(A1ProtocolType.CCSDK_A1_ADAPTER_OSC_V1, expUrl);
}
@Test
+ @DisplayName("test put Policy STD V1")
void putPolicy_STD_V1() {
String expUrl = RIC_1_URL + "/A1-P/v1/policies/policy1";
putPolicy(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1, expUrl);
}
@Test
+ @DisplayName("test put Policy STD V2")
void putPolicy_STD_V2() {
String expUrl =
RIC_1_URL + "/A1-P/v2/policytypes/type1/policies/policy1?notificationDestination=https://test.com";
}
@Test
+ @DisplayName("test post Rejected")
void postRejected() {
clientUnderTest = new CcsdkA1AdapterClient(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1, //
A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
}
@Test
+ @DisplayName("test delete All Policies STD V2")
void deleteAllPolicies_STD_V2() {
String expUrl1 = RIC_1_URL + "/A1-P/v2/policytypes/xxx/policies/xxx";
deleteAllPolicies(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V2_0_0, expUrl1);
}
@Test
+ @DisplayName("test delete All Policies STD V1")
void deleteAllPolicies_STD_V1() {
String expUrl1 = RIC_1_URL + "/A1-P/v1/policies/xxx";
deleteAllPolicies(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V1_1, expUrl1);
}
@Test
+ @DisplayName("test delete All Policies OSC")
void deleteAllPolicies_OSC() {
String expUrl1 = RIC_1_URL + "/a1-p/policytypes/xxx/policies/xxx";
deleteAllPolicies(A1ProtocolType.CCSDK_A1_ADAPTER_OSC_V1, expUrl1);
}
@Test
+ @DisplayName("test get Version OSC")
void getVersion_OSC() {
clientUnderTest = new CcsdkA1AdapterClient(A1ProtocolType.CCSDK_A1_ADAPTER_OSC_V1, // Version irrelevant here
A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
}
@Test
+ @DisplayName("test Get Status")
void testGetStatus() {
clientUnderTest = new CcsdkA1AdapterClient(A1ProtocolType.CCSDK_A1_ADAPTER_STD_V2_0_0, //
A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
import org.json.JSONException;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
}
@Test
+ @DisplayName("test Get Policy Type Identities")
void testGetPolicyTypeIdentities() {
List<String> policyTypeIds = Arrays.asList(POLICY_TYPE_1_ID, POLICY_TYPE_2_ID);
Mono<String> policyTypeIdsResp = Mono.just(policyTypeIds.toString());
}
@Test
+ @DisplayName("test Get Policy Identities")
void testGetPolicyIdentities() {
Mono<String> policyTypeIdsResp = Mono.just(Arrays.asList(POLICY_TYPE_1_ID, POLICY_TYPE_2_ID).toString());
Mono<String> policyIdsType1Resp = Mono.just(Arrays.asList(POLICY_1_ID).toString());
}
@Test
+ @DisplayName("test Get Valid PolicyType")
void testGetValidPolicyType() {
String policyType = "{\"create_schema\": " + POLICY_TYPE_SCHEMA_VALID + "}";
Mono<String> policyTypeResp = Mono.just(policyType);
}
@Test
+ @DisplayName("test Get In Valid Policy Type Json")
void testGetInValidPolicyTypeJson() {
String policyType = "{\"create_schema\": " + POLICY_TYPE_SCHEMA_INVALID + "}";
Mono<String> policyTypeResp = Mono.just(policyType);
}
@Test
+ @DisplayName("test Get Policy Type Without CreateS chema")
void testGetPolicyTypeWithoutCreateSchema() {
Mono<String> policyTypeResp = Mono.just(POLICY_TYPE_SCHEMA_VALID);
}
@Test
+ @DisplayName("test Put Policy")
void testPutPolicy() {
when(asyncRestClientMock.put(anyString(), anyString())).thenReturn(Mono.empty());
}
@Test
+ @DisplayName("test Delete Policy")
void testDeletePolicy() {
when(asyncRestClientMock.delete(anyString())).thenReturn(Mono.empty());
}
@Test
+ @DisplayName("test Delete All Policies")
void testDeleteAllPolicies() {
Mono<String> policyTypeIdsResp = Mono.just(Arrays.asList(POLICY_TYPE_1_ID, POLICY_TYPE_2_ID).toString());
Mono<String> policyIdsType1Resp = Mono.just(Arrays.asList(POLICY_1_ID).toString());
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
}
@Test
+ @DisplayName("test Get Policy Type Identities")
void testGetPolicyTypeIdentities() {
List<String> policyTypeIds = clientUnderTest.getPolicyTypeIdentities().block();
assertEquals(1, policyTypeIds.size(), "should hardcoded to one");
}
@Test
+ @DisplayName("test Get Policy Identities")
void testGetPolicyIdentities() {
doReturn(RIC_URL).when(ricConfigMock).getBaseUrl();
Mono<String> policyIds = Mono.just(Arrays.asList(POLICY_1_ID, POLICY_2_ID).toString());
}
@Test
+ @DisplayName("test Get Valid Policy Type")
void testGetValidPolicyType() {
String policyType = clientUnderTest.getPolicyTypeSchema(POLICY_TYPE_1_NAME).block();
assertEquals("{}", policyType, "");
}
@Test
+ @DisplayName("test Put Policy Valid Response")
void testPutPolicyValidResponse() {
doReturn(RIC_URL).when(ricConfigMock).getBaseUrl();
when(asyncRestClientMock.put(anyString(), anyString())).thenReturn(Mono.just(POLICY_JSON));
}
@Test
+ @DisplayName("test Delete Policy")
void testDeletePolicy() {
doReturn(RIC_URL).when(ricConfigMock).getBaseUrl();
final String url = policiesBaseUrl() + POLICY_1_ID;
}
@Test
+ @DisplayName("test Delete All Policies")
void testDeleteAllPolicies() {
doReturn(RIC_URL).when(ricConfigMock).getBaseUrl();
Mono<String> policyIds = Mono.just(Arrays.asList(POLICY_1_ID, POLICY_2_ID).toString());
import org.json.JSONException;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
}
@Test
+ @DisplayName("test Get Policy Type Identities")
void testGetPolicyTypeIdentities() {
List<String> policyTypeIds = Arrays.asList(POLICY_TYPE_1_ID, POLICY_TYPE_2_ID);
Mono<String> policyTypeIdsResp = Mono.just(policyTypeIds.toString());
}
@Test
+ @DisplayName("test Get Policy Identities")
void testGetPolicyIdentities() {
Mono<String> policyTypeIdsResp = Mono.just(Arrays.asList(POLICY_TYPE_1_ID, POLICY_TYPE_2_ID).toString());
Mono<String> policyIdsType1Resp = Mono.just(Arrays.asList(POLICY_1_ID).toString());
}
@Test
+ @DisplayName("test Get Valid Policy Type")
void testGetValidPolicyType() {
String policyType = "{\"policySchema\": " + POLICY_TYPE_SCHEMA_VALID + "}";
Mono<String> policyTypeResp = Mono.just(policyType);
}
@Test
+ @DisplayName("test Get In Valid PolicyType Json")
void testGetInValidPolicyTypeJson() {
String policyType = "{\"policySchema\": " + POLICY_TYPE_SCHEMA_INVALID + "}";
Mono<String> policyTypeResp = Mono.just(policyType);
}
@Test
+ @DisplayName("test Get Policy Type Without Create Schema")
void testGetPolicyTypeWithoutCreateSchema() {
Mono<String> policyTypeResp = Mono.just(POLICY_TYPE_SCHEMA_VALID);
}
@Test
+ @DisplayName("test Put Policy")
void testPutPolicy() {
when(asyncRestClientMock.put(anyString(), anyString())).thenReturn(Mono.empty());
}
@Test
+ @DisplayName("test Delete Policy")
void testDeletePolicy() {
when(asyncRestClientMock.delete(anyString())).thenReturn(Mono.empty());
}
@Test
+ @DisplayName("test Delete All Policies")
void testDeleteAllPolicies() {
Mono<String> policyTypeIdsResp = Mono.just(Arrays.asList(POLICY_TYPE_1_ID, POLICY_TYPE_2_ID).toString());
Mono<String> policyIdsType1Resp = Mono.just(Arrays.asList(POLICY_1_ID).toString());
import java.nio.charset.StandardCharsets;
import java.util.Map;
+import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException;
ApplicationConfigParser parserUnderTest = new ApplicationConfigParser(applicationConfigMock);
@Test
+ @DisplayName("test when Correct Config")
void whenCorrectConfig() throws Exception {
JsonObject jsonRootObject = getJsonRootObject();
}
@Test
+ @DisplayName("test when Dmaap Config Has Several Streams Publishing")
void whenDmaapConfigHasSeveralStreamsPublishing() throws Exception {
JsonObject jsonRootObject = getJsonRootObject();
JsonObject json = jsonRootObject.getAsJsonObject("config").getAsJsonObject("streams_publishes");
}
@Test
+ @DisplayName("test when Dmaap Config Has Several Streams Subscribing")
void whenDmaapConfigHasSeveralStreamsSubscribing() throws Exception {
JsonObject jsonRootObject = getJsonRootObject();
JsonObject json = jsonRootObject.getAsJsonObject("config").getAsJsonObject("streams_subscribes");
}
@Test
+ @DisplayName("test when Wrong Member Name In Object")
void whenWrongMemberNameInObject() throws Exception {
JsonObject jsonRootObject = getJsonRootObject();
JsonObject json = jsonRootObject.getAsJsonObject("config");
}
@Test
+ @DisplayName("test schema Validation Error")
void schemaValidationError() throws Exception {
when(applicationConfigMock.getConfigurationFileSchemaPath())
.thenReturn("application_configuration_schema.json");
import java.util.HashMap;
import java.util.List;
+import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
}
@Test
+ @DisplayName("test add Rics")
void addRics() throws Exception {
ApplicationConfig appConfigUnderTest = new ApplicationConfig();
}
@Test
+ @DisplayName("test changed Ric")
void changedRic() throws Exception {
ApplicationConfig appConfigUnderTest = new ApplicationConfig();
}
@Test
+ @DisplayName("test removed Ric")
void removedRic() {
ApplicationConfig appConfigUnderTest = new ApplicationConfig();
import java.nio.file.Files;
import java.util.Optional;
+import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.io.TempDir;
public File temporaryFolder;
@Test
+ @DisplayName("test write File With Error should Throw Exception")
void writeFileWithError_shouldThrowException() throws Exception {
File tempJsonFile = new File(temporaryFolder, "config.json");
String filePath = tempJsonFile.getAbsolutePath();
}
@Test
+ @DisplayName("test write And Read File should Be Ok")
void writeAndReadFile_shouldBeOk() throws Exception {
File tempJsonFile = new File(temporaryFolder, "config.json");
String filePath = tempJsonFile.getAbsolutePath();
}
@Test
+ @DisplayName("test read When File Missing should Return Empty")
void readWhenFileMissing_shouldReturnEmpty() {
ConfigurationFile configFileUnderTest = new ConfigurationFile(applicationConfigMock);
}
@Test
+ @DisplayName("test read When File With Io Error should Return Empty And Log Error")
void readWhenFileWithIoError_shouldReturnEmptyAndLogError() throws Exception {
File tempJsonFile = new File(temporaryFolder, "config.json");
String filePath = tempJsonFile.getAbsolutePath();
import java.util.Vector;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
}
@Test
+ @DisplayName("test Counters when Neither Changed Policies Nor Policy Types")
void testCounters_whenNeitherChangedPoliciesNorPolicyTypes() {
RIC_1.setState(Ric.RicState.AVAILABLE);
RIC_1.addSupportedPolicyType(POLICY_TYPE_1);
}
@Test
+ @DisplayName("test Counters when Changed Policies And No Changed Policy Types")
void testCounters_whenChangedPoliciesAndNoChangedPolicyTypes() {
RIC_1.setState(Ric.RicState.AVAILABLE);
RIC_1.addSupportedPolicyType(POLICY_TYPE_1);
}
@Test
+ @DisplayName("test Counters when No Changed Policies And Changed Policy Types")
void testCounters_whenNoChangedPoliciesAndChangedPolicyTypes() {
RIC_1.setState(Ric.RicState.AVAILABLE);
import org.json.JSONObject;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
@Test
@SuppressWarnings("squid:S2925") // "Thread.sleep" should not be used in tests.
+ @DisplayName("test ZZ Actuator")
void testZZActuator() throws Exception {
// The test must be run last, hence the "ZZ" in the name. All succeeding tests
// will fail.
}
@Test
+ @DisplayName("test generate Api Doc")
void generateApiDoc() throws Exception {
String url = "https://localhost:" + this.port + "/v3/api-docs";
ResponseEntity<String> resp = restClient("", false).getForEntity(url).block();
}
@Test
+ @DisplayName("test Persistency Policies")
void testPersistencyPolicies() throws Exception {
Ric ric = this.addRic("ric1");
PolicyType type = this.addPolicyType("type1", ric.id());
}
@Test
+ @DisplayName("test Persistency Policy Types")
void testPersistencyPolicyTypes() throws Exception {
Ric ric = this.addRic("ric1");
this.addPolicyType("type1", ric.id());
}
@Test
+ @DisplayName("test Persistency Service")
void testPersistencyService() throws Exception {
final String SERVICE = "serviceName";
putService(SERVICE, 1234, HttpStatus.CREATED);
}
@Test
+ @DisplayName("test Adding Ric From Configuration")
void testAddingRicFromConfiguration() throws Exception {
// Test adding the RIC from configuration
}
@Test
+ @DisplayName("test Adding Ric From Configuration non Responding Ric")
void testAddingRicFromConfiguration_nonRespondingRic() throws Exception {
putService("service");
}
@Test
+ @DisplayName("test Trust Validation")
void testTrustValidation() {
addRic("ric1");
}
@Test
+ @DisplayName("test Get Rics")
void testGetRics() throws Exception {
addRic("ric1");
this.addPolicyType("type1", "ric1");
}
@Test
+ @DisplayName("test Synchronization")
void testSynchronization() throws Exception {
// Two polictypes will be put in the NearRT RICs
PolicyTypes nearRtRicPolicyTypes = new PolicyTypes(this.applicationConfig);
}
@Test
+ @DisplayName("test Get Ric")
void testGetRic() throws Exception {
String ricId = "ric1";
String managedElementId = "kista_1";
}
@Test
+ @DisplayName("test Put Policy")
void testPutPolicy() throws Exception {
String serviceName = "service.1";
String ricId = "ric.1";
}
@Test
+ @DisplayName("test Put Policy No Service No Status Uri")
void testPutPolicy_NoServiceNoStatusUri() throws Exception {
String ricId = "ric.1";
String policyTypeName = "type1_1.2.3";
*
* @throws ServiceException
*/
+ @DisplayName("test Error From Ric")
void testErrorFromRic() throws ServiceException {
putService("service1");
addPolicyType("type1", "ric1");
}
@Test
+ @DisplayName("test Put Typeless Policy")
void testPutTypelessPolicy() throws Exception {
putService("service1");
addPolicyType("", "ric1");
}
@Test
+ @DisplayName("test Update Service")
void testUpdateService() throws Exception {
this.addRic("ric1");
this.addPolicy("p", "type1", "", "ric1");
}
@Test
+ @DisplayName("test Refuse To Update Policy")
void testRefuseToUpdatePolicy() throws Exception {
// Test that only the json can be changed for a already created policy
// In this case service is attempted to be changed
}
@Test
+ @DisplayName("test Get Policy")
void testGetPolicy() throws Exception {
String url = "/policies/id";
Policy policy = addPolicy("id", "typeName", "service1", "ric1");
}
@Test
+ @DisplayName("test Delete Policy")
void testDeletePolicy() throws Exception {
String policyId = "id.1";
addPolicy(policyId, "typeName", "service1", "ric1");
}
@Test
+ @DisplayName("test Get Policy Type")
void testGetPolicyType() throws Exception {
String typeId = "AC.D";
addPolicyType(typeId, "ric1");
}
@Test
+ @DisplayName("test Get Policy Types")
void testGetPolicyTypes() throws Exception {
String TYPE_ID_1 = "A_type1_1.9.0";
String TYPE_ID_2 = "A_type1_2.0.0";
}
@Test
+ @DisplayName("test Get Policy Instances")
void testGetPolicyInstances() throws Exception {
addPolicy("id1", "type1", "service1");
}
@Test
+ @DisplayName("test Get Policy Instances Filter")
void testGetPolicyInstancesFilter() throws Exception {
addPolicy("id1", "type1", "service1");
addPolicy("id2", "type1", "service2");
}
@Test
+ @DisplayName("test Get Policy Ids Filter")
void testGetPolicyIdsFilter() throws Exception {
addPolicy("id1", "type1", "service1", "ric1");
addPolicy("id2", "type1", "service2", "ric1");
}
@Test
+ @DisplayName("test Put And Get Service")
void testPutAndGetService() throws Exception {
// PUT
String serviceName = "ac.dc";
}
@Test
+ @DisplayName("test Service Supervision")
void testServiceSupervision() throws Exception {
putService("service1", 1, HttpStatus.CREATED);
addPolicyType("type1", "ric1");
}
@Test
+ @DisplayName("test Get Policy Status")
void testGetPolicyStatus() throws Exception {
addPolicy("id", "typeName", "service1", "ric1");
assertThat(policies.size()).isEqualTo(1);
}
@Test
+ @DisplayName("test Get Service Status")
void testGetServiceStatus() throws Exception {
String url = "/status";
String rsp = restClient().get(url).block();
}
@Test
+ @DisplayName("test Service Notification")
void testServiceNotification() throws Exception {
final String AUTH_TOKEN = "testToken";
}
@Test
+ @DisplayName("test Concurrency")
void testConcurrency() throws Exception {
logger.info("Concurrency test starting");
final Instant startTime = Instant.now();
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.AsyncRestClient;
private int port;
@Test
+ @DisplayName("put Valid Configuration With New Ric should Update Repository")
void putValidConfigurationWithNewRic_shouldUpdateRepository() throws Exception {
String url = "a1-policy/v2/configuration";
}
@Test
+ @DisplayName("get No File Exists")
void getNoFileExists() {
String url = "a1-policy/v2/configuration";
testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND, "File does not exist");
}
@Test
+ @DisplayName("put Invalid Configuration should Return Error 400")
void putInvalidConfiguration_shouldReturnError400() throws Exception {
String url = "a1-policy/v2/configuration";
import org.junit.Assert;
import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
}
@Test
+ @DisplayName("successful Case dmaap Not Configured then Sleep And Retry Until Config")
void successfulCase_dmaapNotConfigured_thenSleepAndRetryUntilConfig() throws Exception {
messageConsumerUnderTest = spy(new DmaapMessageConsumer(applicationConfigMock, new SecurityContext("")));
}
@Test
+ @DisplayName("return Error From Dmapp then Sleep And Retry")
void returnErrorFromDmapp_thenSleepAndRetry() throws Exception {
messageConsumerUnderTest = spy(new DmaapMessageConsumer(applicationConfigMock, new SecurityContext("")));
}
@Test
+ @DisplayName("unParsable Message then Send Response And Continue")
void unParsableMessage_thenSendResponseAndContinue() throws Exception {
messageConsumerUnderTest = spy(new DmaapMessageConsumer(applicationConfigMock, new SecurityContext("")));
setTaskNumberOfLoops(2);
}
@Test
+ @DisplayName("test Message Parsing")
void testMessageParsing() throws ServiceException {
messageConsumerUnderTest = new DmaapMessageConsumer(applicationConfigMock, new SecurityContext(""));
String json = gson.toJson(dmaapRequestMessage());
import java.nio.charset.Charset;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.AsyncRestClient;
}
@Test
+ @DisplayName("test successful Delete")
void successfulDelete() throws IOException {
doReturn(okResponse()).when(pmsClient).deleteForEntity(anyString());
doReturn(Mono.just("OK")).when(dmaapClient).post(anyString(), anyString());
}
@Test
+ @DisplayName("test successful Get")
void successfulGet() throws IOException {
doReturn(okResponse()).when(pmsClient).getForEntity(anyString());
doReturn(Mono.just("OK")).when(dmaapClient).post(anyString(), anyString());
}
@Test
+ @DisplayName("test exception From Pms When Get then Post Error")
void exceptionFromPmsWhenGet_thenPostError() throws IOException {
String errorBody = "Unavailable";
WebClientResponseException webClientResponseException = new WebClientResponseException(
}
@Test
+ @DisplayName("test successful Put")
void successfulPut() throws IOException {
doReturn(okResponse()).when(pmsClient).putForEntity(anyString(), anyString());
doReturn(Mono.just("OK")).when(dmaapClient).post(anyString(), anyString());
}
@Test
+ @DisplayName("test successful Post")
void successfulPost() throws IOException {
doReturn(okResponse()).when(pmsClient).postForEntity(anyString(), anyString());
doReturn(Mono.just("OK")).when(dmaapClient).post(anyString(), anyString());
}
@Test
+ @DisplayName("test exception When Calling Pms then Error Response")
void exceptionWhenCallingPms_thenErrorResponse() throws IOException {
doReturn(notOkResponse()).when(pmsClient).putForEntity(anyString(), anyString());
}
@Test
+ @DisplayName("test put Without Payload then Not Found Response With Warning")
void putWithoutPayload_thenNotFoundResponseWithWarning() throws Exception {
DmaapRequestMessage message = DmaapRequestMessage.builder() //
.apiVersion("apiVersion") //
import java.io.IOException;
import java.lang.invoke.MethodHandles;
+import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
}
@Test
+ @DisplayName("test Lock")
void testLock() throws IOException, ServiceException {
Lock lock = new Lock("l1");
Lock.Grant grant = lock.lockBlocking(LockType.SHARED, "test");
}
@Test
+ @DisplayName("test Reactive Lock")
void testReactiveLock() {
Lock lock = new Lock("l1");
import java.util.Properties;
import java.util.Vector;
+import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
}
@Test
+ @DisplayName("test when The Configuration Fits then Configured Rics Are Put In Repository")
void whenTheConfigurationFits_thenConfiguredRicsArePutInRepository() throws Exception {
refreshTaskUnderTest = this.createTestObject(true);
refreshTaskUnderTest.systemEnvironment = new Properties();
}
@Test
+ @DisplayName("test when File Exists But Json Is Incorrect then No Rics Are Put In Repository")
void whenFileExistsButJsonIsIncorrect_thenNoRicsArePutInRepository() throws Exception {
refreshTaskUnderTest = this.createTestObject(true);
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
}
@Test
+ @DisplayName("test when Ric Idle And No Changed Policies Or PolicyTypes then No Synchronization")
void whenRicIdleAndNoChangedPoliciesOrPolicyTypes_thenNoSynchronization() {
doReturn(Mono.just(a1ClientMock)).when(a1ClientFactory).createA1Client(any(Ric.class));
RIC_1.setState(RicState.AVAILABLE);
}
@Test
+ @DisplayName("test when Ric Undefined then Synchronization")
void whenRicUndefined_thenSynchronization() {
doReturn(Mono.just(a1ClientMock)).when(a1ClientFactory).createA1Client(any(Ric.class));
RIC_1.setState(RicState.UNAVAILABLE);
}
@Test
+ @DisplayName("test when Ric Synchronizing then No Synchronization")
void whenRicSynchronizing_thenNoSynchronization() {
doReturn(Mono.just(a1ClientMock)).when(a1ClientFactory).createA1Client(any(Ric.class));
RIC_1.setState(RicState.SYNCHRONIZING);
}
@Test
+ @DisplayName("test when Ric Idle And Error Getting Policy Identities then No Synchronization")
void whenRicIdleAndErrorGettingPolicyIdentities_thenNoSynchronization() {
doReturn(Mono.just(a1ClientMock)).when(a1ClientFactory).createA1Client(any(Ric.class));
RIC_1.setState(RicState.AVAILABLE);
}
@Test
+ @DisplayName("test when Ric Idle And Not Same Amount Of Policies then Synchronization")
void whenRicIdleAndNotSameAmountOfPolicies_thenSynchronization() {
doReturn(Mono.just(a1ClientMock)).when(a1ClientFactory).createA1Client(any(Ric.class));
RIC_1.setState(RicState.AVAILABLE);
}
@Test
+ @DisplayName("test when Ric Idle And Same Amount Of Policies But Not Same Policies then Synchronization")
void whenRicIdleAndSameAmountOfPoliciesButNotSamePolicies_thenSynchronization() {
doReturn(Mono.just(a1ClientMock)).when(a1ClientFactory).createA1Client(any(Ric.class));
RIC_1.setState(RicState.AVAILABLE);
}
@Test
+ @DisplayName("test when Ric Idle And Error Getting Policy Types then No Synchronization")
void whenRicIdleAndErrorGettingPolicyTypes_thenNoSynchronization() {
doReturn(Mono.just(a1ClientMock)).when(a1ClientFactory).createA1Client(any(Ric.class));
RIC_1.setState(RicState.AVAILABLE);
}
@Test
+ @DisplayName("test when Ric Idle And Not Same Amount Of PolicyTypes then Synchronization")
void whenRicIdleAndNotSameAmountOfPolicyTypes_thenSynchronization() {
doReturn(Mono.just(a1ClientMock)).when(a1ClientFactory).createA1Client(any(Ric.class));
RIC_1.setState(RicState.AVAILABLE);
}
@Test
+ @DisplayName("test when Ric Idle And Same Amount Of Policy Types But Not Same Types then Synchronization")
void whenRicIdleAndSameAmountOfPolicyTypesButNotSameTypes_thenSynchronization() {
doReturn(Mono.just(a1ClientMock)).when(a1ClientFactory).createA1Client(any(Ric.class));
PolicyType policyType2 = PolicyType.builder() //
import java.util.Collections;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
};
@Test
+ @DisplayName("test ric Idle And Error Deleting Policies then Synchronization With Failed Recovery")
void ricIdleAndErrorDeletingPoliciesAllTheTime_thenSynchronizationWithFailedRecovery() {
setUpCreationOfA1Client();
simulateRicWithNoPolicyTypes();
}
@Test
+ @DisplayName("test Connection Error")
void testConnectionError() {
setUpCreationOfA1Client();
simulateRicWithNoPolicyTypes();
}
@Test
+ @DisplayName("test ric Idle then Synchronization With Reuse Of Type From Repo And Correct Service Notified")
void ricIdlePolicyTypeInRepo_thenSynchronizationWithReuseOfTypeFromRepoAndCorrectServiceNotified() {
rics.put(ric1);
ric1.setState(RicState.AVAILABLE);
}
@Test
+ @DisplayName("test ric Idle then Synchronization With Type From Ric")
void ricIdlePolicyTypeNotInRepo_thenSynchronizationWithTypeFromRic() throws Exception {
ric1.setState(RicState.AVAILABLE);
rics.put(ric1);
}
@Test
+ @DisplayName("test ric Idle then Synchronization With Recreation Of Policies")
void ricIdleAndHavePolicies_thenSynchronizationWithRecreationOfPolicies() {
ric1.setState(RicState.AVAILABLE);
rics.put(ric1);
import java.time.Instant;
import org.awaitility.Durations;
+import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
.build();
@Test
+ @DisplayName("test service Expired policy And Service Are Deleted In Repo And Policy Is Deleted In Ric")
void serviceExpired_policyAndServiceAreDeletedInRepoAndPolicyIsDeletedInRic() {
setUpRepositoryWithKeepAliveInterval(Duration.ofSeconds(2));
}
@Test
+ @DisplayName("test service Expired But Delete In Ric Fails policy And Service Are Deleted In Repo And Error Logged For Ric")
void serviceExpiredButDeleteInRicFails_policyAndServiceAreDeletedInRepoAndErrorLoggedForRic() {
setUpRepositoryWithKeepAliveInterval(Duration.ofSeconds(2));
}
@Test
+ @DisplayName("test service Not Expired should Not Be Checked")
void serviceNotExpired_shouldNotBeChecked() {
setUpRepositoryWithKeepAliveInterval(Duration.ofSeconds(2));
}
@Test
+ @DisplayName("test service Without Keep Alive Interval should Not Be Checked")
void serviceWithoutKeepAliveInterval_shouldNotBeChecked() {
setUpRepositoryWithKeepAliveInterval(Duration.ofSeconds(0));