Add configurable delay to mock endpoints
[portal/ric-dashboard.git] / webapp-backend / src / main / java / org / oransc / ric / portal / dashboard / config / E2ManagerMockConfiguration.java
index ddec4ae..4561dd7 100644 (file)
@@ -53,6 +53,8 @@ public class E2ManagerMockConfiguration {
 
        private final List<NodebIdentity> nodebIdList;
        private final GetNodebResponse nodebResponse;
+       // Simulate remote method delay for UI testing
+       private final int delayMs = 500;
 
        public E2ManagerMockConfiguration() {
                logger.info("Configuring mock E2 Manager");
@@ -61,7 +63,7 @@ public class E2ManagerMockConfiguration {
                nodebIdList = new ArrayList<>();
                nodebIdList.add(nbid);
                nodebResponse = new GetNodebResponse().connectionStatus("mockConnectionStatus").failureType("mockFailureType")
-                               .ip("1.2.3.4").nodeType("mockNodeType").port(123).ranName("mockRanName");
+                               .ip("127.0.0.1").nodeType("mockNodeType").port(123).ranName("mockRanName");
        }
 
        private ApiClient apiClient() {
@@ -76,11 +78,7 @@ public class E2ManagerMockConfiguration {
                ApiClient apiClient = apiClient();
                HealthCheckApi mockApi = mock(HealthCheckApi.class);
                when(mockApi.getApiClient()).thenReturn(apiClient);
-
-               doAnswer(i -> {
-                       return null;
-               }).when(mockApi).healthGet();
-
+               doAnswer(i -> null).when(mockApi).healthGet();
                return mockApi;
        }
 
@@ -90,27 +88,31 @@ public class E2ManagerMockConfiguration {
                ApiClient apiClient = apiClient();
                NodebApi mockApi = mock(NodebApi.class);
                when(mockApi.getApiClient()).thenReturn(apiClient);
-
-               doAnswer(i -> {
+               doAnswer(inv -> {
+                       logger.debug("nodebDelete sleeping {}", delayMs);
+                       Thread.sleep(delayMs);
                        return null;
                }).when(mockApi).nodebDelete();
-
-               doAnswer(i -> {
+               doAnswer(inv -> {
+                       logger.debug("getNb sleeping {}", delayMs);
+                       Thread.sleep(delayMs);
                        return nodebResponse;
                }).when(mockApi).getNb(any(String.class));
-
-               doAnswer(i -> {
+               doAnswer(inv -> {
+                       logger.debug("getNodebIdList sleeping {}", delayMs);
+                       Thread.sleep(delayMs);
                        return nodebIdList;
                }).when(mockApi).getNodebIdList();
-
-               doAnswer(i -> {
+               doAnswer(inv -> {
+                       logger.debug("endcSetup sleeping {}", delayMs);
+                       Thread.sleep(delayMs);
                        return null;
                }).when(mockApi).endcSetup(any(SetupRequest.class));
-
-               doAnswer(i -> {
+               doAnswer(inv -> {
+                       logger.debug("x2Setup sleeping {}", delayMs);
+                       Thread.sleep(delayMs);
                        return null;
                }).when(mockApi).x2Setup(any(SetupRequest.class));
-
                return mockApi;
        }