PersUserWidgetServiceAOP and tests up
[portal.git] / portal-BE / src / test / java / org / onap / portal / service / PersUserWidgetServiceTest.java
diff --git a/portal-BE/src/test/java/org/onap/portal/service/PersUserWidgetServiceTest.java b/portal-BE/src/test/java/org/onap/portal/service/PersUserWidgetServiceTest.java
new file mode 100644 (file)
index 0000000..3595205
--- /dev/null
@@ -0,0 +1,48 @@
+package org.onap.portal.service;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import javax.transaction.Transactional;
+import org.junit.jupiter.api.Test;
+import org.junit.runner.RunWith;
+import org.onap.portal.domain.dto.transport.WidgetCatalogPersonalization;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+@Transactional
+@TestPropertySource(locations = "classpath:test.properties")
+class PersUserWidgetServiceTest {
+
+    @Autowired
+    private PersUserWidgetService persUserWidgetService;
+
+    @Test
+    void setPersUserAppValueInvalidWidgetIdDataTest() {
+        WidgetCatalogPersonalization catalog = getWidgetCatalog();
+        catalog.setSelect(true);
+        try {
+            persUserWidgetService.setPersUserAppValue(1, catalog);
+        }catch (IllegalArgumentException e){
+            assertEquals("widgetId may not be null", e.getMessage());
+        }
+    }
+
+    @Test
+    void setPersUserAppValueInvalidSelectDataTest() {
+        WidgetCatalogPersonalization catalog = getWidgetCatalog();
+        catalog.setWidgetId(1L);
+        try {
+            persUserWidgetService.setPersUserAppValue(1, catalog);
+        }catch (IllegalArgumentException e){
+            assertEquals("select may not be null", e.getMessage());
+        }
+    }
+
+    private WidgetCatalogPersonalization getWidgetCatalog(){
+        return new WidgetCatalogPersonalization();
+    }
+}