package org.openecomp.sdc.be.components.validation;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import fj.data.Either;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
import org.junit.Assert;
-
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.openecomp.sdc.common.impl.FSConfigurationSource;
import org.openecomp.sdc.exception.ResponseFormat;
-import java.util.*;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-
public class NodeFilterValidationTest {
- private static final String UI_CONSTRAINT_STATIC = "Prop1: {equal: 'value'}";
+ private static final String EMPTY_STR = "";
+ private static final String UI_CONSTRAINT_STATIC = "Prop1: {equal: 'value'}";
private static final String INNER_SERVICE = "innerService";
private static final String PROPERTY_NAME = "Prop1";
private static final String VALUE = "value";
@BeforeEach
public void setup() {
componentsUtils = Mockito.mock(ComponentsUtils.class);
- MockitoAnnotations.initMocks(this);
+ MockitoAnnotations.openMocks(this);
new ConfigurationManager(new FSConfigurationSource(ExternalConfiguration.getChangeListener(), "src/test/resources/config/catalog-be"));
}
Either<Boolean, ResponseFormat> either =
nodeFilterValidator.validateFilter(service, INNER_SERVICE,
Collections.singletonList(UI_CONSTRAINT_STATIC.replace(VALUE, "true")),
- NodeFilterConstraintAction.ADD, NodeFilterConstraintType.PROPERTIES);
+ NodeFilterConstraintAction.ADD, NodeFilterConstraintType.PROPERTIES, EMPTY_STR);
assertTrue(either.isRight());
either =
nodeFilterValidator.validateFilter(service, INNER_SERVICE,
Collections.singletonList(UI_CONSTRAINT_STATIC.replace(VALUE, "true")),
- NodeFilterConstraintAction.ADD, NodeFilterConstraintType.CAPABILITIES);
+ NodeFilterConstraintAction.ADD, NodeFilterConstraintType.CAPABILITIES, EMPTY_STR);
assertTrue(either.isRight());
}
nodeFilterValidator.validateFilter(service, INNER_SERVICE,
Collections.singletonList(UI_CONSTRAINT_STATIC.replace(VALUE, "true")
.replace("equal", "greater_than")),
- NodeFilterConstraintAction.ADD, NodeFilterConstraintType.PROPERTIES);
+ NodeFilterConstraintAction.ADD, NodeFilterConstraintType.PROPERTIES, EMPTY_STR);
Assert.assertFalse(either.isLeft());
}
Either<Boolean, ResponseFormat> either =
nodeFilterValidator.validateFilter(service, INNER_SERVICE,
Collections.singletonList(UI_CONSTRAINT_STATIC.replace(VALUE, "trues")),
- NodeFilterConstraintAction.ADD, NodeFilterConstraintType.PROPERTIES);
+ NodeFilterConstraintAction.ADD, NodeFilterConstraintType.PROPERTIES, EMPTY_STR);
Assert.assertFalse(either.isLeft());
}
nodeFilterValidator.validateFilter(service, INNER_SERVICE,
Collections.singletonList(UI_CONSTRAINT_STATIC.replace(VALUE, "true")
.replace("equal", "greater_than")),
- NodeFilterConstraintAction.ADD, NodeFilterConstraintType.PROPERTIES);
+ NodeFilterConstraintAction.ADD, NodeFilterConstraintType.PROPERTIES, EMPTY_STR);
Assert.assertTrue(either.isLeft());
}
Either<Boolean, ResponseFormat> either =
nodeFilterValidator.validateFilter(service, INNER_SERVICE,
Collections.singletonList(UI_CONSTRAINT_STATIC.replace(VALUE, "1")),
- NodeFilterConstraintAction.ADD, NodeFilterConstraintType.PROPERTIES);
+ NodeFilterConstraintAction.ADD, NodeFilterConstraintType.PROPERTIES, EMPTY_STR);
Assert.assertTrue(either.isLeft());
}
Either<Boolean, ResponseFormat> either =
nodeFilterValidator.validateFilter(service, INNER_SERVICE,
Collections.singletonList(UI_CONSTRAINT_STATIC.replace(VALUE, "1.0")),
- NodeFilterConstraintAction.ADD, NodeFilterConstraintType.PROPERTIES);
+ NodeFilterConstraintAction.ADD, NodeFilterConstraintType.PROPERTIES, EMPTY_STR);
Assert.assertTrue(either.isRight());
}
Either<Boolean, ResponseFormat> either =
nodeFilterValidator.validateFilter(service, INNER_SERVICE,
Collections.singletonList(UI_CONSTRAINT_STATIC.replace(VALUE, "1.0")),
- NodeFilterConstraintAction.ADD, NodeFilterConstraintType.PROPERTIES);
+ NodeFilterConstraintAction.ADD, NodeFilterConstraintType.PROPERTIES, EMPTY_STR);
Assert.assertTrue(either.isLeft());
}
Either<Boolean, ResponseFormat> either =
nodeFilterValidator.validateFilter(service, INNER_SERVICE,
Collections.singletonList(UI_CONSTRAINT_STATIC), NodeFilterConstraintAction.ADD,
- NodeFilterConstraintType.PROPERTIES);
+ NodeFilterConstraintType.PROPERTIES, EMPTY_STR);
Assert.assertTrue(either.isRight());
}
Either<Boolean, ResponseFormat> either =
nodeFilterValidator.validateFilter(service, INNER_SERVICE,
Collections.singletonList(UI_CONSTRAINT_STATIC), NodeFilterConstraintAction.ADD,
- NodeFilterConstraintType.PROPERTIES);
+ NodeFilterConstraintType.PROPERTIES, EMPTY_STR);
Assert.assertTrue(either.isLeft());
}
Either<Boolean, ResponseFormat> either =
nodeFilterValidator.validateFilter(service, COMPONENT1_ID, Collections.singletonList("Prop1:\n"
+ " equal: { get_property :[component2, Prop1]}\n"), NodeFilterConstraintAction.ADD,
- NodeFilterConstraintType.PROPERTIES);
+ NodeFilterConstraintType.PROPERTIES, EMPTY_STR);
Assert.assertTrue(either.isLeft());
}
Service service = createService(STRING_TYPE);
Either<Boolean, ResponseFormat> either =
nodeFilterValidator.validateFilter(service, COMPONENT1_ID, Collections.singletonList("Prop1:\n"
- + " equal: { get_property : [parentservice, Prop1]}\n"), NodeFilterConstraintAction.ADD,
- NodeFilterConstraintType.PROPERTIES);
+ + " equal: { get_property : [SELF, Prop1]}\n"), NodeFilterConstraintAction.ADD,
+ NodeFilterConstraintType.PROPERTIES, EMPTY_STR);
Assert.assertTrue(either.isLeft());
}
Either<Boolean, ResponseFormat> either =
nodeFilterValidator.validateFilter(service, COMPONENT1_ID, Collections.singletonList("Prop1:\n"
+ " equal: { get_property : [component2, Prop1]}\n"), NodeFilterConstraintAction.ADD,
- NodeFilterConstraintType.PROPERTIES);
+ NodeFilterConstraintType.PROPERTIES, EMPTY_STR);
Assert.assertFalse(either.isLeft());
}
Either<Boolean, ResponseFormat> either =
nodeFilterValidator.validateFilter(service, COMPONENT1_ID, Collections.singletonList("Prop1:\n"
+ " equal: { get_property : [parentservice, Prop1]}\n"), NodeFilterConstraintAction.ADD,
- NodeFilterConstraintType.PROPERTIES);
+ NodeFilterConstraintType.PROPERTIES, EMPTY_STR);
Assert.assertFalse(either.isLeft());
}
Either<Boolean, ResponseFormat> either =
nodeFilterValidator.validateFilter(service, COMPONENT1_ID, Collections.singletonList("Prop1:\n"
+ " equal: { get_property : [parentservice, Prop1]}\n"), NodeFilterConstraintAction.ADD,
- NodeFilterConstraintType.PROPERTIES);
+ NodeFilterConstraintType.PROPERTIES, EMPTY_STR);
Assert.assertFalse(either.isLeft());
}
Either<Boolean, ResponseFormat> either =
nodeFilterValidator.validateFilter(service, COMPONENT1_ID, Collections.singletonList("Prop1:\n"
+ " equal: { get_property : [parentservice, Prop1]}\n"), NodeFilterConstraintAction.ADD,
- NodeFilterConstraintType.PROPERTIES);
+ NodeFilterConstraintType.PROPERTIES, EMPTY_STR);
Assert.assertFalse(either.isLeft());
}
Either<Boolean, ResponseFormat> either =
nodeFilterValidator.validateFilter(service, COMPONENT1_ID, Collections.singletonList("Prop1:\n"
+ " equal: { get_property : [parentservice, Prop1]}\n"), NodeFilterConstraintAction.ADD,
- NodeFilterConstraintType.PROPERTIES);
+ NodeFilterConstraintType.PROPERTIES, EMPTY_STR);
Assert.assertFalse(either.isLeft());
}