X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-backend%2Fsrc%2Ftest%2Fjava%2Forg%2Foransc%2Fportal%2Fnonrtric%2Fcontrolpanel%2Fmock%2FEnrichmentControllerMockConfiguration.java;h=b9dcc6b78ce6543e352dad29b41529d5dff1bbb9;hb=b36108a6b4f18c5620ed120184bdd8c86c85c70e;hp=c0fb4f11cee98af0ee0605aa987572ec0ce4850a;hpb=d8e8633cdb1927a79ee1c5866a6c3d7cf455db42;p=portal%2Fnonrtric-controlpanel.git 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 c0fb4f1..b9dcc6b 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 @@ -37,6 +37,9 @@ import java.util.stream.Collectors; import org.oransc.portal.nonrtric.controlpanel.eiproducerapi.EiProducerApi; import org.oransc.portal.nonrtric.controlpanel.model.JobInfo; +import org.oransc.portal.nonrtric.controlpanel.model.ProducerRegistrationInfo; +import org.oransc.portal.nonrtric.controlpanel.model.ProducerRegistrationInfo.ProducerEiTypeRegistrationInfo; +import org.oransc.portal.nonrtric.controlpanel.model.ProducerStatusInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.test.context.TestConfiguration; @@ -74,29 +77,29 @@ public class EnrichmentControllerMockConfiguration { } public ResponseEntity getAllEiProducers() { - EiProducers result = new EiProducers(); + List result = new ArrayList<>(); result.addAll(database.getAllEiProducers()); return new ResponseEntity<>(gson.toJson(result), HttpStatus.OK); } @Override - public ResponseEntity getEiProducer(String eiProducerId) { - EiProducer result = database.getEiProducerInstance(eiProducerId); - return new ResponseEntity<>(gson.toJson(result), HttpStatus.OK); + public ResponseEntity getEiProducer(String eiProducerId) { + ProducerRegistrationInfo result = database.getEiProducerInstance(eiProducerId); + return new ResponseEntity<>(result, HttpStatus.OK); } @Override - public ResponseEntity getEiJobsForOneEiProducer(String eiProducerId) { - EiJobs result = new EiJobs(); + public ResponseEntity> getEiJobsForOneEiProducer(String eiProducerId) { + List result = new ArrayList<>(); result.addAll(database.getAllEiJobs()); - return new ResponseEntity<>(gson.toJson(result), HttpStatus.OK); + return new ResponseEntity<>(result, HttpStatus.OK); } @Override - public ResponseEntity getEiProducerStatus(String eiProducerId) { - EiProducer result = database.getEiProducerInstance(eiProducerId); - return new ResponseEntity<>(gson.toJson(result.status()), HttpStatus.OK); + public ResponseEntity getEiProducerStatus(String eiProducerId) { + ProducerRegistrationInfo result = database.getEiProducerInstance(eiProducerId); + return new ResponseEntity<>(result.status, HttpStatus.OK); } } @@ -104,19 +107,19 @@ public class EnrichmentControllerMockConfiguration { Database() { - List supported_types = new ArrayList(); + List supported_types = new ArrayList(); - // Create EiType instance + // Create ProducerEiTypeRegistrationInfo instance String schema = getStringFromFile("ei-type-1.json"); - EiType eiType1 = getEiTypeInstance("type1", schema, Arrays.asList("prod-1")); + ProducerEiTypeRegistrationInfo eiType1 = getEiTypeInstance("type1", schema, Arrays.asList("prod-1")); supported_types.add(eiType1); - // Create EiType instance + // Create ProducerEiTypeRegistrationInfo instance schema = getStringFromFile("ei-type-2.json"); - EiType eiType2 = getEiTypeInstance("type2", schema, Arrays.asList("prod-1")); + ProducerEiTypeRegistrationInfo eiType2 = getEiTypeInstance("type2", schema, Arrays.asList("prod-1")); supported_types.add(eiType2); - // Create EiProducer instance + // Create ProducerRegistrationInfo instance putEiProducerInstance("prod-1", "http://example.com/", "http://example.com/", "http://example.com/", supported_types, new ProducerStatusInfo(ProducerStatusInfo.OperationalState.ENABLED)); @@ -152,22 +155,20 @@ public class EnrichmentControllerMockConfiguration { } void putEiProducerInstance(String id, String creation_url, String deletion_url, String callback_url, - List supported_types, ProducerStatusInfo status) { - EiProducer eiProducer = ImmutableEiProducer.builder() // - .ei_producer_id(id) // - .ei_job_creation_callback_url(creation_url) // - .ei_job_deletion_callback_url(deletion_url) // - .ei_producer_supervision_callback_url(callback_url) // - .supported_ei_types(supported_types) // - .status(status).build(); // + List supported_types, ProducerStatusInfo status) { + ProducerRegistrationInfo eiProducer = ProducerRegistrationInfo.builder() // + .jobCallbackUrl(creation_url) // + .producerSupervisionCallbackUrl(callback_url) // + .types(supported_types) // + .status(status) // + .build(); // eiProducers.put(id, eiProducer); } - EiType getEiTypeInstance(String id, Object data, List producer_ids) { - return ImmutableEiType.builder() // - .ei_type_identity(id) // - .ei_job_data_schema(data) // - .ei_producer_ids(producer_ids) // + ProducerEiTypeRegistrationInfo getEiTypeInstance(String id, Object data, List producer_ids) { + return ProducerEiTypeRegistrationInfo.builder() // + .eiTypeId(id) // + .jobDataSchema(data) // .build(); // } @@ -179,8 +180,8 @@ public class EnrichmentControllerMockConfiguration { eiJobs.remove(id); } - EiProducer getEiProducerInstance(String id) throws RestClientException { - EiProducer i = eiProducers.get(id); + ProducerRegistrationInfo getEiProducerInstance(String id) throws RestClientException { + ProducerRegistrationInfo i = eiProducers.get(id); if (i == null) { throw new RestClientException("Producer not found: " + id); } @@ -191,16 +192,15 @@ public class EnrichmentControllerMockConfiguration { return Collections.unmodifiableCollection(eiProducers.keySet()); } - public Collection getAllEiProducers() { + public Collection getAllEiProducers() { return eiProducers.values(); } public List getAllEiJobs() { return new ArrayList<>(eiJobs.values()); - } - private Map eiProducers = new HashMap<>(); + private Map eiProducers = new HashMap<>(); private Map eiJobs = new HashMap<>(); } }