summaryrefslogtreecommitdiffstats
path: root/portal-BE/src/test/java/org/onap/portal/service/PersUserWidgetServiceTest.java
blob: 35952053f7b47675161c079215bd14ec054314f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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();
    }
}