PersUserWidgetServiceAOP and tests up
[portal.git] / portal-BE / src / test / java / org / onap / portal / service / PersUserWidgetServiceTest.java
1 package org.onap.portal.service;
2
3 import static org.junit.jupiter.api.Assertions.*;
4
5 import javax.transaction.Transactional;
6 import org.junit.jupiter.api.Test;
7 import org.junit.runner.RunWith;
8 import org.onap.portal.domain.dto.transport.WidgetCatalogPersonalization;
9 import org.springframework.beans.factory.annotation.Autowired;
10 import org.springframework.boot.test.context.SpringBootTest;
11 import org.springframework.test.context.TestPropertySource;
12 import org.springframework.test.context.junit4.SpringRunner;
13
14 @RunWith(SpringRunner.class)
15 @SpringBootTest
16 @Transactional
17 @TestPropertySource(locations = "classpath:test.properties")
18 class PersUserWidgetServiceTest {
19
20     @Autowired
21     private PersUserWidgetService persUserWidgetService;
22
23     @Test
24     void setPersUserAppValueInvalidWidgetIdDataTest() {
25         WidgetCatalogPersonalization catalog = getWidgetCatalog();
26         catalog.setSelect(true);
27         try {
28             persUserWidgetService.setPersUserAppValue(1, catalog);
29         }catch (IllegalArgumentException e){
30             assertEquals("widgetId may not be null", e.getMessage());
31         }
32     }
33
34     @Test
35     void setPersUserAppValueInvalidSelectDataTest() {
36         WidgetCatalogPersonalization catalog = getWidgetCatalog();
37         catalog.setWidgetId(1L);
38         try {
39             persUserWidgetService.setPersUserAppValue(1, catalog);
40         }catch (IllegalArgumentException e){
41             assertEquals("select may not be null", e.getMessage());
42         }
43     }
44
45     private WidgetCatalogPersonalization getWidgetCatalog(){
46         return new WidgetCatalogPersonalization();
47     }
48 }