X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-backend%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fric%2Fportal%2Fdashboard%2Fconfig%2FE2ManagerMockConfiguration.java;h=4561dd7e36c80117e762d7bb28e4bf408d73c249;hb=fa50e55b6e8977ad0a6a28096fe58fb54924ca2b;hp=d6ff9b8e48c4b0c3ddea3d88e6754523ae9f8d52;hpb=5c87567c1743fb3f6957fe8fe0906310212cd1d6;p=portal%2Fric-dashboard.git diff --git a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/E2ManagerMockConfiguration.java b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/E2ManagerMockConfiguration.java index d6ff9b8e..4561dd7e 100644 --- a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/E2ManagerMockConfiguration.java +++ b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/E2ManagerMockConfiguration.java @@ -25,10 +25,15 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.lang.invoke.MethodHandles; +import java.util.ArrayList; +import java.util.List; import org.oransc.ric.e2mgr.client.api.HealthCheckApi; import org.oransc.ric.e2mgr.client.api.NodebApi; import org.oransc.ric.e2mgr.client.invoker.ApiClient; +import org.oransc.ric.e2mgr.client.model.GetNodebResponse; +import org.oransc.ric.e2mgr.client.model.NodebIdentity; +import org.oransc.ric.e2mgr.client.model.NodebIdentityGlobalNbId; import org.oransc.ric.e2mgr.client.model.SetupRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,8 +43,7 @@ import org.springframework.context.annotation.Profile; import org.springframework.http.HttpStatus; /** - * Creates a mock implementation of the E2 manager client API. This version - * answers only status codes, no data, so the mock implementations are trivial. + * Creates a mock implementation of the E2 Manager client API. */ @Profile("mock") @Configuration @@ -47,8 +51,19 @@ public class E2ManagerMockConfiguration { private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + private final List 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"); + NodebIdentityGlobalNbId globalNbId = new NodebIdentityGlobalNbId().nbId("mockNbId").plmnId("mockPlmId"); + NodebIdentity nbid = new NodebIdentity().inventoryName("mockInvName").globalNbId(globalNbId); + nodebIdList = new ArrayList<>(); + nodebIdList.add(nbid); + nodebResponse = new GetNodebResponse().connectionStatus("mockConnectionStatus").failureType("mockFailureType") + .ip("127.0.0.1").nodeType("mockNodeType").port(123).ranName("mockRanName"); } private ApiClient apiClient() { @@ -58,32 +73,46 @@ public class E2ManagerMockConfiguration { } @Bean - public HealthCheckApi e2HealthCheckApi() { + // Use the same name as regular configuration + public HealthCheckApi e2MgrHealthCheckApi() { 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; } @Bean - public NodebApi e2NodebApi() { + // Use the same name as regular configuration + public NodebApi e2MgrNodebApi() { 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(inv -> { + logger.debug("getNb sleeping {}", delayMs); + Thread.sleep(delayMs); + return nodebResponse; + }).when(mockApi).getNb(any(String.class)); + doAnswer(inv -> { + logger.debug("getNodebIdList sleeping {}", delayMs); + Thread.sleep(delayMs); + return nodebIdList; + }).when(mockApi).getNodebIdList(); + 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; }