Release oam-ves-adopter Contatiner
[oam/nf-oam-adopter.git] / ves-nf-oam-adopter / ves-nf-oam-adopter-pm-manager / src / test / java / org / o / ran / oam / nf / oam / adopter / pm / rest / manager / PerformanceManagementManagerTest.java
index eb0112e..623f0a7 100644 (file)
@@ -19,7 +19,6 @@
 
 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;
@@ -49,7 +48,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
 @ExtendWith(SpringExtension.class)
 @SpringBootTest(classes = {VesEventNotifierMock.class, PerformanceManagementMapperConfigProvider.class,
     PerformanceManagementFile2VesMapper.class, PerformanceManagementAdaptersDeployer.class})
-public class PerformanceManagementManagerTest {
+class PerformanceManagementManagerTest {
 
     @Autowired
     @Qualifier("test")
@@ -75,7 +74,7 @@ public class PerformanceManagementManagerTest {
 
     @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());
@@ -87,7 +86,7 @@ public class PerformanceManagementManagerTest {
     }
 
     @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());
@@ -97,24 +96,24 @@ public class PerformanceManagementManagerTest {
     }
 
     @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"));
     }
@@ -122,11 +121,13 @@ public class PerformanceManagementManagerTest {
     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;