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=334915c8a9148bfbb9dd50f159a234dfada6bb4f;hb=81c5a43871449332f9a9560c7cf25d07cf714d8e;hp=3df6dc70d188b18ce0321b24e9c969b0689a2196;hpb=f660cae7a447b60d84ef75f7c2bcbf62412d4579;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 3df6dc70..334915c8 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 @@ -1,6 +1,6 @@ /*- * ========================LICENSE_START================================= - * ORAN-OSC + * O-RAN-SC * %% * Copyright (C) 2019 AT&T Intellectual Property and Nokia * %% @@ -26,10 +26,10 @@ import static org.mockito.Mockito.when; import java.lang.invoke.MethodHandles; -import org.oransc.ric.e2mgr.client.api.EndcSetupRequestApi; import org.oransc.ric.e2mgr.client.api.HealthCheckApi; -import org.oransc.ric.e2mgr.client.api.X2SetupRequestApi; +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.SetupRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,8 +39,8 @@ import org.springframework.context.annotation.Profile; import org.springframework.http.HttpStatus; /** - * Creates an implementation of the E2 manager client that answers requests with - * mock data. + * Creates a mock implementation of the E2 manager client API. This version + * answers only status codes, no data, so the mock implementations are trivial. */ @Profile("mock") @Configuration @@ -48,8 +48,11 @@ public class E2ManagerMockConfiguration { private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + private final GetNodebResponse nodebResponse; + public E2ManagerMockConfiguration() { logger.info("Configuring mock E2 Manager"); + nodebResponse = new GetNodebResponse().ip("1.2.3.4").port(123).ranName("myRan"); } private ApiClient apiClient() { @@ -59,32 +62,38 @@ public class E2ManagerMockConfiguration { } @Bean - public EndcSetupRequestApi endcSetupRequestApi() { - ApiClient apiClient = apiClient(); - EndcSetupRequestApi mockApi = mock(EndcSetupRequestApi.class); - when(mockApi.getApiClient()).thenReturn(apiClient); - return mockApi; - } - - @Bean - public HealthCheckApi healthCheckApi() { + // 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).healthCheck(); + }).when(mockApi).healthGet(); + return mockApi; } @Bean - public X2SetupRequestApi x2SetupRequestApi() { + // Use the same name as regular configuration + public NodebApi e2MgrNodebApi() { ApiClient apiClient = apiClient(); - X2SetupRequestApi mockApi = mock(X2SetupRequestApi.class); + NodebApi mockApi = mock(NodebApi.class); when(mockApi.getApiClient()).thenReturn(apiClient); + + doAnswer(i -> { + return nodebResponse; + }).when(mockApi).getNb(any(String.class)); + doAnswer(i -> { return null; - }).when(mockApi).setup(any(SetupRequest.class)); + }).when(mockApi).endcSetup(any(SetupRequest.class)); + + doAnswer(i -> { + return null; + }).when(mockApi).x2Setup(any(SetupRequest.class)); + return mockApi; }