Introduce rAPP Catalogue API
[nonrtric.git] / enrichment-coordinator-service / src / test / java / org / oransc / enrichment / ApplicationTest.java
index 67b0d8a..e564fef 100644 (file)
@@ -1,9 +1,9 @@
 /*-
  * ========================LICENSE_START=================================
- * ONAP : ccsdk oran
- * ======================================================================
- * Copyright (C) 2019-2020 Nordix Foundation. All rights reserved.
- * ======================================================================
+ * O-RAN-SC
+ * %%
+ * Copyright (C) 2020 Nordix Foundation
+ * %%
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -42,6 +42,7 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.oransc.enrichment.clients.AsyncRestClient;
+import org.oransc.enrichment.clients.AsyncRestClientFactory;
 import org.oransc.enrichment.clients.ProducerJobInfo;
 import org.oransc.enrichment.configuration.ApplicationConfig;
 import org.oransc.enrichment.configuration.ImmutableWebClientConfig;
@@ -163,6 +164,13 @@ class ApplicationTest {
         assertThat(rsp).isEqualTo("[\"test\"]");
     }
 
+    @Test
+    void testGetEiTypesEmpty() throws Exception {
+        String url = ConsumerConsts.API_ROOT + "/eitypes";
+        String rsp = restClient().get(url).block();
+        assertThat(rsp).isEqualTo("[]");
+    }
+
     @Test
     void testGetEiType() throws Exception {
         putEiProducerWithOneType(EI_PRODUCER_ID, "test");
@@ -185,6 +193,14 @@ class ApplicationTest {
         String url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs";
         String rsp = restClient().get(url).block();
         assertThat(rsp).isEqualTo("[\"jobId\"]");
+
+        url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs?owner=owner";
+        rsp = restClient().get(url).block();
+        assertThat(rsp).isEqualTo("[\"jobId\"]");
+
+        url = ConsumerConsts.API_ROOT + "/eitypes/typeId/eijobs?owner=JUNK";
+        rsp = restClient().get(url).block();
+        assertThat(rsp).isEqualTo("[]");
     }
 
     @Test
@@ -474,6 +490,16 @@ class ApplicationTest {
         assertThat(this.eiTypes.size()).isEqualTo(0);
     }
 
+    @Test
+    void testGetStatus() throws JsonMappingException, JsonProcessingException, ServiceException {
+        putEiProducerWithOneTypeRejecting("simulateProducerError", EI_TYPE_ID);
+        putEiProducerWithOneTypeRejecting("simulateProducerError2", EI_TYPE_ID);
+
+        String url = "/status";
+        ResponseEntity<String> resp = restClient().getForEntity(url).block();
+        assertThat(resp.getBody()).contains("hunky dory");
+    }
+
     ProducerEiTypeRegistrationInfo producerEiTypeRegistrationInfo(String typeId)
         throws JsonMappingException, JsonProcessingException {
         return new ProducerEiTypeRegistrationInfo(jsonSchemaObject(), typeId);
@@ -576,7 +602,8 @@ class ApplicationTest {
             .trustStorePassword(config.trustStorePassword()) //
             .build();
 
-        return new AsyncRestClient(baseUrl(), config);
+        AsyncRestClientFactory restClientFactory = new AsyncRestClientFactory(config);
+        return restClientFactory.createRestClient(baseUrl());
     }
 
     private AsyncRestClient restClient() {