import java.net.URI;
import java.util.Arrays;
import java.util.List;
+import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.function.Function;
import javax.ws.rs.core.Response;
import org.mockito.Mock;
import org.onap.vid.aai.AaiClientInterface;
import org.onap.vid.asdc.parser.ServiceModelInflator;
import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.model.Action;
+import org.onap.vid.model.ModelUtil;
import org.onap.vid.model.ServiceModel;
import org.onap.vid.model.aaiTree.AAITreeNode;
import org.onap.vid.model.aaiTree.FailureAAITreeNode;
import org.onap.vid.model.aaiTree.ServiceInstance;
import org.onap.vid.model.aaiTree.Vnf;
+import org.onap.vid.properties.Features;
import org.onap.vid.testUtils.TestUtils;
+import org.onap.vid.utils.Logging;
import org.springframework.http.HttpMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import org.togglz.core.manager.FeatureManager;
public class AAIServiceTreeIntegrativeTest {
@Mock
ServiceModelInflator serviceModelInflator;
+ @Mock
+ FeatureManager featureManager;
+
+ @Mock
+ Logging logging;
+
+ private AAITreeNodesEnricher aaiTreeNodesEnricher;
private AAITreeNodeBuilder aaiTreeNodeBuilder;
- private AAITreeConverter aaiTreeConverter = new AAITreeConverter();
+ private AAITreeConverter aaiTreeConverter = new AAITreeConverter(new ModelUtil());
private ExecutorService executorService = Executors.newFixedThreadPool(10);
private String serviceType = "vWINIFRED";
private String serviceInstanceId = "62888f15-6d24-4f7b-92a7-c3f35beeb215";
- //TODO Amichai: if in the future it is neede, add here the SUFFIX to the URL: "?format=simple"
private String serviceInstanceRequestUri = "business/customers/customer/" +
globalCustomerID +
"/service-subscriptions/service-subscription/" +
"\"relationship-key\": \"owning-entity.owning-entity-id\"," +
"\"relationship-value\": \"43b8a85a-0421-4265-9069-117dd6526b8a\"}]}]}}";
- //TODO Amichai: if in the future it is neede, add here the SUFFIX to the URL: "?format=simple"
private static String genericVnfRequestUri = "/aai/v12/network/generic-vnfs/generic-vnf/59bde732-9b84-46bd-a59a-3c45fee0538b";
private String genericVnfResponseString(boolean isDuplicatedKeysInTenantRelation) {
@BeforeMethod
public void initMocks() {
TestUtils.initMockitoMocks(this);
- aaiTreeNodeBuilder = new AAITreeNodeBuilder(aaiClient);
+ reboundLoggingWithMdcMock();
+ aaiTreeNodeBuilder = new AAITreeNodeBuilder(aaiClient, logging);
+ aaiTreeNodesEnricher = new AAITreeNodesEnricher(aaiClient, null, featureManager, serviceModelInflator);
+
+ when(featureManager.isActive(Features.FLAG_EXP_TOPOLOGY_TREE_VFMODULE_NAMES_FROM_OTHER_TOSCA_VERSIONS))
+ .thenReturn(true);
+ }
+
+ private void reboundLoggingWithMdcMock() {
+ when(logging.withMDC(any(), any(Callable.class))).thenAnswer(invocation -> invocation.getArgument(1));
+ when(logging.withMDC(any(), any(Function.class))).thenAnswer(invocation -> invocation.getArgument(1));
}
public void getServiceInstanceTreeAndAssert(boolean isDuplicatedKeysInTenantRelation) throws IOException, AsdcCatalogException {
when(aaiGetVersionByInvariantIdResponse.readEntity(String.class)).thenReturn(getVersionByInvariantIdResponseString);
- when(sdcService.getService(any())).thenReturn(mock(ServiceModel.class));
+ when(sdcService.getServiceModelOrThrow(any())).thenReturn(mock(ServiceModel.class));
when(serviceModelInflator.toNamesByVersionId(any())).thenReturn(ImmutableMap.of(
"11c6dc3e-cd6a-41b3-a50e-b5a10f7157d0", new ServiceModelInflator.Names("vnf-model-customization-name", "vnf-key-in-model")
));
- ServiceInstance root = new AAIServiceTree(aaiClient, aaiTreeNodeBuilder, aaiTreeConverter, sdcService, serviceModelInflator, executorService)
+ ServiceInstance root = new AAIServiceTree(aaiTreeNodeBuilder, aaiTreeNodesEnricher, aaiTreeConverter, sdcService, executorService)
.getServiceInstanceTopology(globalCustomerID, serviceType, serviceInstanceId);
assertServiceNode(root, 1);
when(aaiGetVersionByInvariantIdResponse.readEntity(String.class)).
thenReturn(TestUtils.readFileAsString("/getTopology/serviceWithCR/service-design-and-creation.json"));
- when(sdcService.getService(any())).thenReturn(
+ when(sdcService.getServiceModelOrThrow(any())).thenReturn(
TestUtils.readJsonResourceFileAsObject("/getTopology/serviceWithCR/serviceWithCRModel.json", ServiceModel.class));
- ServiceInstance serviceInstance = new AAIServiceTree(aaiClient, aaiTreeNodeBuilder, aaiTreeConverter, sdcService, new ServiceModelInflator(), executorService)
+ ServiceInstance serviceInstance = new AAIServiceTree(aaiTreeNodeBuilder,
+ new AAITreeNodesEnricher(aaiClient, null, featureManager, new ServiceModelInflator()), aaiTreeConverter, sdcService, executorService)
.getServiceInstanceTopology("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", "Emanuel", "a565e6ad-75d1-4493-98f1-33234b5c17e2");
String expected = TestUtils.readFileAsString("/getTopology/serviceWithCR/getTopologyWithCR.json");
when(aaiGetVersionByInvariantIdResponse.readEntity(String.class)).thenReturn(getVersionByInvariantIdResponseString);
- when(sdcService.getService(any())).thenReturn(mock(ServiceModel.class));
+ when(sdcService.getServiceModelOrThrow(any())).thenReturn(mock(ServiceModel.class));
when(serviceModelInflator.toNamesByVersionId(any())).thenReturn(ImmutableMap.of());
- new AAIServiceTree(aaiClient, aaiTreeNodeBuilder, aaiTreeConverter, sdcService, serviceModelInflator, executorService)
+ new AAIServiceTree(aaiTreeNodeBuilder, aaiTreeNodesEnricher, aaiTreeConverter, sdcService, executorService)
.getServiceInstanceTopology(globalCustomerID, serviceType, serviceInstanceId);
}