Code Review
/
nonrtric.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "Added RIC state to RicInfo in the agent NBI"
[nonrtric.git]
/
policy-agent
/
src
/
test
/
java
/
org
/
oransc
/
policyagent
/
clients
/
SdncOscA1ClientTest.java
diff --git
a/policy-agent/src/test/java/org/oransc/policyagent/clients/SdncOscA1ClientTest.java
b/policy-agent/src/test/java/org/oransc/policyagent/clients/SdncOscA1ClientTest.java
index
e463cae
..
18ef097
100644
(file)
--- a/
policy-agent/src/test/java/org/oransc/policyagent/clients/SdncOscA1ClientTest.java
+++ b/
policy-agent/src/test/java/org/oransc/policyagent/clients/SdncOscA1ClientTest.java
@@
-39,6
+39,8
@@
import org.mockito.stubbing.OngoingStubbing;
import org.oransc.policyagent.clients.A1Client.A1ProtocolType;
import org.oransc.policyagent.clients.SdncOscA1Client.AdapterRequest;
import org.oransc.policyagent.clients.SdncOscA1Client.AdapterResponse;
import org.oransc.policyagent.clients.A1Client.A1ProtocolType;
import org.oransc.policyagent.clients.SdncOscA1Client.AdapterRequest;
import org.oransc.policyagent.clients.SdncOscA1Client.AdapterResponse;
+import org.oransc.policyagent.configuration.ControllerConfig;
+import org.oransc.policyagent.configuration.ImmutableControllerConfig;
import org.oransc.policyagent.repository.Policy;
import org.oransc.policyagent.repository.Ric;
import org.springframework.web.reactive.function.client.WebClientResponseException;
import org.oransc.policyagent.repository.Policy;
import org.oransc.policyagent.repository.Ric;
import org.springframework.web.reactive.function.client.WebClientResponseException;
@@
-64,12
+66,22
@@
public class SdncOscA1ClientTest {
AsyncRestClient asyncRestClientMock;
AsyncRestClient asyncRestClientMock;
+ private ControllerConfig controllerConfig() {
+ return ImmutableControllerConfig.builder() //
+ .name("name") //
+ .baseUrl("baseUrl") //
+ .password(CONTROLLER_PASSWORD) //
+ .userName(CONTROLLER_USERNAME) //
+ .build();
+ }
+
@BeforeEach
public void init() {
asyncRestClientMock = mock(AsyncRestClient.class);
Ric ric = A1ClientHelper.createRic(RIC_1_URL);
@BeforeEach
public void init() {
asyncRestClientMock = mock(AsyncRestClient.class);
Ric ric = A1ClientHelper.createRic(RIC_1_URL);
- clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_STD_V1_1, ric.getConfig(), CONTROLLER_USERNAME,
- CONTROLLER_PASSWORD, asyncRestClientMock);
+
+ clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_STD_V1_1, ric.getConfig(), controllerConfig(),
+ asyncRestClientMock);
}
@Test
}
@Test
@@
-83,7
+95,7
@@
public class SdncOscA1ClientTest {
public void testGetPolicyTypeIdentities_OSC() {
clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_OSC_V1, //
A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
public void testGetPolicyTypeIdentities_OSC() {
clientUnderTest = new SdncOscA1Client(A1ProtocolType.SDNC_OSC_OSC_V1, //
A1ClientHelper.createRic(RIC_1_URL).getConfig(), //
-
CONTROLLER_USERNAME, CONTROLLER_PASSWORD
, asyncRestClientMock);
+
controllerConfig()
, asyncRestClientMock);
String response = createResponse(Arrays.asList(POLICY_TYPE_1_ID));
whenAsyncPostThenReturn(Mono.just(response));
String response = createResponse(Arrays.asList(POLICY_TYPE_1_ID));
whenAsyncPostThenReturn(Mono.just(response));
@@
-96,7
+108,7
@@
public class SdncOscA1ClientTest {
AdapterRequest expectedParams = ImmutableAdapterRequest.builder() //
.nearRtRicUrl(expUrl) //
.build();
AdapterRequest expectedParams = ImmutableAdapterRequest.builder() //
.nearRtRicUrl(expUrl) //
.build();
- String expInput =
A1Client
Helper.createInputJsonString(expectedParams);
+ String expInput =
SdncJson
Helper.createInputJsonString(expectedParams);
verify(asyncRestClientMock).postWithAuthHeader(GET_A1_POLICY_URL, expInput, CONTROLLER_USERNAME,
CONTROLLER_PASSWORD);
verify(asyncRestClientMock).postWithAuthHeader(GET_A1_POLICY_URL, expInput, CONTROLLER_USERNAME,
CONTROLLER_PASSWORD);
@@
-131,7
+143,7
@@
public class SdncOscA1ClientTest {
AdapterRequest expectedParams = ImmutableAdapterRequest.builder() //
.nearRtRicUrl(policiesUrl()) //
.build();
AdapterRequest expectedParams = ImmutableAdapterRequest.builder() //
.nearRtRicUrl(policiesUrl()) //
.build();
- String expInput =
A1Client
Helper.createInputJsonString(expectedParams);
+ String expInput =
SdncJson
Helper.createInputJsonString(expectedParams);
verify(asyncRestClientMock).postWithAuthHeader(GET_A1_POLICY_URL, expInput, CONTROLLER_USERNAME,
CONTROLLER_PASSWORD);
verify(asyncRestClientMock).postWithAuthHeader(GET_A1_POLICY_URL, expInput, CONTROLLER_USERNAME,
CONTROLLER_PASSWORD);
@@
-156,7
+168,7
@@
public class SdncOscA1ClientTest {
.nearRtRicUrl(expUrl) //
.body(POLICY_JSON_VALID) //
.build();
.nearRtRicUrl(expUrl) //
.body(POLICY_JSON_VALID) //
.build();
- String expInput =
A1Client
Helper.createInputJsonString(expectedInputParams);
+ String expInput =
SdncJson
Helper.createInputJsonString(expectedInputParams);
verify(asyncRestClientMock).postWithAuthHeader(PUT_A1_URL, expInput, CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
}
verify(asyncRestClientMock).postWithAuthHeader(PUT_A1_URL, expInput, CONTROLLER_USERNAME, CONTROLLER_PASSWORD);
}
@@
-180,7
+192,7
@@
public class SdncOscA1ClientTest {
.nearRtRicUrl(expUrl) //
.body(policyJson) //
.build();
.nearRtRicUrl(expUrl) //
.body(policyJson) //
.build();
- String expRequest =
A1Client
Helper.createInputJsonString(expRequestParams);
+ String expRequest =
SdncJson
Helper.createInputJsonString(expRequestParams);
verify(asyncRestClientMock).postWithAuthHeader(PUT_A1_URL, expRequest, CONTROLLER_USERNAME,
CONTROLLER_PASSWORD);
StepVerifier.create(returnedMono)
verify(asyncRestClientMock).postWithAuthHeader(PUT_A1_URL, expRequest, CONTROLLER_USERNAME,
CONTROLLER_PASSWORD);
StepVerifier.create(returnedMono)
@@
-199,7
+211,7
@@
public class SdncOscA1ClientTest {
AdapterRequest expectedInputParams = ImmutableAdapterRequest.builder() //
.nearRtRicUrl(expUrl) //
.build();
AdapterRequest expectedInputParams = ImmutableAdapterRequest.builder() //
.nearRtRicUrl(expUrl) //
.build();
- String expInput =
A1Client
Helper.createInputJsonString(expectedInputParams);
+ String expInput =
SdncJson
Helper.createInputJsonString(expectedInputParams);
verify(asyncRestClientMock).postWithAuthHeader(DELETE_A1_URL, expInput, CONTROLLER_USERNAME,
CONTROLLER_PASSWORD);
verify(asyncRestClientMock).postWithAuthHeader(DELETE_A1_URL, expInput, CONTROLLER_USERNAME,
CONTROLLER_PASSWORD);
@@
-213,18
+225,25
@@
public class SdncOscA1ClientTest {
String returnedStatus = clientUnderTest.getPolicyStatus(policy).block();
String returnedStatus = clientUnderTest.getPolicyStatus(policy).block();
- assertEquals("OK", returnedStatus, "unexpeted status");
+ assertEquals("OK", returnedStatus, "unexpe
c
ted status");
final String expUrl = policiesUrl() + "/" + POLICY_1_ID + "/status";
AdapterRequest expectedInputParams = ImmutableAdapterRequest.builder() //
.nearRtRicUrl(expUrl) //
.build();
final String expUrl = policiesUrl() + "/" + POLICY_1_ID + "/status";
AdapterRequest expectedInputParams = ImmutableAdapterRequest.builder() //
.nearRtRicUrl(expUrl) //
.build();
- String expInput =
A1Client
Helper.createInputJsonString(expectedInputParams);
+ String expInput =
SdncJson
Helper.createInputJsonString(expectedInputParams);
verify(asyncRestClientMock).postWithAuthHeader(GET_A1_POLICY_STATUS_URL, expInput, CONTROLLER_USERNAME,
CONTROLLER_PASSWORD);
}
verify(asyncRestClientMock).postWithAuthHeader(GET_A1_POLICY_STATUS_URL, expInput, CONTROLLER_USERNAME,
CONTROLLER_PASSWORD);
}
+ @Test
+ public void testGetVersion() {
+ whenPostReturnOkResponse();
+ A1ProtocolType returnedVersion = clientUnderTest.getProtocolVersion().block();
+ assertEquals(A1ProtocolType.SDNC_OSC_STD_V1_1, returnedVersion, "");
+ }
+
private void whenPostReturnOkResponse() {
AdapterResponse adapterResponse = ImmutableAdapterResponse.builder() //
.body("OK") //
private void whenPostReturnOkResponse() {
AdapterResponse adapterResponse = ImmutableAdapterResponse.builder() //
.body("OK") //