import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.openecomp.sdc.be.components.impl.ServiceImportBusinessLogic.CREATE_RESOURCE;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
-import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.openecomp.sdc.be.components.csar.CsarInfo;
import org.openecomp.sdc.be.components.impl.artifact.ArtifactOperationInfo;
class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTestSetup {
- @InjectMocks
- private ServiceImportBusinessLogic sIBL;
-
- @Mock
- private ArtifactDefinition artifactDefinition;
- @Mock
- private ServletUtils servletUtils;
- @Mock
- private ResourceImportManager resourceImportManager;
+ private static final String DEFAULT_ICON = "defaulticon";
- private AbstractValidationsServlet servlet = new ArtifactExternalServlet(userBusinessLogic,
+ private final ArtifactDefinition artifactDefinition = mock(ArtifactDefinition.class);
+ private final ResourceImportManager resourceImportManager = mock(ResourceImportManager.class);
+ private final ServletUtils servletUtils = mock(ServletUtils.class);
+ private final AbstractValidationsServlet servlet = new ArtifactExternalServlet(userBusinessLogic,
componentInstanceBusinessLogic, componentsUtils, servletUtils, resourceImportManager, artifactsBusinessLogic);
+ @InjectMocks
+ private ServiceImportBusinessLogic sIBL;
public static String loadFileNameToJsonString(String fileName) throws IOException {
String sourceDir = "src/test/resources/normativeTypes";
when(serviceImportParseLogic.getServiceWithGroups(anyString())).thenReturn(newService);
when(mockJanusGraphDao.commit()).thenReturn(JanusGraphOperationStatus.OK);
when(graphLockOperation.unlockComponentByName(anyString(), anyString(), any(NodeTypeEnum.class))).thenReturn(StorageOperationStatus.OK);
+ when(serviceImportParseLogic.createOutputsOnService(any(Service.class), any(), anyString())).thenReturn(newService);
Service result = sIBL.createService(oldService, AuditingActionEnum.CREATE_RESOURCE, user, payload, payloadName);
assertNotNull(result);
Assertions.assertThrows(ComponentException.class, () -> sIBL.createServiceFromYaml(oldService,
topologyTemplateYaml, yamlName, nodeTypesInfo, csarInfo,
- nodeTypesArtifactsToCreate, false, true, nodeName));
+ nodeTypesArtifactsToCreate, false, true, nodeName, user.getUserId()));
}
@Test
csfyp.setParsedToscaYamlInfo(parsedToscaYamlInfo);
when(toscaOperationFacade.getLatestResourceByToscaResourceName(anyString())).thenReturn(Either.left(resource));
Assertions.assertThrows(ComponentException.class, () -> sIBL.createServiceAndRIsFromYaml(oldService,
- false, nodeTypesArtifactsToCreate, false, true, csfyp));
+ false, nodeTypesArtifactsToCreate, false, true, csfyp, user.getUserId()));
}
@Test
csfyp.setParsedToscaYamlInfo(parsedToscaYamlInfo);
when(toscaOperationFacade.getLatestResourceByToscaResourceName(anyString())).thenReturn(Either.left(resource));
Assertions.assertThrows(ComponentException.class, () -> sIBL.createServiceAndRIsFromYaml(oldService,
- false, nodeTypesArtifactsToCreate, false, true, csfyp));
+ false, nodeTypesArtifactsToCreate, false, true, csfyp, user.getUserId()));
}
@Test
void testCreateGroupsOnResourceNull() {
Service service = createServiceObject(true);
Map<String, GroupDefinition> groups = new HashMap<>();
- Assertions.assertNotNull(sIBL.createGroupsOnResource(service, groups));
+ Assertions.assertNotNull(
+ sIBL.createGroupsOnResource(service, groups));
}
@Test
void testUpdateGroupsMembersUsingResource() {
Service service = createServiceObject(true);
Map<String, GroupDefinition> groups = getGroups();
- Assertions.assertNotNull(sIBL.updateGroupsMembersUsingResource(groups, service));
+
+ Assertions.assertNotNull(
+ sIBL.updateGroupsMembersUsingResource(groups, service));
}
@Test
void testUpdateGroupsMembersUsingResource_left() {
Service service = createServiceObject(true);
Map<String, GroupDefinition> groups = getGroups();
- Assertions.assertNotNull(sIBL.updateGroupsMembersUsingResource(groups, service));
+
+ Assertions.assertNotNull(
+ sIBL.updateGroupsMembersUsingResource(groups, service));
}
@Test
groupDefinition.setUniqueId("groupDefinitionUniqueId");
groupDefinition.setName("groupDefinition");
groupDefinitionList.add(groupDefinition);
- Assertions.assertNotNull(sIBL.createGroupsOnResource(resource, groups));
+
+ Assertions.assertNotNull(
+ sIBL.createGroupsOnResource(resource, groups));
}
@Test
void testUpdateGroupsMembersUsingResource2() {
Resource resource = createParseResourceObject(true);
Map<String, GroupDefinition> groups = getGroups();
- Assertions.assertNotNull(sIBL.updateGroupsMembersUsingResource(groups, resource));
+
+ Assertions.assertNotNull(
+ sIBL.updateGroupsMembersUsingResource(groups, resource));
}
@Test
void testUpdateGroupsMembersUsingResource_left2() {
Resource resource = createParseResourceObject(true);
Map<String, GroupDefinition> groups = getGroups();
- Assertions.assertNotNull(sIBL.updateGroupsMembersUsingResource(groups, resource));
+
+ Assertions.assertNotNull(
+ sIBL.updateGroupsMembersUsingResource(groups, resource));
}
@Test