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=b05d817495c062067bb39260877128b71b02f133;hb=0b44138e09b41a42ee1f87afd39616478911dde5;hp=f5b59d4ee016126c5eef46ef3ae80480505ec5b3;hpb=ace0b71ff6e424193ff6d6519a529d279e7ade58;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 f5b59d4e..b05d8174 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,8 +26,10 @@ import static org.mockito.Mockito.when; import java.lang.invoke.MethodHandles; -import org.oransc.ric.e2mgr.client.api.E2ManagerApi; +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.SetupRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,7 +39,8 @@ import org.springframework.context.annotation.Profile; import org.springframework.http.HttpStatus; /** - * Creates a mock implementation of the E2 manager client API. + * 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 @@ -45,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() { @@ -56,14 +62,27 @@ public class E2ManagerMockConfiguration { } @Bean - public E2ManagerApi e2ManagerApi() { + public HealthCheckApi e2HealthCheckApi() { ApiClient apiClient = apiClient(); - E2ManagerApi mockApi = mock(E2ManagerApi.class); + HealthCheckApi mockApi = mock(HealthCheckApi.class); when(mockApi.getApiClient()).thenReturn(apiClient); doAnswer(i -> { return null; - }).when(mockApi).healthCheck(); + }).when(mockApi).healthGet(); + + return mockApi; + } + + @Bean + public NodebApi e2NodebApi() { + ApiClient apiClient = apiClient(); + NodebApi mockApi = mock(NodebApi.class); + when(mockApi.getApiClient()).thenReturn(apiClient); + + doAnswer(i -> { + return nodebResponse; + }).when(mockApi).getNb(any(String.class)); doAnswer(i -> { return null; @@ -71,7 +90,7 @@ public class E2ManagerMockConfiguration { doAnswer(i -> { return null; - }).when(mockApi).setup(any(SetupRequest.class)); + }).when(mockApi).x2Setup(any(SetupRequest.class)); return mockApi; }