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 resource = new ResourceBuilder().setComponentType(ComponentTypeEnum.RESOURCE).setUniqueId(resourceId)
109 .setName(RESOURCE_NAME).build();
110 resource.setInterfaces(InterfaceOperationTestUtils.createMockInterfaceDefinitionMap(interfaceId, operationId,
112 resource.setInputs(createInputsForResource());
115 when(userValidations.validateUserExists(eq(user.getUserId()), anyString(), eq(true))).thenReturn(user);
116 when(toscaOperationFacade.getToscaElement(resourceId)).thenReturn(Either.left(resource));
117 when(graphLockOperation.lockComponent(Mockito.anyString(), eq(NodeTypeEnum.Resource)))
118 .thenReturn(StorageOperationStatus.OK);
119 when(interfaceOperationValidation
120 .validateInterfaceOperations(any(), any(), any(), anyMap(), anyBoolean()))
121 .thenReturn(Either.left(true));
122 when(interfaceOperationValidation
123 .validateDeleteOperationContainsNoMappedOutput(any(), any(), any()))
124 .thenReturn(Either.left(true));
125 when(janusGraphDao.commit()).thenReturn(JanusGraphOperationStatus.OK);
128 private List<InputDefinition> createInputsForResource() {
129 InputDefinition inputDefinition = new InputDefinition();
130 inputDefinition.setName(inputId);
131 inputDefinition.setInputId(inputId);
132 inputDefinition.setUniqueId(inputId);
133 inputDefinition.setValue(inputId);
134 inputDefinition.setDefaultValue(inputId);
135 return Arrays.asList(inputDefinition);
139 public void createInterfaceOperationTestOnExistingInterface() {
140 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
141 .thenReturn(Either.left(Collections.emptyMap()));
142 when(interfaceOperation.updateInterfaces(any(), any())).thenReturn(Either.left(
143 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId, operationId, operationName))));
144 Either<List<InterfaceDefinition>, ResponseFormat> interfaceOperationEither =
145 interfaceOperationBusinessLogic.createInterfaceOperation(resourceId,
146 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId,
147 operationId, operationName)),
149 Assert.assertTrue(interfaceOperationEither.isLeft());
153 public void createInterfaceOperationTestOnExistingInterfaceInputsFromCapProp() {
154 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
155 .thenReturn(Either.left(Collections.emptyMap()));
156 when(interfaceOperation.updateInterfaces(any(), any())).thenReturn(Either.left(
157 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId, operationId, operationName))));
159 CapabilityDefinition capabilityDefinition = new CapabilityDefinition();
160 capabilityDefinition.setName("cap" + Math.random());
161 capabilityDefinition.setType("tosca.capabilities.network.Bindable");
162 capabilityDefinition.setOwnerId(resourceId);
163 capabilityDefinition.setUniqueId("capUniqueId");
165 List<ComponentInstanceProperty> properties = new ArrayList<>();
166 ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
167 instanceProperty.setUniqueId("ComponentInput1_uniqueId");
168 instanceProperty.setType("Integer");
169 instanceProperty.setName("prop_name");
170 instanceProperty.setDescription("prop_description_prop_desc");
171 instanceProperty.setOwnerId("capUniqueId");
172 instanceProperty.setSchema(new SchemaDefinition());
173 properties.add(instanceProperty);
174 capabilityDefinition.setProperties(properties);
175 Map<String, List<CapabilityDefinition>> capabilityMap = new HashMap<>();
176 capabilityMap.put(capabilityDefinition.getType(), Collections.singletonList(capabilityDefinition));
178 resource.setCapabilities(capabilityMap);
179 when(toscaOperationFacade.getToscaElement(resourceId)).thenReturn(Either.left(resource));
181 Either<List<InterfaceDefinition>, ResponseFormat> interfaceOperationEither =
182 interfaceOperationBusinessLogic.createInterfaceOperation(resourceId,
183 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId,
184 operationId, operationName)),
186 Assert.assertTrue(interfaceOperationEither.isLeft());
191 public void createInterfaceOperationWithoutInterfaceTest() {
192 resource.getInterfaces().clear();
193 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
194 .thenReturn(Either.left(Collections.emptyMap()));
195 when(interfaceOperation.addInterfaces(any(), any())).thenReturn(Either.left(
196 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId, operationId, operationName))));
197 when(interfaceOperation.updateInterfaces(any(), any())).thenReturn(Either.left(
198 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId, operationId, operationName))));
199 Either<List<InterfaceDefinition>, ResponseFormat> interfaceOperationEither =
200 interfaceOperationBusinessLogic.createInterfaceOperation(resourceId,
201 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId,
202 operationId, operationName)),
204 Assert.assertTrue(interfaceOperationEither.isLeft());
208 public void createInterfaceOperationWithoutInterfaceTestFail() {
209 resource.getInterfaces().clear();
210 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
211 .thenReturn(Either.left(Collections.emptyMap()));
212 when(interfaceOperation.addInterfaces(any(), any()))
213 .thenReturn(Either.right(StorageOperationStatus.GENERAL_ERROR));
214 Either<List<InterfaceDefinition>, ResponseFormat> interfaceOperationEither =
215 interfaceOperationBusinessLogic.createInterfaceOperation(resourceId,
216 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId,
217 operationId, operationName)),
219 Assert.assertTrue(interfaceOperationEither.isRight());
223 public void shouldFailWhenCreateInterfaceOperationFailedTest() {
224 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
225 .thenReturn(Either.left(Collections.emptyMap()));
226 when(interfaceOperation.updateInterfaces(any(), any()))
227 .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
228 Assert.assertTrue(interfaceOperationBusinessLogic.createInterfaceOperation(resourceId,
229 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId, operationId, operationName)),
230 user, true).isRight());
234 public void updateInterfaceOperationTestWithArtifactSuccess() {
235 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
236 .thenReturn(Either.left(Collections.emptyMap()));
237 when(artifactToscaOperation.removeArifactFromResource(any(), any(), any(), anyBoolean()))
238 .thenReturn(Either.left(new ArtifactDefinition()));
239 when(artifactToscaOperation.getArtifactById(any(), any())).thenReturn(Either.left(new ArtifactDefinition()));
240 when(artifactCassandraDao.deleteArtifact(any(String.class))).thenReturn(CassandraOperationStatus.OK);
241 when(interfaceOperation.updateInterfaces(any(), any())).thenReturn(Either.left(
242 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId, operationId, operationName))));
243 Either<List<InterfaceDefinition>, ResponseFormat> interfaceOperation =
244 interfaceOperationBusinessLogic.updateInterfaceOperation(resourceId,
245 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId,
246 operationId, operationName)),
248 Assert.assertTrue(interfaceOperation.isLeft());
252 public void updateInterfaceOperationTestWithArtifactFailure() {
253 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
254 .thenReturn(Either.left(Collections.emptyMap()));
255 when(artifactToscaOperation.getArtifactById(any(), any())).thenReturn(Either.left(new ArtifactDefinition()));
256 when(artifactToscaOperation.removeArifactFromResource(any(), any(), any(), anyBoolean()))
257 .thenReturn(Either.right(StorageOperationStatus.ARTIFACT_NOT_FOUND));
258 Either<List<InterfaceDefinition>, ResponseFormat> interfaceOperation =
259 interfaceOperationBusinessLogic.updateInterfaceOperation(resourceId,
260 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId,
261 operationId, operationName)),
263 Assert.assertTrue(interfaceOperation.isRight());
267 public void updateInterfaceOperationTestWithoutArtifact() {
268 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
269 .thenReturn(Either.left(Collections.emptyMap()));
270 when(artifactToscaOperation.getArtifactById(any(), any())).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
271 when(interfaceOperation.updateInterfaces(any(), any())).thenReturn(Either.left(
272 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId, operationId, operationName))));
273 Either<List<InterfaceDefinition>, ResponseFormat> interfaceOperation =
274 interfaceOperationBusinessLogic.updateInterfaceOperation(resourceId,
275 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId,
276 operationId, operationName)),
278 Assert.assertTrue(interfaceOperation.isLeft());
282 public void updateInterfaceOperationTestDoesntExist() {
283 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
284 .thenReturn(Either.left(Collections.emptyMap()));
285 Either<List<InterfaceDefinition>, ResponseFormat> interfaceOperation =
286 interfaceOperationBusinessLogic.updateInterfaceOperation(resourceId,
287 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId,
288 operationId, operationName)),
290 Assert.assertTrue(interfaceOperation.isRight());
294 public void createInterfaceOperationTestFailOnException() {
295 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
296 .thenReturn(Either.left(Collections.emptyMap()));
297 when(interfaceOperation.updateInterfaces(any(), any())).thenThrow(new RuntimeException());
298 Either<List<InterfaceDefinition>, ResponseFormat> interfaceOperationEither =
299 interfaceOperationBusinessLogic.createInterfaceOperation(resourceId,
300 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId,
301 operationId, operationName)),
303 Assert.assertTrue(interfaceOperationEither.isRight());
307 public void createInterfaceOperationTestFailOnFetchinGlobalTypes() {
308 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
309 .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
310 Either<List<InterfaceDefinition>, ResponseFormat> interfaceOperationEither =
311 interfaceOperationBusinessLogic.createInterfaceOperation(resourceId,
312 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId,
313 operationId, operationName)),
315 Assert.assertTrue(interfaceOperationEither.isRight());
319 public void createInterfaceOperationTestFailOnValidation() {
320 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
321 .thenReturn(Either.left(Collections.emptyMap()));
322 when(interfaceOperationValidation
323 .validateInterfaceOperations(any(), any(), any(), anyMap(), anyBoolean()))
324 .thenReturn(Either.right(new ResponseFormat()));
325 Either<List<InterfaceDefinition>, ResponseFormat> interfaceOperationEither =
326 interfaceOperationBusinessLogic.createInterfaceOperation(resourceId,
327 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId,
328 operationId, operationName)),
330 Assert.assertTrue(interfaceOperationEither.isRight());
334 public void deleteInterfaceOperationTestInterfaceDoesntExist() {
335 Assert.assertTrue(interfaceOperationBusinessLogic.deleteInterfaceOperation(resourceId, interfaceId1,
336 Collections.singletonList(operationId), user, true).isRight());
340 public void deleteInterfaceOperationTestOperationDoesntExist() {
341 Assert.assertTrue(interfaceOperationBusinessLogic.deleteInterfaceOperation(resourceId, interfaceId,
342 Collections.singletonList(operationId1), user, true).isRight());
346 public void deleteInterfaceOperationTestSuccess() {
347 resource.getInterfaces().get(interfaceId).getOperations()
348 .putAll(InterfaceOperationTestUtils.createMockOperationMap(operationId1, operationName));
349 when(artifactToscaOperation.getArtifactById(any(), any())).thenReturn(Either.left(new ArtifactDefinition()));
350 when(artifactToscaOperation.removeArifactFromResource(any(), any(), any(), anyBoolean()))
351 .thenReturn(Either.left(new ArtifactDefinition()));
352 when(artifactCassandraDao.deleteArtifact(any(String.class))).thenReturn(CassandraOperationStatus.OK);
353 when(interfaceOperation.updateInterfaces(any(), any())).thenReturn(Either.left(Collections.emptyList()));
354 Assert.assertTrue(interfaceOperationBusinessLogic.deleteInterfaceOperation(resourceId, interfaceId,
355 Collections.singletonList(operationId), user, true).isLeft());
359 public void shouldFailWhenDeleteInterfaceOperationFailedTest() {
360 when(artifactToscaOperation.getArtifactById(any(), any())).thenReturn(Either.left(new ArtifactDefinition()));
361 when(artifactToscaOperation.removeArifactFromResource(any(), any(), any(), anyBoolean()))
362 .thenReturn(Either.left(new ArtifactDefinition()));
363 when(artifactCassandraDao.deleteArtifact(any(String.class))).thenReturn(CassandraOperationStatus.OK);
364 when(interfaceOperation.updateInterfaces(any(), any()))
365 .thenReturn(Either.right(StorageOperationStatus.GENERAL_ERROR));
366 Assert.assertTrue(interfaceOperationBusinessLogic.deleteInterfaceOperation(resourceId, interfaceId,
367 Collections.singletonList(operationId), user, true).isRight());
371 public void deleteInterfaceOperationTestFailOnArtifactDeletion() {
372 when(artifactToscaOperation.getArtifactById(any(), any())).thenReturn(Either.left(new ArtifactDefinition()));
373 when(artifactToscaOperation.removeArifactFromResource(any(), any(), any(), anyBoolean()))
374 .thenReturn(Either.left(new ArtifactDefinition()));
375 when(artifactCassandraDao.deleteArtifact(any(String.class))).thenReturn(CassandraOperationStatus.GENERAL_ERROR);
376 Assert.assertTrue(interfaceOperationBusinessLogic.deleteInterfaceOperation(resourceId, interfaceId,
377 Collections.singletonList(operationId), user, true).isRight());
381 public void deleteInterfaceOperationTestFailOnException() {
382 when(artifactToscaOperation.getArtifactById(any(), any())).thenReturn(Either.left(new ArtifactDefinition()));
383 when(artifactToscaOperation.removeArifactFromResource(any(), any(), any(), anyBoolean()))
384 .thenReturn(Either.left(new ArtifactDefinition()));
385 when(artifactCassandraDao.deleteArtifact(any(String.class))).thenThrow(new RuntimeException());
386 Assert.assertTrue(interfaceOperationBusinessLogic.deleteInterfaceOperation(resourceId, interfaceId,
387 Collections.singletonList(operationId), user, true).isRight());
391 public void deleteInterfaceTestSuccess() {
392 when(artifactToscaOperation.getArtifactById(any(), any())).thenReturn(Either.left(new ArtifactDefinition()));
393 when(artifactToscaOperation.removeArifactFromResource(any(), any(), any(), anyBoolean()))
394 .thenReturn(Either.left(new ArtifactDefinition()));
395 when(artifactCassandraDao.deleteArtifact(any(String.class))).thenReturn(CassandraOperationStatus.OK);
396 when(interfaceOperation.updateInterfaces(any(), any())).thenReturn(Either.left(Collections.emptyList()));
397 when(interfaceOperation.deleteInterface(any(), any())).thenReturn(Either.left(interfaceId));
398 Assert.assertTrue(interfaceOperationBusinessLogic.deleteInterfaceOperation(resourceId, interfaceId,
399 Collections.singletonList(operationId), user, true).isLeft());
403 public void deleteInterfaceTestFailure() {
404 when(artifactToscaOperation.getArtifactById(any(), any())).thenReturn(Either.left(new ArtifactDefinition()));
405 when(artifactToscaOperation.removeArifactFromResource(any(), any(), any(), anyBoolean()))
406 .thenReturn(Either.left(new ArtifactDefinition()));
407 when(artifactCassandraDao.deleteArtifact(any(String.class))).thenReturn(CassandraOperationStatus.OK);
408 when(interfaceOperation.updateInterfaces(any(), any())).thenReturn(Either.left(Collections.emptyList()));
409 when(interfaceOperation.deleteInterface(any(), any()))
410 .thenReturn(Either.right(StorageOperationStatus.GENERAL_ERROR));
411 Assert.assertTrue(interfaceOperationBusinessLogic.deleteInterfaceOperation(resourceId, interfaceId,
412 Collections.singletonList(operationId), user, true).isRight());
416 public void getInterfaceOperationTestInterfaceDoesntExist() {
417 Assert.assertTrue(interfaceOperationBusinessLogic.getInterfaceOperation(resourceId, interfaceId1,
418 Collections.singletonList(operationId), user, true).isRight());
422 public void getInterfaceOperationTestOperationDoesntExist() {
423 Assert.assertTrue(interfaceOperationBusinessLogic.getInterfaceOperation(resourceId, interfaceId,
424 Collections.singletonList(operationId1), user, true).isRight());
428 public void getInterfaceOperationTest() {
429 Assert.assertTrue(interfaceOperationBusinessLogic.getInterfaceOperation(resourceId, interfaceId,
430 Collections.singletonList(operationId), user, true).isLeft());
434 public void getInterfaceOperationTestFailOnException() {
435 when(janusGraphDao.commit()).thenThrow(new RuntimeException());
436 Assert.assertTrue(interfaceOperationBusinessLogic.getInterfaceOperation(resourceId, interfaceId,
437 Collections.singletonList(operationId), user, true).isRight());
441 public void shouldFailWhenLockComponentFailedTest() {
442 when(graphLockOperation.lockComponent(Mockito.anyString(), eq(NodeTypeEnum.Resource)))
443 .thenReturn(StorageOperationStatus.NOT_FOUND);
444 Assert.assertTrue(interfaceOperationBusinessLogic.deleteInterfaceOperation(resourceId, interfaceId,
445 Collections.singletonList(operationId), user, true).isRight());
446 Assert.assertTrue(interfaceOperationBusinessLogic.getInterfaceOperation(resourceId, interfaceId,
447 Collections.singletonList(operationId), user, true).isRight());
448 Assert.assertTrue(interfaceOperationBusinessLogic.createInterfaceOperation(resourceId,
449 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId, operationId, operationName)),
450 user, true).isRight());
454 public void shouldFailWhenGetComponentFailedTest() {
455 when(toscaOperationFacade.getToscaElement(resourceId))
456 .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
457 Assert.assertTrue(interfaceOperationBusinessLogic.deleteInterfaceOperation(resourceId, interfaceId,
458 Collections.singletonList(operationId), user, true).isRight());
459 Assert.assertTrue(interfaceOperationBusinessLogic.getInterfaceOperation(resourceId, interfaceId,
460 Collections.singletonList(operationId), user, true).isRight());
461 Assert.assertTrue(interfaceOperationBusinessLogic.createInterfaceOperation(resourceId,
462 Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId, operationId,
463 operationName)), user, true).isRight());
467 public void testGetAllInterfaceLifecycleTypes_TypesNotFound() {
468 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
469 .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
470 Either<Map<String, InterfaceDefinition>, ResponseFormat> response =
471 interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes();
472 Assert.assertTrue(response.isRight());
476 public void testGetAllInterfaceLifecycleTypes_Success() {
477 InterfaceDefinition interfaceDefinition = new InterfaceDefinition();
478 interfaceDefinition.setUniqueId(interfaceId);
479 interfaceDefinition.setType(interfaceId);
480 Map<String, InterfaceDefinition> interfaceDefinitionMap = new HashMap<>();
481 interfaceDefinitionMap.put(interfaceDefinition.getUniqueId(), interfaceDefinition);
482 when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes())
483 .thenReturn(Either.left(interfaceDefinitionMap));
484 Either<Map<String, InterfaceDefinition>, ResponseFormat> response =
485 interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes();
486 Assert.assertEquals(1, response.left().value().size());