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";
}
@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());
}
@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());
}
@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 {
}
@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);