aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/CapabilityFilter.java28
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/NodeFilter.java35
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/user/UserMessage.java46
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/facade/operations/CatalogOperationTest.java76
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/CapabilityFilterTest.java64
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/NodeFilterTest.java39
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/user/UserMessageTest.java59
7 files changed, 261 insertions, 86 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/CapabilityFilter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/CapabilityFilter.java
index 8afd9518ba..0197c3dabe 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/CapabilityFilter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/CapabilityFilter.java
@@ -16,40 +16,26 @@
package org.openecomp.sdc.be.tosca.model;
-
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
import org.apache.commons.collections.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-
-
+@Getter
+@Setter
+@ToString
public class CapabilityFilter {
- List<Map<String, List<Object>>> properties;
-
- public List<Map<String, List<Object>>> getProperties() {
- return properties;
- }
-
- public void setProperties(List<Map<String, List<Object>>> properties) {
- this.properties = properties;
- }
+ private List<Map<String, List<Object>>> properties;
public void addProperty(Map<String, List<Object>> property) {
if(CollectionUtils.isEmpty(properties)) {
this.properties = new ArrayList<>();
}
-
this.properties.add(property);
}
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder("CapabilityFilter{");
- sb.append("properties=").append(properties);
- sb.append('}');
- return sb.toString();
- }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/NodeFilter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/NodeFilter.java
index 79e9f57209..f5511edd1b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/NodeFilter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/NodeFilter.java
@@ -17,34 +17,13 @@ package org.openecomp.sdc.be.tosca.model;
import java.util.List;
import java.util.Map;
+import lombok.Getter;
+import lombok.Setter;
+@Getter
+@Setter
public class NodeFilter {
-
- Object tosca_id;
- List<Map<String, List<Object>>> properties;
- List<Map<String, CapabilityFilter>> capabilities;
-
- public Object getTosca_id() {
- return tosca_id;
- }
-
- public void setTosca_id(Object tosca_id) {
- this.tosca_id = tosca_id;
- }
-
- public List<Map<String, CapabilityFilter>> getCapabilities() {
- return capabilities;
- }
-
- public void setCapabilities(List<Map<String, CapabilityFilter>> capabilities) {
- this.capabilities = capabilities;
- }
-
- public List<Map<String, List<Object>>> getProperties() {
- return properties;
- }
-
- public void setProperties(List<Map<String, List<Object>>> properties) {
- this.properties = properties;
- }
+ private Object tosca_id;
+ private List<Map<String, List<Object>>> properties;
+ private List<Map<String, CapabilityFilter>> capabilities;
} \ No newline at end of file
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/user/UserMessage.java b/catalog-be/src/main/java/org/openecomp/sdc/be/user/UserMessage.java
index 362bf34592..73943f6c4e 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/user/UserMessage.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/user/UserMessage.java
@@ -20,51 +20,23 @@
package org.openecomp.sdc.be.user;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
import org.openecomp.sdc.be.catalog.api.ITypeMessage;
-public class UserMessage implements ITypeMessage{
+@Getter
+@Setter
+@AllArgsConstructor
+@ToString
+public class UserMessage implements ITypeMessage {
private UserOperationEnum operation;
private String userId;
private String role;
- public UserMessage(UserOperationEnum operation, String userId, String role) {
- this.setOperation(operation);
- this.setUserId(userId);
- this.setRole(role);
- }
-
- public UserOperationEnum getOperation() {
- return operation;
- }
-
- public void setOperation(UserOperationEnum operation) {
- this.operation = operation;
- }
-
- public String getUserId() {
- return userId;
- }
-
- public void setUserId(String userId) {
- this.userId = userId;
- }
-
- public String getRole() {
- return role;
- }
-
- public void setRole(String role) {
- this.role = role;
- }
-
- @Override
- public String toString() {
- return "UserMessage [operation=" + operation + ", userId=" + userId + ", role=" + role + "]";
- }
-
@Override
public String getMessageType() {
return getClass().getSimpleName();
}
-
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/facade/operations/CatalogOperationTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/facade/operations/CatalogOperationTest.java
new file mode 100644
index 0000000000..68cc4e764b
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/facade/operations/CatalogOperationTest.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020 Samsung Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.facade.operations;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.openecomp.sdc.be.catalog.api.IStatus;
+import org.openecomp.sdc.be.catalog.enums.ChangeTypeEnum;
+import org.openecomp.sdc.be.catalog.impl.ComponentMessage;
+import org.openecomp.sdc.be.catalog.impl.DmaapProducer;
+import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
+import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.Resource;
+
+@RunWith(MockitoJUnitRunner.class)
+public class CatalogOperationTest {
+ @Mock
+ private DmaapProducer msProducer;
+ @Mock
+ private Resource component;
+ @Captor
+ private ArgumentCaptor<ComponentMessage> messageCaptor;
+
+ private CatalogOperation catalogOperation;
+
+ @Before
+ public void setUp() {
+ catalogOperation = new CatalogOperation(msProducer);
+ }
+
+ @Test
+ public void updateCatalogTest() {
+ when(component.getLifecycleState()).thenReturn(LifecycleStateEnum.CERTIFIED);
+ when(component.getResourceType()).thenReturn(ResourceTypeEnum.ABSTRACT);
+ when(component.getLastUpdateDate()).thenReturn(System.currentTimeMillis());
+ when(component.getLastUpdaterUserId()).thenReturn("mock-id");
+ when(component.getCategories()).thenReturn(null);
+ when(msProducer.pushMessage(any(ComponentMessage.class))).thenReturn(IStatus.getSuccessStatus());
+
+ catalogOperation.updateCatalog(ChangeTypeEnum.LIFECYCLE, component);
+
+ Mockito.verify(msProducer).pushMessage(messageCaptor.capture());
+ ComponentMessage message = messageCaptor.getValue();
+ assertThat(message.getChangeType()).isEqualTo(ChangeTypeEnum.LIFECYCLE);
+ assertThat(message.getResourceType()).isEqualTo(ResourceTypeEnum.ABSTRACT.name());
+ assertThat(message.getLifecycleState()).isEqualTo(LifecycleStateEnum.CERTIFIED.name());
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/CapabilityFilterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/CapabilityFilterTest.java
new file mode 100644
index 0000000000..5d221f81f0
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/CapabilityFilterTest.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020 Samsung Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.tosca.model;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.junit.Test;
+
+public class CapabilityFilterTest {
+ private CapabilityFilter createCapabilityFilter() {
+ return new CapabilityFilter();
+ }
+
+ private Map<String, List<Object>> createProperty() {
+ Map<String, List<Object>> property = new HashMap<>();
+ List<Object> mockValue = new ArrayList<>();
+ mockValue.add("mock-value-0");
+ property.put("mock-key", mockValue);
+ return property;
+ }
+
+ @Test
+ public void testDefaultCtor() {
+ assertThat(CapabilityFilter.class, hasValidBeanConstructor());
+ }
+
+ @Test
+ public void testGettersSetters() {
+ assertThat(CapabilityFilter.class, hasValidGettersAndSetters());
+ }
+
+ @Test
+ public void testAddProperty() {
+ CapabilityFilter capabilityFilter = createCapabilityFilter();
+ Map<String, List<Object>> property = createProperty();
+ capabilityFilter.addProperty(property);
+ assertThat(capabilityFilter.getProperties(), hasItem(property));
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/NodeFilterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/NodeFilterTest.java
new file mode 100644
index 0000000000..72fcf5f2dc
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/NodeFilterTest.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020 Samsung Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.tosca.model;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import org.junit.Test;
+
+public class NodeFilterTest {
+ @Test
+ public void testDefaultCtor() {
+ assertThat(NodeFilter.class, hasValidBeanConstructor());
+ }
+
+ @Test
+ public void testGettersSetters() {
+ assertThat(NodeFilter.class, hasValidGettersAndSetters());
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/user/UserMessageTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/user/UserMessageTest.java
new file mode 100644
index 0000000000..2e9f86dd59
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/user/UserMessageTest.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020 Samsung Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.user;
+
+import static com.google.code.beanmatchers.BeanMatchers.isABeanWithValidGettersAndSettersExcluding;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.isA;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import org.junit.Test;
+
+public class UserMessageTest {
+ private static final UserOperationEnum USER_OPERATION = UserOperationEnum.CREATE;
+ private static final String USER_ID = "mock-user";
+ private static final String ROLE = "mock-role";
+
+ private UserMessage createUserMessage() {
+ return new UserMessage(USER_OPERATION, USER_ID, ROLE);
+ }
+
+ @Test
+ public void testCtor() {
+ UserMessage userMessage = createUserMessage();
+ assertThat(userMessage, isA(UserMessage.class));
+ assertThat(userMessage.getOperation(), is(USER_OPERATION));
+ assertThat(userMessage.getUserId(), is(USER_ID));
+ assertThat(userMessage.getRole(), is(ROLE));
+ }
+
+ @Test
+ public void testGettersSetters() {
+ UserMessage userMessage = createUserMessage();
+ assertThat(userMessage, isABeanWithValidGettersAndSettersExcluding("messageType"));
+ }
+
+ @Test
+ public void testGetMessageType() {
+ UserMessage userMessage = createUserMessage();
+ assertThat(userMessage.getMessageType(), is(UserMessage.class.getSimpleName()));
+ }
+} \ No newline at end of file