Merge "Updated function test env with new tests and features"
[nonrtric.git] / policy-agent / src / test / java / org / oransc / policyagent / clients / A1ClientFactoryTest.java
index 742734e..74cebb0 100644 (file)
@@ -46,7 +46,7 @@ import reactor.core.publisher.Mono;
 import reactor.test.StepVerifier;
 
 @ExtendWith(MockitoExtension.class)
-public class A1ClientFactoryTest {
+class A1ClientFactoryTest {
     private static final String RIC_NAME = "Name";
     private static final String EXCEPTION_MESSAGE = "Error";
 
@@ -78,14 +78,14 @@ public class A1ClientFactoryTest {
     }
 
     @BeforeEach
-    public void createFactoryUnderTest() {
+    void createFactoryUnderTest() {
         factoryUnderTest = spy(new A1ClientFactory(applicationConfigMock));
         this.ric = new Ric(ricConfig(""));
 
     }
 
     @Test
-    public void getProtocolVersion_ok() throws ServiceException {
+    void getProtocolVersion_ok() throws ServiceException {
         whenGetProtocolVersionThrowException(clientMock1);
         whenGetProtocolVersionReturn(clientMock2, A1ProtocolType.STD_V1_1);
         doReturn(clientMock1, clientMock2).when(factoryUnderTest).createClient(any(), any());
@@ -97,7 +97,7 @@ public class A1ClientFactoryTest {
     }
 
     @Test
-    public void getProtocolVersion_ok_Last() throws ServiceException {
+    void getProtocolVersion_ok_Last() throws ServiceException {
         whenGetProtocolVersionThrowException(clientMock1, clientMock2, clientMock3);
         whenGetProtocolVersionReturn(clientMock4, A1ProtocolType.STD_V1_1);
         doReturn(clientMock1, clientMock2, clientMock3, clientMock4).when(factoryUnderTest).createClient(any(), any());
@@ -109,16 +109,16 @@ public class A1ClientFactoryTest {
     }
 
     @Test
-    public void getProtocolVersion_error() throws ServiceException {
+    void getProtocolVersion_error() throws ServiceException {
         whenGetProtocolVersionThrowException(clientMock1, clientMock2, clientMock3, clientMock4);
         doReturn(clientMock1, clientMock2, clientMock3, clientMock4).when(factoryUnderTest).createClient(any(), any());
 
         StepVerifier.create(factoryUnderTest.createA1Client(ric)) //
             .expectSubscription() //
-            .expectErrorMatches(throwable -> throwable.getMessage().equals(EXCEPTION_MESSAGE)) //
+            .expectError() //
             .verify();
 
-        assertEquals(A1ProtocolType.UNKNOWN, ric.getProtocolVersion(), "Not correct protocol");
+        assertEquals(A1ProtocolType.UNKNOWN, ric.getProtocolVersion(), "Protocol negotiation failed for " + ric.name());
     }
 
     private A1Client createClient(A1ProtocolType version) throws ServiceException {
@@ -126,13 +126,13 @@ public class A1ClientFactoryTest {
     }
 
     @Test
-    public void create_check_types() throws ServiceException {
+    void create_check_types() throws ServiceException {
         assertTrue(createClient(A1ProtocolType.STD_V1_1) instanceof StdA1ClientVersion1);
         assertTrue(createClient(A1ProtocolType.OSC_V1) instanceof OscA1Client);
     }
 
     @Test
-    public void create_check_types_controllers() throws ServiceException {
+    void create_check_types_controllers() throws ServiceException {
         this.ric = new Ric(ricConfig("anythingButEmpty"));
         whenGetGetControllerConfigReturn();
         assertTrue(createClient(A1ProtocolType.SDNC_ONAP) instanceof SdncOnapA1Client);