aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be
diff options
context:
space:
mode:
authorayalaben <ayala.benzvi@amdocs.com>2018-10-09 13:12:37 +0300
committerayalaben <ayala.benzvi@amdocs.com>2018-10-09 13:12:37 +0300
commit30bcbe8f02ea5fec868d0986c0b5185f8af7a5c7 (patch)
tree3f0e02bad59a77f357ae9f0edac773c3e6e482e9 /openecomp-be
parent52b9a0d5103c000f473b038f1cb524696ab78678 (diff)
Unit test coverage
Change-Id: I9d5dc653ed636cb129106ff0ae12b43993611ddf Issue-ID: SDC-1822 Signed-off-by: ayalaben <ayala.benzvi@amdocs.com>
Diffstat (limited to 'openecomp-be')
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/test/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsServicesImplTest.java38
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/OrchestrationTemplateFileExtensionErrorBuilderTest.java26
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductCreationFailedBuilderTest.java27
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductNotFoundErrorBuilderTest.java27
4 files changed, 109 insertions, 9 deletions
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/test/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsServicesImplTest.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/test/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsServicesImplTest.java
index 0e27dcae4c..9346b0a5a5 100644
--- a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/test/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsServicesImplTest.java
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/test/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsServicesImplTest.java
@@ -48,7 +48,7 @@ public class PermissionsServicesImplTest {
@Mock
private UserPermissionsDao userPermissionsDao; // do not delete. needed for permissionService
@Mock
- private PermissionsRules permissionsRules;
+ private PermissionsRules permissionsRulesMock;
@InjectMocks
@Spy
private PermissionsServicesImpl permissionsServices;
@@ -72,11 +72,11 @@ public class PermissionsServicesImplTest {
@Test
public void testExecute() {
- Mockito.doNothing().when(permissionsRules).executeAction(anyString(), anyString(), anyString());
+ Mockito.doNothing().when(permissionsRulesMock).executeAction(anyString(), anyString(), anyString());
permissionsServices.execute(ITEM1_ID, USER1_ID, PERMISSION);
- Mockito.verify(permissionsRules, times(1)).executeAction(anyString(), anyString(), anyString());
+ Mockito.verify(permissionsRulesMock, times(1)).executeAction(anyString(), anyString(), anyString());
}
@Test
@@ -123,28 +123,48 @@ public class PermissionsServicesImplTest {
@Test
public void testIsAllowed() {
when(permissionsDaoMock.getUserItemPermission(ITEM1_ID, USER1_ID)).thenReturn(Optional.of(PERMISSION));
- when(permissionsRules.isAllowed(PERMISSION, ACTION_SUBMIT)).thenReturn(true);
+ when(permissionsRulesMock.isAllowed(PERMISSION, ACTION_SUBMIT)).thenReturn(true);
boolean result = permissionsServices.isAllowed(ITEM1_ID, USER1_ID, ACTION_SUBMIT);
Assert.assertTrue(result);
- }
+ }
- @Test
- public void testUpdatePermissions() {
+ @Test
+ public void shouldUpdatePermissions(){
Set<String> addedUsers = new HashSet<>();
addedUsers.add(USER2_ID);
permissionsServices.updateItemPermissions(ITEM1_ID, PERMISSION, addedUsers, new HashSet<>());
- verify(permissionsRules).executeAction(ITEM1_ID, USER1_ID, CHANGE_PERMISSIONS);
- verify(permissionsRules).updatePermission(ITEM1_ID, USER1_ID, PERMISSION, addedUsers, new HashSet<>());
+ verify(permissionsRulesMock).executeAction(ITEM1_ID, USER1_ID, CHANGE_PERMISSIONS);
+ verify(permissionsRulesMock).updatePermission(ITEM1_ID, USER1_ID, PERMISSION, addedUsers, new HashSet<>());
verify(permissionsDaoMock).updateItemPermissions(ITEM1_ID, PERMISSION, addedUsers, new
HashSet<>());
}
+ @Test
+ public void shouldExecutePermissionRules(){
+ permissionsServices.execute(ITEM1_ID,USER1_ID,ACTION_SUBMIT);
+ verify(permissionsRulesMock).executeAction(ITEM1_ID,USER1_ID,ACTION_SUBMIT);
+ }
+
+ @Test
+ public void shouldReturnUserItemPermission(){
+ doReturn(Optional.of(PERMISSION)).when(permissionsDaoMock).getUserItemPermission(ITEM1_ID, USER1_ID);
+ Optional<String> actual = permissionsServices.getUserItemPermission(ITEM1_ID, USER1_ID);
+ Assert.assertTrue(actual.isPresent());
+ Assert.assertEquals(actual.get(), PERMISSION);
+ }
+
+ @Test
+ public void shouldDeleteItemPermissions(){
+ permissionsServices.deleteItemPermissions(ITEM1_ID);
+ verify(permissionsDaoMock).deleteItemPermissions(ITEM1_ID);
+ }
+
private static ItemPermissionsEntity createPermissionEntity(String itemId, String
userId, String permission) {
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/OrchestrationTemplateFileExtensionErrorBuilderTest.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/OrchestrationTemplateFileExtensionErrorBuilderTest.java
new file mode 100644
index 0000000000..1e643fa787
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/OrchestrationTemplateFileExtensionErrorBuilderTest.java
@@ -0,0 +1,26 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.errors;
+
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.INVALID_EXTENSION;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.testng.Assert;
+
+public class OrchestrationTemplateFileExtensionErrorBuilderTest {
+
+ private OrchestrationTemplateFileExtensionErrorBuilder orchestrationTemplateFileExtensionErrorBuilder;
+
+ @Before
+ public void setUp() {
+ orchestrationTemplateFileExtensionErrorBuilder = new OrchestrationTemplateFileExtensionErrorBuilder();
+ }
+
+ @Test
+ public void shouldReturnInvalidExtentionErrorCode(){
+ ErrorCode actual = orchestrationTemplateFileExtensionErrorBuilder.build();
+ Assert.assertEquals(actual.category(), ErrorCategory.APPLICATION);
+ Assert.assertEquals(actual.id(), INVALID_EXTENSION);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductCreationFailedBuilderTest.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductCreationFailedBuilderTest.java
new file mode 100644
index 0000000000..921881d322
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductCreationFailedBuilderTest.java
@@ -0,0 +1,27 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.errors;
+
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.FAILED_TO_CREATE_VSP;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.testng.Assert;
+
+public class VendorSoftwareProductCreationFailedBuilderTest {
+
+ private static final String VSP_ID = "testVsp1";
+ private VendorSoftwareProductCreationFailedBuilder vendorSoftwareProductCreationFailedBuilder;
+
+ @Before
+ public void setUp() {
+ vendorSoftwareProductCreationFailedBuilder = new VendorSoftwareProductCreationFailedBuilder(VSP_ID);
+ }
+
+ @Test
+ public void shouldReturnVspNotFoundErrorCode(){
+ ErrorCode actual = vendorSoftwareProductCreationFailedBuilder.build();
+ Assert.assertEquals(actual.category(), ErrorCategory.APPLICATION);
+ Assert.assertEquals(actual.id(), FAILED_TO_CREATE_VSP);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductNotFoundErrorBuilderTest.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductNotFoundErrorBuilderTest.java
new file mode 100644
index 0000000000..75e6b1f6df
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductNotFoundErrorBuilderTest.java
@@ -0,0 +1,27 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.errors;
+
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.VSP_NOT_FOUND;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.testng.Assert;
+
+public class VendorSoftwareProductNotFoundErrorBuilderTest {
+
+ private static final String VSP_ID = "testVsp1";
+ private VendorSoftwareProductNotFoundErrorBuilder vendorSoftwareProductNotFoundErrorBuilder;
+
+ @Before
+ public void setUp() {
+ vendorSoftwareProductNotFoundErrorBuilder = new VendorSoftwareProductNotFoundErrorBuilder(VSP_ID);
+ }
+
+ @Test
+ public void shouldReturnVspNotFoundErrorCode(){
+ ErrorCode actual = vendorSoftwareProductNotFoundErrorBuilder.build();
+ Assert.assertEquals(actual.category(), ErrorCategory.APPLICATION);
+ Assert.assertEquals(actual.id(), VSP_NOT_FOUND);
+ }
+}