Drop AUX cluster pod list from Platform status
[portal/ric-dashboard.git] / webapp-backend / src / test / java / org / oransc / ric / portal / dashboard / config / CaasIngressMockConfiguration.java
index b75ab5a..56a01ab 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.oransc.ric.portal.dashboard.config;
 
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.mock;
 
@@ -39,8 +40,8 @@ import org.springframework.context.annotation.Profile;
  * Creates mock implementations of Kubernetes clients that answer requests with
  * sample data read from the filesystem.
  */
-@Profile("test")
 @Configuration
+@Profile("test")
 public class CaasIngressMockConfiguration {
 
        private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@@ -49,13 +50,11 @@ public class CaasIngressMockConfiguration {
        @Value("${mock.config.delay:0}")
        private int delayMs;
 
-       private final String auxPods;
        private final String pltPods;
 
        public CaasIngressMockConfiguration() throws IOException {
                logger.info("Configuring mock CAAS-Ingres clients");
                // Files in src/test/resources
-               auxPods = readDataFromPath("caas-ingress-ricaux-pods.json");
                pltPods = readDataFromPath("caas-ingress-ricplt-pods.json");
        }
 
@@ -77,25 +76,18 @@ public class CaasIngressMockConfiguration {
                return sb.toString();
        }
 
-       @Bean
-       // Use the same name as regular configuration
-       public SimpleKubernetesClient ciAuxApi() throws IOException {
-               SimpleKubernetesClient mockClient = mock(SimpleKubernetesClient.class);
-               doAnswer(inv -> {
-                       logger.debug("listPods for aux");
-                       return auxPods;
-               }).when(mockClient).listPods("ricaux");
-               return mockClient;
-       }
-
        @Bean
        // Use the same name as regular configuration
        public SimpleKubernetesClient ciPltApi() throws IOException {
                SimpleKubernetesClient mockClient = mock(SimpleKubernetesClient.class);
                doAnswer(inv -> {
-                       logger.debug("listPods for plt");
-                       return pltPods;
-               }).when(mockClient).listPods("ricplt");
+                       String ns = inv.<String>getArgument(0);
+                       logger.debug("listPods for namespace {}", ns);
+                       if ("ricplt".equals(ns))
+                               return pltPods;
+                       else
+                               throw new Exception("Fake server failure");
+               }).when(mockClient).listPods(any(String.class));
                return mockClient;
        }