package org.o.ran.oam.nf.oam.adopter.pm.rest.manager;
-import static java.lang.Thread.sleep;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = {VesEventNotifierMock.class, PerformanceManagementMapperConfigProvider.class,
PerformanceManagementFile2VesMapper.class, PerformanceManagementAdaptersDeployer.class})
-public class PerformanceManagementManagerTest {
+class PerformanceManagementManagerTest {
@Autowired
@Qualifier("test")
@Test
@Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
- public void testMapping() throws IOException, InterruptedException, AlreadyPresentException {
+ void testMapping() throws IOException, InterruptedException, AlreadyPresentException {
assertTrue(deployer.getAll().isEmpty());
deployer.create("172.0.10.2", "admin", "admin");
assertFalse(deployer.getAll().isEmpty());
}
@Test
- public void testDelete() throws AlreadyPresentException, NotFoundException {
+ void testDelete() throws AlreadyPresentException, NotFoundException {
assertTrue(deployer.getAll().isEmpty());
deployer.create("172.0.10.2", "admin", "admin");
assertFalse(deployer.getAll().isEmpty());
}
@Test
- public void testAlreadyPresent() throws AlreadyPresentException {
+ void testAlreadyPresent() throws AlreadyPresentException {
assertTrue(deployer.getAll().isEmpty());
deployer.create("172.0.10.2", "admin", "admin");
assertFalse(deployer.getAll().isEmpty());
final Exception alreadyPresentException = assertThrows(AlreadyPresentException.class,
() -> deployer.create("172.0.10.2", "admin", "admin"));
- assertEquals(alreadyPresentException.getMessage(), "Adapter 172.0.10.2 already present.");
+ assertEquals("Adapter 172.0.10.2 already present.", alreadyPresentException.getMessage());
}
@Test
- public void testNotPresent() {
+ void testNotPresent() {
final Exception exception = assertThrows(NotFoundException.class, () -> deployer.delete("172.0.10.2"));
- assertEquals(exception.getMessage(), "Adapter 172.0.10.2 is not present.");
+ assertEquals("Adapter 172.0.10.2 is not present.", exception.getMessage());
}
@Test
- public void testTimeZone() throws AlreadyPresentException {
+ void testTimeZone() throws AlreadyPresentException {
deployer.create("172.0.10.2", "admin", "admin");
assertEquals(deployer.getTimeZone("172.0.10.2"), ZoneId.of("+02:00"));
}
private static List<String> getVesNotification(final VesEventNotifierMock listener, final int expectedSize)
throws InterruptedException {
List<String> events = null;
- for (int i = 0; i < 100000; i++) {
- sleep(1000);
- events = listener.getEvents();
- if (events != null && !events.isEmpty() && events.size() == expectedSize) {
- break;
+ synchronized (listener) {
+ for (int i = 0; i < 100000; i++) {
+ listener.wait(1000);
+ events = listener.getEvents();
+ if (events != null && !events.isEmpty() && events.size() == expectedSize) {
+ break;
+ }
}
}
return events;