Cleanup of EnrichmentController
Change-Id: Ie632cf37c9d8780bf62b8d00b7806fd675ee7a3b
Issue-ID: NONRTRIC-339
Signed-off-by: elinuxhenrik <henrik.b.andersson@est.tech>
diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/controller/EnrichmentController.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/controller/EnrichmentController.java
index 0845fcd..57019ce 100644
--- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/controller/EnrichmentController.java
+++ b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/controller/EnrichmentController.java
@@ -42,7 +42,6 @@
import org.springframework.http.ResponseEntity;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -82,37 +81,6 @@
logger.debug("enrichment: configured with client type {}", eiProducerApi.getClass().getName());
}
- /*
- * The fields are defined in the Enrichment Control Typescript interface.
- */
- @ApiOperation(value = "Get the EI type identifiers")
- @GetMapping(EI_TYPES)
- public ResponseEntity<String> getAllEiTypeIds() {
- logger.debug("getAllEiTypeIds");
- return this.eiProducerApi.getAllEiTypeIds();
- }
-
- @ApiOperation(value = "Get an individual EI type")
- @GetMapping(EI_TYPES + "/{" + EI_TYPE_ID + "}")
- public ResponseEntity<String> getEiType(@PathVariable(EI_TYPE_ID) String eiTypeId) {
- logger.debug("getEiType {}", eiTypeId);
- return this.eiProducerApi.getEiType(eiTypeId);
- }
-
- @ApiOperation(value = "Get an individual EI producer")
- @GetMapping(EI_PRODUCERS + "/{" + EI_PRODUCER_ID + "}")
- public ResponseEntity<String> getEiProducer(@PathVariable(EI_PRODUCER_ID) String eiProducerId) {
- logger.debug("getEiProducer {}", eiProducerId);
- return this.eiProducerApi.getEiProducer(eiProducerId);
- }
-
- @ApiOperation(value = "Get the EI job definitions for one EI producer")
- @GetMapping(EI_PRODUCERS + "/{" + EI_PRODUCER_ID + "}/" + EI_JOBS)
- public ResponseEntity<String> getEiJobsForOneEiProducer(@PathVariable(EI_PRODUCER_ID) String eiProducerId) {
- logger.debug("getEiJobsForOneEiProducer {}", eiProducerId);
- return this.eiProducerApi.getEiJobsForOneEiProducer(eiProducerId);
- }
-
@ApiOperation(value = "Get the EI job definitions for one EI producer")
@GetMapping(EI_JOBS)
public ResponseEntity<List<JobInfo>> getEiJobs() {
@@ -172,11 +140,4 @@
return JsonParser.parseString(statusResponse.getBody()).getAsJsonObject().get("operational_state")
.getAsString();
}
-
- @ApiOperation(value = "Get the status of an EI producer")
- @GetMapping(EI_PRODUCERS + "/{" + EI_PRODUCER_ID + "}/" + STATUS)
- public ResponseEntity<String> getEiProducerStatus(@PathVariable(EI_PRODUCER_ID) String eiProducerId) {
- logger.debug("getEiProducerStatus {}", eiProducerId);
- return this.eiProducerApi.getEiProducerStatus(eiProducerId);
- }
}
diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/eiproducerapi/EiProducerApi.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/eiproducerapi/EiProducerApi.java
index 0e6b5c4..943b9f9 100644
--- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/eiproducerapi/EiProducerApi.java
+++ b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/eiproducerapi/EiProducerApi.java
@@ -23,10 +23,6 @@
public interface EiProducerApi {
- public ResponseEntity<String> getAllEiTypeIds();
-
- public ResponseEntity<String> getEiType(String eiTypeId);
-
public ResponseEntity<String> getAllEiProducerIds();
public ResponseEntity<String> getEiProducer(String eiProducerId);
diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/eiproducerapi/EiProducerApiImpl.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/eiproducerapi/EiProducerApiImpl.java
index f544fe2..51be42a 100644
--- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/eiproducerapi/EiProducerApiImpl.java
+++ b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/eiproducerapi/EiProducerApiImpl.java
@@ -35,7 +35,6 @@
public class EiProducerApiImpl implements EiProducerApi {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- private static final String EI_TYPES = "/eitypes";
private static final String EI_PRODUCERS = "/eiproducers";
private static final String EI_JOBS = "/eijobs";
private static final String STATUS = "/status";
@@ -54,16 +53,6 @@
}
@Override
- public ResponseEntity<String> getAllEiTypeIds() {
- return getResponseArray(EI_TYPES);
- }
-
- @Override
- public ResponseEntity<String> getEiType(String eiTypeId) {
- return getResponseObject(EI_TYPES + "/" + eiTypeId);
- }
-
- @Override
public ResponseEntity<String> getAllEiProducerIds() {
return getResponseArray(EI_PRODUCERS);
}
diff --git a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/RestApiTest.java b/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/RestApiTest.java
index b432b73..4243c34 100644
--- a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/RestApiTest.java
+++ b/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/RestApiTest.java
@@ -72,7 +72,6 @@
String url = "/v2/api-docs";
ResponseEntity<String> resp = restClient().getForEntity(url).block();
assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.OK);
-
JsonElement jsonElement = JsonParser.parseString(resp.getBody());
String indented = gson.toJson(jsonElement);
try (PrintStream out = new PrintStream(new FileOutputStream("../docs/api.json"))) {
diff --git a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/eiproducerapi/EiProducerApiImplTest.java b/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/eiproducerapi/EiProducerApiImplTest.java
index 773bb54..a388d8b 100644
--- a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/eiproducerapi/EiProducerApiImplTest.java
+++ b/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/eiproducerapi/EiProducerApiImplTest.java
@@ -35,13 +35,6 @@
import reactor.core.publisher.Mono;
class EiProducerApiImplTest {
- private static final String URL_EI_TYPES = "/eitypes";
- private static final String EI_TYPE_1 = "eitype1";
- private static final String EI_TYPE_2 = "eitype2";
- private static final String EI_TYPE_1_INFO_VALID =
- "{\"ei_producer_ids\":[\"eiprod1\",\"eiprod2\"],\"ei_job_data_schema\":{\"title\":\"eijob1\"}}";
- private static final String EI_TYPE_1_INFO_INVALID =
- "{\"ei_producer_ids\":[\"eiprod1\",\"eiprod2\"],\"ei_job_data_schema\":\"title\":\"eijob1\"}}";
private static final String URL_EI_PRODUCERS = "/eiproducers";
private static final String EI_PRODUCER_1 = "eiprod1";
private static final String EI_PRODUCER_2 = "eiprod2";
@@ -72,44 +65,6 @@
}
@Test
- void testGetAllEiTypeIdsFailure() {
- whenGetReturnFailure(URL_EI_TYPES, HttpStatus.NOT_FOUND, "");
- ResponseEntity<String> returnedResp = apiUnderTest.getAllEiTypeIds();
- assertEquals(HttpStatus.NOT_FOUND, returnedResp.getStatusCode());
- }
-
- @Test
- void testGetAllEiTypeIdsSuccess() {
- String eiTypeIds = Arrays.asList(EI_TYPE_1, EI_TYPE_2).toString();
-
- whenGetReturnOK(URL_EI_TYPES, HttpStatus.OK, eiTypeIds);
-
- ResponseEntity<String> returnedResp = apiUnderTest.getAllEiTypeIds();
- assertEquals("[\"" + EI_TYPE_1 + "\",\"" + EI_TYPE_2 + "\"]", returnedResp.getBody());
- assertEquals(HttpStatus.OK, returnedResp.getStatusCode());
- }
-
- @Test
- void testGetEiTypeValidJson() {
- whenGetReturnOK(URL_EI_TYPES + "/" + EI_TYPE_1, HttpStatus.OK, EI_TYPE_1_INFO_VALID);
-
- ResponseEntity<String> returnedResp = apiUnderTest.getEiType(EI_TYPE_1);
-
- assertEquals(HttpStatus.OK, returnedResp.getStatusCode());
- assertEquals(EI_TYPE_1_INFO_VALID, returnedResp.getBody());
- }
-
- @Test
- void testGetEiTypeInvalidJson() {
- whenGetReturnOK(URL_EI_TYPES + "/" + EI_TYPE_1, HttpStatus.OK, EI_TYPE_1_INFO_INVALID);
-
- ResponseEntity<String> returnedResp = apiUnderTest.getEiType(EI_TYPE_1);
-
- assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, returnedResp.getStatusCode());
- assertTrue(returnedResp.getBody().contains("JSONException"));
- }
-
- @Test
void testGetAllEiProducerIdsFailure() {
whenGetReturnFailure(URL_EI_PRODUCERS, HttpStatus.NOT_FOUND, "");
ResponseEntity<String> returnedResp = apiUnderTest.getAllEiProducerIds();
diff --git a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/mock/EiTypes.java b/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/mock/EiTypes.java
deleted file mode 100644
index 8fc9eaf..0000000
--- a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/mock/EiTypes.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*-
- * ========================LICENSE_START=================================
- * O-RAN-SC
- * %%
- * Copyright (C) 2019 Nordix Foundation
- * Modifications 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ========================LICENSE_END===================================
- */
-package org.oransc.portal.nonrtric.controlpanel.mock;
-
-import java.util.ArrayList;
-
-public class EiTypes extends ArrayList<EiType> {
-
- private static final long serialVersionUID = -928428052502491021L;
-
-}
diff --git a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/mock/EnrichmentControllerMockConfiguration.java b/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/mock/EnrichmentControllerMockConfiguration.java
index f407f9f..43be49f 100644
--- a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/mock/EnrichmentControllerMockConfiguration.java
+++ b/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/mock/EnrichmentControllerMockConfiguration.java
@@ -67,25 +67,6 @@
private final Database database = new Database();
@Override
- public ResponseEntity<String> getAllEiTypeIds() {
- List<String> result = new ArrayList<>();
- result.addAll(database.getAllEiTypeIds());
- return new ResponseEntity<>(gson.toJson(result), HttpStatus.OK);
- }
-
- public ResponseEntity<String> getAllEiTypes() {
- EiTypes result = new EiTypes();
- result.addAll(database.getAllEiTypes());
- return new ResponseEntity<>(gson.toJson(result), HttpStatus.OK);
- }
-
- @Override
- public ResponseEntity<String> getEiType(String eiTypeId) {
- EiType result = database.getEiTypeInstance(eiTypeId);
- return new ResponseEntity<>(gson.toJson(result), HttpStatus.OK);
- }
-
- @Override
public ResponseEntity<String> getAllEiProducerIds() {
List<String> result = new ArrayList<>();
result.addAll(database.getAllEiProducerIds());
@@ -117,21 +98,6 @@
EiProducer result = database.getEiProducerInstance(eiProducerId);
return new ResponseEntity<>(gson.toJson(result.status()), HttpStatus.OK);
}
-
- public ResponseEntity<String> deleteEiProducerInstance(String eiProducerId) {
- database.deleteEiProducerInstance(eiProducerId);
- return new ResponseEntity<>(HttpStatus.OK);
- }
-
- public ResponseEntity<String> deleteEiTypeInstance(String eiTypeId) {
- database.deleteEiTypeInstance(eiTypeId);
- return new ResponseEntity<>(HttpStatus.OK);
- }
-
- public ResponseEntity<String> deleteEiJobInstance(String eiJobId) {
- database.deleteEiJobInstance(eiJobId);
- return new ResponseEntity<>(HttpStatus.OK);
- }
}
class Database {
@@ -142,12 +108,12 @@
// Create EiType instance
String schema = getStringFromFile("ei-type-1.json");
- EiType eiType1 = putEiTypeInstance("type1", schema, Arrays.asList("prod-1"));
+ EiType eiType1 = getEiTypeInstance("type1", schema, Arrays.asList("prod-1"));
supported_types.add(eiType1);
// Create EiType instance
schema = getStringFromFile("ei-type-2.json");
- EiType eiType2 = putEiTypeInstance("type2", schema, Arrays.asList("prod-1"));
+ EiType eiType2 = getEiTypeInstance("type2", schema, Arrays.asList("prod-1"));
supported_types.add(eiType2);
// Create EiProducer instance
@@ -198,18 +164,12 @@
eiProducers.put(id, eiProducer);
}
- EiType putEiTypeInstance(String id, Object data, List<String> producer_ids) {
- EiType i = ImmutableEiType.builder() //
+ EiType getEiTypeInstance(String id, Object data, List<String> producer_ids) {
+ return ImmutableEiType.builder() //
.ei_type_identity(id) //
.ei_job_data_schema(data) //
.ei_producer_ids(producer_ids) //
.build(); //
- eiTypes.put(id, i);
- return eiTypes.get(id);
- }
-
- public void deleteEiTypeInstance(String id) {
- eiTypes.remove(id);
}
public void deleteEiProducerInstance(String id) {
@@ -220,14 +180,6 @@
eiJobs.remove(id);
}
- EiType getEiTypeInstance(String id) throws RestClientException {
- EiType i = eiTypes.get(id);
- if (i == null) {
- throw new RestClientException("Type not found: " + id);
- }
- return i;
- }
-
EiProducer getEiProducerInstance(String id) throws RestClientException {
EiProducer i = eiProducers.get(id);
if (i == null) {
@@ -236,14 +188,6 @@
return i;
}
- public Collection<String> getAllEiTypeIds() {
- return Collections.unmodifiableCollection(eiTypes.keySet());
- }
-
- public Collection<EiType> getAllEiTypes() {
- return eiTypes.values();
- }
-
public Collection<String> getAllEiProducerIds() {
return Collections.unmodifiableCollection(eiProducers.keySet());
}
@@ -271,10 +215,7 @@
return result;
}
- private Map<String, EiType> eiTypes = new HashMap<>();
private Map<String, EiProducer> eiProducers = new HashMap<>();
private Map<String, EiJob> eiJobs = new HashMap<>();
-
}
-
}