import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
when(nodeFilterValidator
.validateFilter(resource, componentInstanceId,
requirementNodeFilterPropertyDataDefinition.getConstraints(),
- NodeFilterConstraintAction.ADD, NodeFilterConstraintType.PROPERTIES)).thenReturn(Either.left(true));
+ NodeFilterConstraintAction.ADD, NodeFilterConstraintType.PROPERTIES, "")).thenReturn(Either.left(true));
when(nodeFilterValidator.validateComponentInstanceExist(resource, componentInstanceId))
.thenReturn(Either.left(true));
when(graphLockOperation.lockComponent(componentId, NodeTypeEnum.Resource))
final Optional<CINodeFilterDataDefinition> result = componentNodeFilterBusinessLogic
.addNodeFilter(componentId, componentInstanceId, NodeFilterConstraintAction.ADD,
"MyPropertyName", constraint, true, ComponentTypeEnum.RESOURCE,
- NodeFilterConstraintType.PROPERTIES, capabilityName);
+ NodeFilterConstraintType.PROPERTIES, "");
assertThat(result).isPresent();
assertThat(result.get().getProperties().getListToscaDataDefinition()).hasSize(1);
verify(toscaOperationFacade, times(1)).getToscaElement(componentId);
verify(nodeFilterValidator, times(1)).validateFilter(resource, componentInstanceId,
- Collections.singletonList(constraint), NodeFilterConstraintAction.ADD, NodeFilterConstraintType.PROPERTIES);
+ Collections.singletonList(constraint), NodeFilterConstraintAction.ADD, NodeFilterConstraintType.PROPERTIES, "");
verify(graphLockOperation, times(1)).lockComponent(componentId, NodeTypeEnum.Resource);
verify(nodeFilterOperation, times(1))
.addNewProperty(anyString(), anyString(), any(CINodeFilterDataDefinition.class),
when(nodeFilterValidator
.validateFilter(resource, componentInstanceId,
requirementNodeFilterPropertyDataDefinition.getConstraints(),
- NodeFilterConstraintAction.ADD, NodeFilterConstraintType.CAPABILITIES)).thenReturn(Either.left(true));
+ NodeFilterConstraintAction.ADD, NodeFilterConstraintType.CAPABILITIES, capabilityName)).thenReturn(Either.left(true));
when(nodeFilterValidator.validateComponentInstanceExist(resource, componentInstanceId))
.thenReturn(Either.left(true));
when(graphLockOperation.lockComponent(componentId, NodeTypeEnum.Resource))
assertThat(result.get().getProperties().getListToscaDataDefinition()).hasSize(1);
verify(toscaOperationFacade, times(1)).getToscaElement(componentId);
verify(nodeFilterValidator, times(1)).validateFilter(resource, componentInstanceId,
- Collections.singletonList(constraint), NodeFilterConstraintAction.ADD, NodeFilterConstraintType.CAPABILITIES);
+ Collections.singletonList(constraint), NodeFilterConstraintAction.ADD, NodeFilterConstraintType.CAPABILITIES, capabilityName);
verify(graphLockOperation, times(1)).lockComponent(componentId, NodeTypeEnum.Resource);
verify(nodeFilterOperation, times(1))
.addNewCapabilities(anyString(), anyString(), any(CINodeFilterDataDefinition.class),
when(nodeFilterValidator
.validateFilter(resource, componentInstanceId,
requirementNodeFilterPropertyDataDefinition.getConstraints(),
- NodeFilterConstraintAction.ADD, NodeFilterConstraintType.PROPERTIES)).thenReturn(Either.left(true));
+ NodeFilterConstraintAction.ADD, NodeFilterConstraintType.PROPERTIES, capabilityName)).thenReturn(Either.left(true));
when(nodeFilterValidator.validateComponentInstanceExist(resource, componentInstanceId))
.thenReturn(Either.left(true));
when(graphLockOperation.lockComponent(componentId, NodeTypeEnum.Resource))
verify(toscaOperationFacade, times(1)).getToscaElement(componentId);
verify(graphLockOperation, times(1)).lockComponent(componentId, NodeTypeEnum.Resource);
verify(nodeFilterValidator, times(1)).validateFilter(resource, componentInstanceId,
- constraints, NodeFilterConstraintAction.ADD, NodeFilterConstraintType.PROPERTIES);
+ constraints, NodeFilterConstraintAction.ADD, NodeFilterConstraintType.PROPERTIES, capabilityName);
verify(nodeFilterOperation, times(0))
.addNewProperty(componentId, componentInstanceId, ciNodeFilterDataDefinition,
requirementNodeFilterPropertyDataDefinition);
when(nodeFilterValidator.validateComponentInstanceExist(resource, componentInstanceId))
.thenReturn(Either.left(true));
when(nodeFilterValidator.validateFilter(resource, componentInstanceId, singletonList(constraint),
- NodeFilterConstraintAction.DELETE, NodeFilterConstraintType.PROPERTIES)).thenReturn(Either.left(true));
+ NodeFilterConstraintAction.DELETE, NodeFilterConstraintType.PROPERTIES, "")).thenReturn(Either.left(true));
when(graphLockOperation.lockComponent(componentId, NodeTypeEnum.Resource))
.thenReturn(StorageOperationStatus.OK);
.validateComponentInstanceExist(resource, componentInstanceId);
verify(nodeFilterValidator, times(1))
.validateFilter(resource, componentInstanceId, singletonList(constraint),
- NodeFilterConstraintAction.DELETE, NodeFilterConstraintType.PROPERTIES);
+ NodeFilterConstraintAction.DELETE, NodeFilterConstraintType.PROPERTIES, "");
verify(nodeFilterOperation, times(1))
.deleteConstraint(componentId, componentInstanceId, ciNodeFilterDataDefinition, 0,
NodeFilterConstraintType.PROPERTIES);
when(nodeFilterValidator.validateComponentInstanceExist(resource, componentInstanceId))
.thenReturn(Either.left(true));
when(nodeFilterValidator.validateFilter(resource, componentInstanceId, singletonList(constraint),
- NodeFilterConstraintAction.DELETE, NodeFilterConstraintType.PROPERTIES)).thenReturn(Either.left(true));
+ NodeFilterConstraintAction.DELETE, NodeFilterConstraintType.PROPERTIES, "")).thenReturn(Either.left(true));
when(graphLockOperation.lockComponent(componentId, NodeTypeEnum.Resource))
.thenReturn(StorageOperationStatus.OK);
verify(graphLockOperation, times(1)).lockComponent(componentId, NodeTypeEnum.Resource);
verify(nodeFilterValidator, times(1))
.validateFilter(resource, componentInstanceId, singletonList(constraint),
- NodeFilterConstraintAction.DELETE, NodeFilterConstraintType.PROPERTIES);
+ NodeFilterConstraintAction.DELETE, NodeFilterConstraintType.PROPERTIES, "");
verify(nodeFilterValidator, times(1))
.validateComponentInstanceExist(resource, componentInstanceId);
verify(graphLockOperation, times(1)).unlockComponent(componentId, NodeTypeEnum.Resource);
when(nodeFilterValidator.validateComponentInstanceExist(resource, componentInstanceId))
.thenReturn(Either.left(true));
when(nodeFilterValidator.validateFilter(resource, componentInstanceId, singletonList(constraint),
- NodeFilterConstraintAction.DELETE, NodeFilterConstraintType.PROPERTIES)).thenReturn(Either.left(true));
+ NodeFilterConstraintAction.DELETE, NodeFilterConstraintType.PROPERTIES, "")).thenReturn(Either.left(true));
assertThrows(BusinessLogicException.class, () -> componentNodeFilterBusinessLogic
.deleteNodeFilter(componentId, componentInstanceId, NodeFilterConstraintAction.DELETE, constraint,
verify(toscaOperationFacade, times(1)).getToscaElement(componentId);
verify(nodeFilterValidator, times(1))
.validateFilter(resource, componentInstanceId, singletonList(constraint),
- NodeFilterConstraintAction.DELETE, NodeFilterConstraintType.PROPERTIES);
+ NodeFilterConstraintAction.DELETE, NodeFilterConstraintType.PROPERTIES, "");
verify(nodeFilterValidator, times(1))
.validateComponentInstanceExist(resource, componentInstanceId);
}
when(nodeFilterValidator
.validateFilter(ArgumentMatchers.any(Component.class), anyString(), anyList(),
ArgumentMatchers.any(NodeFilterConstraintAction.class),
- ArgumentMatchers.any(NodeFilterConstraintType.class))).thenReturn(Either.left(true));
+ ArgumentMatchers.any(NodeFilterConstraintType.class), anyString())).thenReturn(Either.left(true));
+
+ when(nodeFilterValidator
+ .validateFilter(ArgumentMatchers.any(Component.class), anyString(), anyList(),
+ ArgumentMatchers.any(NodeFilterConstraintAction.class),
+ ArgumentMatchers.any(NodeFilterConstraintType.class), isNull())).thenReturn(Either.left(true));
when(graphLockOperation.lockComponent(componentId, NodeTypeEnum.Resource))
.thenReturn(StorageOperationStatus.OK);
}
@Test
- public void updateNodeFilterFailTest() {
+ public void updateNodeFilterFailTest() throws BusinessLogicException {
componentInstance.setNodeFilter(ciNodeFilterDataDefinition);
when(toscaOperationFacade.getToscaElement(componentId)).thenReturn(Either.left(resource));
when(nodeFilterValidator.validateComponentInstanceExist(resource, componentInstanceId))
.thenReturn(Either.left(true));
+ when(nodeFilterValidator
+ .validateFilter(ArgumentMatchers.any(Component.class), anyString(), anyList(),
+ ArgumentMatchers.any(NodeFilterConstraintAction.class),
+ ArgumentMatchers.any(NodeFilterConstraintType.class), anyString())).thenReturn(Either.left(true));
when(nodeFilterValidator
.validateFilter(ArgumentMatchers.any(Component.class), anyString(), anyList(),
ArgumentMatchers.any(NodeFilterConstraintAction.class),
- ArgumentMatchers.any(NodeFilterConstraintType.class))).thenReturn(Either.left(true));
+ ArgumentMatchers.any(NodeFilterConstraintType.class), isNull())).thenReturn(Either.left(true));
when(graphLockOperation.lockComponent(componentId, NodeTypeEnum.Resource))
.thenReturn(StorageOperationStatus.OK);
.thenReturn(StorageOperationStatus.OK);
assertThrows(BusinessLogicException.class, () -> componentNodeFilterBusinessLogic
- .updateNodeFilter(componentId, componentInstanceId, uiConstraint, ComponentTypeEnum.RESOURCE,
+ .updateNodeFilter(componentId, componentInstanceId, uiConstraint, ComponentTypeEnum.RESOURCE,
NodeFilterConstraintType.PROPERTIES, 0));
}
when(nodeFilterValidator
.validateFilter(ArgumentMatchers.any(Component.class), anyString(), anyList(),
ArgumentMatchers.any(NodeFilterConstraintAction.class),
- ArgumentMatchers.any(NodeFilterConstraintType.class))).thenReturn(Either.left(true));
+ ArgumentMatchers.any(NodeFilterConstraintType.class), anyString())).thenReturn(Either.left(true));
assertThrows(BusinessLogicException.class, () -> componentNodeFilterBusinessLogic
.updateNodeFilter(componentId, componentInstanceId, uiConstraint, ComponentTypeEnum.RESOURCE,