2 * Copyright © 2016-2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.openecomp.sdc.be.components.impl;
19 import static org.mockito.ArgumentMatchers.any;
20 import static org.mockito.ArgumentMatchers.anyBoolean;
21 import static org.mockito.ArgumentMatchers.anyMap;
22 import static org.mockito.ArgumentMatchers.anyString;
23 import static org.mockito.ArgumentMatchers.eq;
24 import static org.mockito.Mockito.when;
26 import java.util.ArrayList;
27 import java.util.Arrays;
28 import java.util.Collections;
29 import java.util.HashMap;
30 import java.util.List;
33 import fj.data.Either;
34 import org.junit.Assert;
35 import org.junit.Before;
36 import org.junit.Test;
37 import org.junit.runner.RunWith;
38 import org.mockito.InjectMocks;
39 import org.mockito.Mock;
40 import org.mockito.Mockito;
41 import org.mockito.junit.MockitoJUnitRunner;
42 import org.openecomp.sdc.be.components.utils.ResourceBuilder;
43 import org.openecomp.sdc.be.components.validation.InterfaceOperationValidation;
44 import org.openecomp.sdc.be.components.validation.UserValidations;
45 import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao;
46 import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
47 import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
48 import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
49 import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
50 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
51 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
52 import org.openecomp.sdc.be.impl.ComponentsUtils;
53 import org.openecomp.sdc.be.model.ArtifactDefinition;
54 import org.openecomp.sdc.be.model.CapabilityDefinition;
55 import org.openecomp.sdc.be.model.ComponentInstanceProperty;
56 import org.openecomp.sdc.be.model.InputDefinition;
57 import org.openecomp.sdc.be.model.InterfaceDefinition;
58 import org.openecomp.sdc.be.model.Resource;
59 import org.openecomp.sdc.be.model.User;
60 import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ArtifactsOperations;
61 import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation;
62 import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
63 import org.openecomp.sdc.be.model.operations.api.IGraphLockOperation;
64 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
65 import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
66 import org.openecomp.sdc.exception.ResponseFormat;
67 import org.openecomp.sdc.test.utils.InterfaceOperationTestUtils;
69 @RunWith(MockitoJUnitRunner.class)
70 public class InterfaceOperationBusinessLogicTest {
72 private static final String resourceId = "resourceId";
73 private static final String interfaceId = "interfaceId";
74 private static final String operationId = "operationId";
75 private static final String inputId = "inputId";
76 private static final String RESOURCE_NAME = "Resource1";
77 private static final String operationId1 = "operationId1";
78 private static final String interfaceId1 = "interfaceId1";
79 private static final String operationName = "createOperation";
82 private InterfaceOperationBusinessLogic interfaceOperationBusinessLogic;
84 private UserValidations userValidations;
86 private ToscaOperationFacade toscaOperationFacade;
88 private ComponentsUtils componentsUtils;
90 private IGraphLockOperation graphLockOperation;
92 private JanusGraphDao janusGraphDao;
94 private InterfaceLifecycleOperation interfaceLifecycleOperation;
96 private InterfaceOperationValidation interfaceOperationValidation;
98 private InterfaceOperation interfaceOperation;
100 private ArtifactCassandraDao artifactCassandraDao;
102 protected ArtifactsOperations artifactToscaOperation;
104 private Resource resource;
107 public void setup() {
108 interfaceOperationBusinessLogic.setUserValidations(userValidations);
109 interfaceOperationBusinessLogic.setToscaOperationFacade(toscaOperationFacade);
110 interfaceOperationBusinessLogic.setGraphLockOperation(graphLockOperation);
111 interfaceOperationBusinessLogic.setJanusGraphDao(janusGraphDao);
112 interfaceOperationBusinessLogic.setComponentsUtils(componentsUtils);
113 resource = new ResourceBuilder().setComponentType(ComponentTypeEnum.RESOURCE).setUniqueId(resourceId)
114 .setName(RESOURCE_NAME).build();
115 resource.setInterfaces(InterfaceOperationTestUtils.createMockInterfaceDefinitionMap(interfaceId, operationId,
117 resource.setInputs(createInputsForResource());
120 when(userValidations.validateUserExists(eq(user.getUserId()), anyString(), eq(true))).thenReturn(user);
121 when(toscaOperationFacade.getToscaElement(resourceId)).thenReturn(Either.left(resource));
122 when(graphLockOperation.lockComponent(Mockito.anyString(), eq(NodeTypeEnum.Resource)))
123 .thenReturn(StorageOperationStatus.OK);
124 when(interfaceOperationValidation
125 .validateInterfaceOperations(any(), any(), any(), anyMap(), anyBoolean()))
126 .thenReturn(Either.left(true));
127 when(interfaceOperationValidation
128 .validateDeleteOperationContainsNoMappedOutput(any(), any(), any()))
129 .thenReturn(Either.left(true));
130 when(janusGraphDao.commit()).thenReturn(JanusGraphOperationStatus.OK);
133 private List<InputDefinition> createInputsForResource() {
134 InputDefinition inputDefinition = new InputDefinition();
135 inputDefinition.setName(inputId);
136 inputDefinition.setInputId(inputId);
137 inputDefinition.setUniqueId(inputId);
138 inputDefinition.setValue(inputId);
139 inputDefinition.setDefaultValue(inputId);
140 return Arrays.asList(inputDefinition);
144 public void createInterfaceOperationTestOnExistingInterface() {
145 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
146 .thenReturn(Either.left(Collections.emptyMap()));
147 when(interfaceOperation.updateInterfaces(any(), any())).thenReturn(Either.left(
148 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId, operationId, operationName))));
149 Either<List<InterfaceDefinition>, ResponseFormat> interfaceOperationEither =
150 interfaceOperationBusinessLogic.createInterfaceOperation(resourceId,
151 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId,
152 operationId, operationName)),
154 Assert.assertTrue(interfaceOperationEither.isLeft());
158 public void createInterfaceOperationTestOnExistingInterfaceInputsFromCapProp() {
159 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
160 .thenReturn(Either.left(Collections.emptyMap()));
161 when(interfaceOperation.updateInterfaces(any(), any())).thenReturn(Either.left(
162 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId, operationId, operationName))));
164 CapabilityDefinition capabilityDefinition = new CapabilityDefinition();
165 capabilityDefinition.setName("cap" + Math.random());
166 capabilityDefinition.setType("tosca.capabilities.network.Bindable");
167 capabilityDefinition.setOwnerId(resourceId);
168 capabilityDefinition.setUniqueId("capUniqueId");
170 List<ComponentInstanceProperty> properties = new ArrayList<>();
171 ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
172 instanceProperty.setUniqueId("ComponentInput1_uniqueId");
173 instanceProperty.setType("Integer");
174 instanceProperty.setName("prop_name");
175 instanceProperty.setDescription("prop_description_prop_desc");
176 instanceProperty.setOwnerId("capUniqueId");
177 instanceProperty.setSchema(new SchemaDefinition());
178 properties.add(instanceProperty);
179 capabilityDefinition.setProperties(properties);
180 Map<String, List<CapabilityDefinition>> capabilityMap = new HashMap<>();
181 capabilityMap.put(capabilityDefinition.getType(), Collections.singletonList(capabilityDefinition));
183 resource.setCapabilities(capabilityMap);
184 when(toscaOperationFacade.getToscaElement(resourceId)).thenReturn(Either.left(resource));
186 Either<List<InterfaceDefinition>, ResponseFormat> interfaceOperationEither =
187 interfaceOperationBusinessLogic.createInterfaceOperation(resourceId,
188 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId,
189 operationId, operationName)),
191 Assert.assertTrue(interfaceOperationEither.isLeft());
196 public void createInterfaceOperationWithoutInterfaceTest() {
197 resource.getInterfaces().clear();
198 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
199 .thenReturn(Either.left(Collections.emptyMap()));
200 when(interfaceOperation.addInterfaces(any(), any())).thenReturn(Either.left(
201 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId, operationId, operationName))));
202 when(interfaceOperation.updateInterfaces(any(), any())).thenReturn(Either.left(
203 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId, operationId, operationName))));
204 Either<List<InterfaceDefinition>, ResponseFormat> interfaceOperationEither =
205 interfaceOperationBusinessLogic.createInterfaceOperation(resourceId,
206 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId,
207 operationId, operationName)),
209 Assert.assertTrue(interfaceOperationEither.isLeft());
213 public void createInterfaceOperationWithoutInterfaceTestFail() {
214 resource.getInterfaces().clear();
215 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
216 .thenReturn(Either.left(Collections.emptyMap()));
217 when(interfaceOperation.addInterfaces(any(), any()))
218 .thenReturn(Either.right(StorageOperationStatus.GENERAL_ERROR));
219 Either<List<InterfaceDefinition>, ResponseFormat> interfaceOperationEither =
220 interfaceOperationBusinessLogic.createInterfaceOperation(resourceId,
221 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId,
222 operationId, operationName)),
224 Assert.assertTrue(interfaceOperationEither.isRight());
228 public void shouldFailWhenCreateInterfaceOperationFailedTest() {
229 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
230 .thenReturn(Either.left(Collections.emptyMap()));
231 when(interfaceOperation.updateInterfaces(any(), any()))
232 .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
233 Assert.assertTrue(interfaceOperationBusinessLogic.createInterfaceOperation(resourceId,
234 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId, operationId, operationName)),
235 user, true).isRight());
239 public void updateInterfaceOperationTestWithArtifactSuccess() {
240 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
241 .thenReturn(Either.left(Collections.emptyMap()));
242 when(artifactToscaOperation.removeArifactFromResource(any(), any(), any(), anyBoolean()))
243 .thenReturn(Either.left(new ArtifactDefinition()));
244 when(artifactToscaOperation.getArtifactById(any(), any())).thenReturn(Either.left(new ArtifactDefinition()));
245 when(artifactCassandraDao.deleteArtifact(any(String.class))).thenReturn(CassandraOperationStatus.OK);
246 when(interfaceOperation.updateInterfaces(any(), any())).thenReturn(Either.left(
247 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId, operationId, operationName))));
248 Either<List<InterfaceDefinition>, ResponseFormat> interfaceOperation =
249 interfaceOperationBusinessLogic.updateInterfaceOperation(resourceId,
250 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId,
251 operationId, operationName)),
253 Assert.assertTrue(interfaceOperation.isLeft());
257 public void updateInterfaceOperationTestWithArtifactFailure() {
258 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
259 .thenReturn(Either.left(Collections.emptyMap()));
260 when(artifactToscaOperation.getArtifactById(any(), any())).thenReturn(Either.left(new ArtifactDefinition()));
261 when(artifactToscaOperation.removeArifactFromResource(any(), any(), any(), anyBoolean()))
262 .thenReturn(Either.right(StorageOperationStatus.ARTIFACT_NOT_FOUND));
263 Either<List<InterfaceDefinition>, ResponseFormat> interfaceOperation =
264 interfaceOperationBusinessLogic.updateInterfaceOperation(resourceId,
265 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId,
266 operationId, operationName)),
268 Assert.assertTrue(interfaceOperation.isRight());
272 public void updateInterfaceOperationTestWithoutArtifact() {
273 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
274 .thenReturn(Either.left(Collections.emptyMap()));
275 when(artifactToscaOperation.getArtifactById(any(), any())).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
276 when(interfaceOperation.updateInterfaces(any(), any())).thenReturn(Either.left(
277 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId, operationId, operationName))));
278 Either<List<InterfaceDefinition>, ResponseFormat> interfaceOperation =
279 interfaceOperationBusinessLogic.updateInterfaceOperation(resourceId,
280 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId,
281 operationId, operationName)),
283 Assert.assertTrue(interfaceOperation.isLeft());
287 public void updateInterfaceOperationTestDoesntExist() {
288 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
289 .thenReturn(Either.left(Collections.emptyMap()));
290 Either<List<InterfaceDefinition>, ResponseFormat> interfaceOperation =
291 interfaceOperationBusinessLogic.updateInterfaceOperation(resourceId,
292 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId,
293 operationId, operationName)),
295 Assert.assertTrue(interfaceOperation.isRight());
299 public void createInterfaceOperationTestFailOnException() {
300 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
301 .thenReturn(Either.left(Collections.emptyMap()));
302 when(interfaceOperation.updateInterfaces(any(), any())).thenThrow(new RuntimeException());
303 Either<List<InterfaceDefinition>, ResponseFormat> interfaceOperationEither =
304 interfaceOperationBusinessLogic.createInterfaceOperation(resourceId,
305 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId,
306 operationId, operationName)),
308 Assert.assertTrue(interfaceOperationEither.isRight());
312 public void createInterfaceOperationTestFailOnFetchinGlobalTypes() {
313 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
314 .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
315 Either<List<InterfaceDefinition>, ResponseFormat> interfaceOperationEither =
316 interfaceOperationBusinessLogic.createInterfaceOperation(resourceId,
317 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId,
318 operationId, operationName)),
320 Assert.assertTrue(interfaceOperationEither.isRight());
324 public void createInterfaceOperationTestFailOnValidation() {
325 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
326 .thenReturn(Either.left(Collections.emptyMap()));
327 when(interfaceOperationValidation
328 .validateInterfaceOperations(any(), any(), any(), anyMap(), anyBoolean()))
329 .thenReturn(Either.right(new ResponseFormat()));
330 Either<List<InterfaceDefinition>, ResponseFormat> interfaceOperationEither =
331 interfaceOperationBusinessLogic.createInterfaceOperation(resourceId,
332 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId,
333 operationId, operationName)),
335 Assert.assertTrue(interfaceOperationEither.isRight());
339 public void deleteInterfaceOperationTestInterfaceDoesntExist() {
340 Assert.assertTrue(interfaceOperationBusinessLogic.deleteInterfaceOperation(resourceId, interfaceId1,
341 Collections.singletonList(operationId), user, true).isRight());
345 public void deleteInterfaceOperationTestOperationDoesntExist() {
346 Assert.assertTrue(interfaceOperationBusinessLogic.deleteInterfaceOperation(resourceId, interfaceId,
347 Collections.singletonList(operationId1), user, true).isRight());
351 public void deleteInterfaceOperationTestSuccess() {
352 resource.getInterfaces().get(interfaceId).getOperations()
353 .putAll(InterfaceOperationTestUtils.createMockOperationMap(operationId1, operationName));
354 when(artifactToscaOperation.getArtifactById(any(), any())).thenReturn(Either.left(new ArtifactDefinition()));
355 when(artifactToscaOperation.removeArifactFromResource(any(), any(), any(), anyBoolean()))
356 .thenReturn(Either.left(new ArtifactDefinition()));
357 when(artifactCassandraDao.deleteArtifact(any(String.class))).thenReturn(CassandraOperationStatus.OK);
358 when(interfaceOperation.updateInterfaces(any(), any())).thenReturn(Either.left(Collections.emptyList()));
359 Assert.assertTrue(interfaceOperationBusinessLogic.deleteInterfaceOperation(resourceId, interfaceId,
360 Collections.singletonList(operationId), user, true).isLeft());
364 public void shouldFailWhenDeleteInterfaceOperationFailedTest() {
365 when(artifactToscaOperation.getArtifactById(any(), any())).thenReturn(Either.left(new ArtifactDefinition()));
366 when(artifactToscaOperation.removeArifactFromResource(any(), any(), any(), anyBoolean()))
367 .thenReturn(Either.left(new ArtifactDefinition()));
368 when(artifactCassandraDao.deleteArtifact(any(String.class))).thenReturn(CassandraOperationStatus.OK);
369 when(interfaceOperation.updateInterfaces(any(), any()))
370 .thenReturn(Either.right(StorageOperationStatus.GENERAL_ERROR));
371 Assert.assertTrue(interfaceOperationBusinessLogic.deleteInterfaceOperation(resourceId, interfaceId,
372 Collections.singletonList(operationId), user, true).isRight());
376 public void deleteInterfaceOperationTestFailOnArtifactDeletion() {
377 when(artifactToscaOperation.getArtifactById(any(), any())).thenReturn(Either.left(new ArtifactDefinition()));
378 when(artifactToscaOperation.removeArifactFromResource(any(), any(), any(), anyBoolean()))
379 .thenReturn(Either.left(new ArtifactDefinition()));
380 when(artifactCassandraDao.deleteArtifact(any(String.class))).thenReturn(CassandraOperationStatus.GENERAL_ERROR);
381 Assert.assertTrue(interfaceOperationBusinessLogic.deleteInterfaceOperation(resourceId, interfaceId,
382 Collections.singletonList(operationId), user, true).isRight());
386 public void deleteInterfaceOperationTestFailOnException() {
387 when(artifactToscaOperation.getArtifactById(any(), any())).thenReturn(Either.left(new ArtifactDefinition()));
388 when(artifactToscaOperation.removeArifactFromResource(any(), any(), any(), anyBoolean()))
389 .thenReturn(Either.left(new ArtifactDefinition()));
390 when(artifactCassandraDao.deleteArtifact(any(String.class))).thenThrow(new RuntimeException());
391 Assert.assertTrue(interfaceOperationBusinessLogic.deleteInterfaceOperation(resourceId, interfaceId,
392 Collections.singletonList(operationId), user, true).isRight());
396 public void deleteInterfaceTestSuccess() {
397 when(artifactToscaOperation.getArtifactById(any(), any())).thenReturn(Either.left(new ArtifactDefinition()));
398 when(artifactToscaOperation.removeArifactFromResource(any(), any(), any(), anyBoolean()))
399 .thenReturn(Either.left(new ArtifactDefinition()));
400 when(artifactCassandraDao.deleteArtifact(any(String.class))).thenReturn(CassandraOperationStatus.OK);
401 when(interfaceOperation.updateInterfaces(any(), any())).thenReturn(Either.left(Collections.emptyList()));
402 when(interfaceOperation.deleteInterface(any(), any())).thenReturn(Either.left(interfaceId));
403 Assert.assertTrue(interfaceOperationBusinessLogic.deleteInterfaceOperation(resourceId, interfaceId,
404 Collections.singletonList(operationId), user, true).isLeft());
408 public void deleteInterfaceTestFailure() {
409 when(artifactToscaOperation.getArtifactById(any(), any())).thenReturn(Either.left(new ArtifactDefinition()));
410 when(artifactToscaOperation.removeArifactFromResource(any(), any(), any(), anyBoolean()))
411 .thenReturn(Either.left(new ArtifactDefinition()));
412 when(artifactCassandraDao.deleteArtifact(any(String.class))).thenReturn(CassandraOperationStatus.OK);
413 when(interfaceOperation.updateInterfaces(any(), any())).thenReturn(Either.left(Collections.emptyList()));
414 when(interfaceOperation.deleteInterface(any(), any()))
415 .thenReturn(Either.right(StorageOperationStatus.GENERAL_ERROR));
416 Assert.assertTrue(interfaceOperationBusinessLogic.deleteInterfaceOperation(resourceId, interfaceId,
417 Collections.singletonList(operationId), user, true).isRight());
421 public void getInterfaceOperationTestInterfaceDoesntExist() {
422 Assert.assertTrue(interfaceOperationBusinessLogic.getInterfaceOperation(resourceId, interfaceId1,
423 Collections.singletonList(operationId), user, true).isRight());
427 public void getInterfaceOperationTestOperationDoesntExist() {
428 Assert.assertTrue(interfaceOperationBusinessLogic.getInterfaceOperation(resourceId, interfaceId,
429 Collections.singletonList(operationId1), user, true).isRight());
433 public void getInterfaceOperationTest() {
434 Assert.assertTrue(interfaceOperationBusinessLogic.getInterfaceOperation(resourceId, interfaceId,
435 Collections.singletonList(operationId), user, true).isLeft());
439 public void getInterfaceOperationTestFailOnException() {
440 when(janusGraphDao.commit()).thenThrow(new RuntimeException());
441 Assert.assertTrue(interfaceOperationBusinessLogic.getInterfaceOperation(resourceId, interfaceId,
442 Collections.singletonList(operationId), user, true).isRight());
446 public void shouldFailWhenLockComponentFailedTest() {
447 when(graphLockOperation.lockComponent(Mockito.anyString(), eq(NodeTypeEnum.Resource)))
448 .thenReturn(StorageOperationStatus.NOT_FOUND);
449 Assert.assertTrue(interfaceOperationBusinessLogic.deleteInterfaceOperation(resourceId, interfaceId,
450 Collections.singletonList(operationId), user, true).isRight());
451 Assert.assertTrue(interfaceOperationBusinessLogic.getInterfaceOperation(resourceId, interfaceId,
452 Collections.singletonList(operationId), user, true).isRight());
453 Assert.assertTrue(interfaceOperationBusinessLogic.createInterfaceOperation(resourceId,
454 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId, operationId, operationName)),
455 user, true).isRight());
459 public void shouldFailWhenGetComponentFailedTest() {
460 when(toscaOperationFacade.getToscaElement(resourceId))
461 .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
462 Assert.assertTrue(interfaceOperationBusinessLogic.deleteInterfaceOperation(resourceId, interfaceId,
463 Collections.singletonList(operationId), user, true).isRight());
464 Assert.assertTrue(interfaceOperationBusinessLogic.getInterfaceOperation(resourceId, interfaceId,
465 Collections.singletonList(operationId), user, true).isRight());
466 Assert.assertTrue(interfaceOperationBusinessLogic.createInterfaceOperation(resourceId,
467 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId, operationId,
468 operationName)), user, true).isRight());
472 public void testGetAllInterfaceLifecycleTypes_TypesNotFound() {
473 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
474 .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
475 Either<Map<String, InterfaceDefinition>, ResponseFormat> response =
476 interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes();
477 Assert.assertTrue(response.isRight());
481 public void testGetAllInterfaceLifecycleTypes_Success() {
482 InterfaceDefinition interfaceDefinition = new InterfaceDefinition();
483 interfaceDefinition.setUniqueId(interfaceId);
484 interfaceDefinition.setType(interfaceId);
485 Map<String, InterfaceDefinition> interfaceDefinitionMap = new HashMap<>();
486 interfaceDefinitionMap.put(interfaceDefinition.getUniqueId(), interfaceDefinition);
487 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
488 .thenReturn(Either.left(interfaceDefinitionMap));
489 Either<Map<String, InterfaceDefinition>, ResponseFormat> response =
490 interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes();
491 Assert.assertEquals(1, response.left().value().size());