diff options
author | Michael Hwang <mhwang@research.att.com> | 2018-03-22 11:02:57 -0400 |
---|---|---|
committer | Michael Hwang <mhwang@research.att.com> | 2018-03-26 10:56:24 -0400 |
commit | e65fc2fc02594a7c8640a6330b2373db1efb923e (patch) | |
tree | 4433e083f96dcb1ad26c6f73d437195d6d8f7a75 /src/main/java/io | |
parent | 7f61b70d33879712c5dad64c04a5d54b2b065138 (diff) |
Add unit tests to reach 50% coverage
Ripped out the dcae controller code which is no longer
needed.
Change-Id: I43906edb80bcd5e25445ec2a7175c6748b0ab2ae
Signed-off-by: Michael Hwang <mhwang@research.att.com>
Issue-ID: DCAEGEN2-257
Diffstat (limited to 'src/main/java/io')
-rw-r--r-- | src/main/java/io/swagger/api/factories/DcaeServicesApiServiceFactory.java | 10 | ||||
-rw-r--r-- | src/main/java/io/swagger/api/impl/DcaeServicesApiServiceImpl.java | 26 |
2 files changed, 5 insertions, 31 deletions
diff --git a/src/main/java/io/swagger/api/factories/DcaeServicesApiServiceFactory.java b/src/main/java/io/swagger/api/factories/DcaeServicesApiServiceFactory.java index 2fda7e7..ba27ada 100644 --- a/src/main/java/io/swagger/api/factories/DcaeServicesApiServiceFactory.java +++ b/src/main/java/io/swagger/api/factories/DcaeServicesApiServiceFactory.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * dcae-inventory * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ package io.swagger.api.factories; -import org.onap.dcae.inventory.clients.DCAEControllerClient; import org.onap.dcae.inventory.clients.DatabusControllerClient; import io.swagger.api.DcaeServicesApiService; import io.swagger.api.impl.DcaeServicesApiServiceImpl; @@ -29,23 +28,18 @@ import io.swagger.api.impl.DcaeServicesApiServiceImpl; public final class DcaeServicesApiServiceFactory { // Yes I agree this code is not great and I blame for Swagger for putting me in this spot. - private static DCAEControllerClient dcaeControllerClient; private static DatabusControllerClient databusControllerClient; //Utility classes, which are a collection of static members, are not meant to be instantiated. private DcaeServicesApiServiceFactory(){ } - public static void setDcaeControllerClient(DCAEControllerClient dcaeControllerClient) { - DcaeServicesApiServiceFactory.dcaeControllerClient = dcaeControllerClient; - } - public static void setDatabusControllerClient(DatabusControllerClient databusControllerClient) { DcaeServicesApiServiceFactory.databusControllerClient = databusControllerClient; } public static DcaeServicesApiService getDcaeServicesApi() { - return new DcaeServicesApiServiceImpl(dcaeControllerClient, databusControllerClient); + return new DcaeServicesApiServiceImpl(databusControllerClient); } } diff --git a/src/main/java/io/swagger/api/impl/DcaeServicesApiServiceImpl.java b/src/main/java/io/swagger/api/impl/DcaeServicesApiServiceImpl.java index f1219ac..26949af 100644 --- a/src/main/java/io/swagger/api/impl/DcaeServicesApiServiceImpl.java +++ b/src/main/java/io/swagger/api/impl/DcaeServicesApiServiceImpl.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * dcae-inventory * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ package io.swagger.api.impl; -import org.onap.dcae.inventory.clients.DCAEControllerClient; import org.onap.dcae.inventory.clients.DatabusControllerClient; import org.onap.dcae.inventory.daos.DCAEServiceComponentsDAO; import org.onap.dcae.inventory.daos.DCAEServiceTransactionDAO; @@ -29,7 +28,6 @@ import org.onap.dcae.inventory.daos.InventoryDAOManager; import org.onap.dcae.inventory.dbthings.mappers.DCAEServiceObjectMapper; import org.onap.dcae.inventory.dbthings.models.DCAEServiceComponentObject; import org.onap.dcae.inventory.dbthings.models.DCAEServiceObject; -import org.onap.dcae.inventory.exceptions.DCAEControllerClientException; import org.onap.dcae.inventory.exceptions.DatabusControllerClientException; import io.swagger.api.*; import io.swagger.model.*; @@ -51,14 +49,11 @@ public class DcaeServicesApiServiceImpl extends DcaeServicesApiService { private static final Logger LOG = LoggerFactory.getLogger(DcaeServicesApiServiceImpl.class); private static final int PAGINATION_PAGE_SIZE = 25; - private static final String COMPONENT_SOURCE_DCAE_CONTROLLER = "DCAECONTROLLER"; private static final String COMPONENT_SOURCE_DATA_BUS_CONTROLLER = "DMAAPCONTROLLER"; - private final DCAEControllerClient dcaeControllerClient; private final DatabusControllerClient databusControllerClient; - public DcaeServicesApiServiceImpl(DCAEControllerClient dcaeControllerClient, DatabusControllerClient databusControllerClient) { - this.dcaeControllerClient = dcaeControllerClient; + public DcaeServicesApiServiceImpl(DatabusControllerClient databusControllerClient) { this.databusControllerClient = databusControllerClient; } @@ -90,22 +85,7 @@ public class DcaeServicesApiServiceImpl extends DcaeServicesApiService { // TODO: When putting together the components fail. Should this be a 500 case? // For now, this is just logged as a warning. - if (COMPONENT_SOURCE_DCAE_CONTROLLER.equalsIgnoreCase(sco.getComponentSource())) { - if (this.dcaeControllerClient != null) { - try { - DCAEControllerClient.ServiceInstance serviceInstance - = this.dcaeControllerClient.getServiceInstance(component.getComponentId()); - component.setStatus(serviceInstance.getStatus()); - // There's no specific location rather its inferred from the AIC tenant - component.setLocation(this.dcaeControllerClient.getLocation(serviceInstance)); - Link componentLink = Link.fromUri(this.dcaeControllerClient.constructResourceURI(sco.getComponentId())) - .rel("component").title(component.getComponentId()).build(); - component.setComponentLink(componentLink); - } catch (DCAEControllerClientException e) { - LOG.warn(String.format("%s, %s", e.getMessage(), sco.toString()), e); - } - } - } else if (COMPONENT_SOURCE_DATA_BUS_CONTROLLER.equalsIgnoreCase(sco.getComponentSource())) { + if (COMPONENT_SOURCE_DATA_BUS_CONTROLLER.equalsIgnoreCase(sco.getComponentSource())) { if (this.databusControllerClient != null) { try { if (this.databusControllerClient.isExists(sco.getComponentId())) { |