[SECARSP-149] *server side unit tests
[platform/core/security/suspicious-activity-monitor.git] / server / samserver / src / test / java / com / samsung / samserver / service / impl / AnalyzeServiceImplTest.java
1 /*
2  * In Samsung Ukraine R&D Center (SRK under a contract between)
3  * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
4  * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
5  */
6 package com.samsung.samserver.service.impl;
7
8 import com.samsung.samserver.domain.*;
9 import com.samsung.samserver.service.ReportTypeService;
10 import com.samsung.samserver.service.RuleService;
11 import com.samsung.samserver.service.UpdatesService;
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.mockito.InjectMocks;
15 import org.mockito.Mock;
16 import org.mockito.MockitoAnnotations;
17 import org.slf4j.Logger;
18
19 import static org.mockito.Mockito.*;
20
21 /**
22  * Test class for the AnalyzeServiceImpl.
23  *
24  * @see AnalyzeServiceImpl
25  */
26 public class AnalyzeServiceImplTest {
27     @Mock
28     Logger log;
29     @Mock
30     ReportTypeService reportTypeService;
31     @Mock
32     RuleService ruleService;
33     @Mock
34     UpdatesService updatesService;
35     @InjectMocks
36     AnalyzeServiceImpl analyzeServiceImpl;
37
38     @Before
39     public void setUp() {
40         MockitoAnnotations.initMocks(this);
41     }
42
43     @Test
44     public void testAnalyze() throws Exception {
45         when(reportTypeService.findOneWithRules(anyLong())).thenReturn(new ReportType("name", "descr"));
46         when(ruleService.findOneWithActions(anyLong())).thenReturn(new Rule());
47         when(updatesService.save(any())).thenReturn(new Updates("uuid", "type", "uri", null, "descr", "data", new Device()));
48         when(updatesService.getUpdateUID(any(), any())).thenReturn("getUpdateUIDResponse");
49         when(updatesService.find(anyString(), any())).thenReturn(null);
50
51         analyzeServiceImpl.analyze(new Report("data", new ReportType("name", "descr"), new Device()));
52     }
53 }