bc268df756d9c67394b05830bfd9ac6faaceecc9
[aai/sparky-be.git] / src / test / java / org / onap / aai / sparky / synchronizer / SyncControllerTest.java
1 /**\r
2  * ============LICENSE_START=======================================================\r
3  * org.onap.aai\r
4  * ================================================================================\r
5  * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
6  * Copyright © 2017 Amdocs\r
7  * ================================================================================\r
8  * Licensed under the Apache License, Version 2.0 (the "License");\r
9  * you may not use this file except in compliance with the License.\r
10  * You may obtain a copy of the License at\r
11  *\r
12  *       http://www.apache.org/licenses/LICENSE-2.0\r
13  *\r
14  * Unless required by applicable law or agreed to in writing, software\r
15  * distributed under the License is distributed on an "AS IS" BASIS,\r
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
17  * See the License for the specific language governing permissions and\r
18  * limitations under the License.\r
19  * ============LICENSE_END=========================================================\r
20  *\r
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
22  */\r
23 package org.onap.aai.sparky.synchronizer;\r
24 \r
25 import org.junit.Before;\r
26 import org.junit.Test;\r
27 import org.mockito.Mockito;\r
28 import org.onap.aai.sparky.synchronizer.SyncController.SyncActions;\r
29 \r
30 public class SyncControllerTest {\r
31 \r
32   SyncController controller;\r
33 \r
34   @Before\r
35   public void init() throws Exception {\r
36     controller = new SyncController("name-1");\r
37   }\r
38 \r
39   @Test\r
40   public void testPerformAction_PreSync() {\r
41     controller.performAction(SyncActions.SYNCHRONIZE);\r
42     controller.shutdown();\r
43   }\r
44 \r
45   @Test\r
46   public void testRegisterIndexCleaner_NullIndexName() {\r
47     IndexCleaner cleaner =\r
48         new ElasticSearchIndexCleaner(null, null, "index_type-1", "host-1", "port-1", 1, 1);\r
49     controller.registerIndexCleaner(cleaner);\r
50   }\r
51 \r
52   @Test\r
53   public void testRegisterIndexCleaner_NotNullIndexName() {\r
54     IndexCleaner cleaner =\r
55         new ElasticSearchIndexCleaner(null, "index-1", "index_type-1", "host-1", "port-1", 1, 1);\r
56     controller.registerIndexCleaner(cleaner);\r
57   }\r
58 \r
59   @Test\r
60   public void testRegisterIndexValidator_NullIndexValidator() {\r
61     IndexValidator validator =\r
62         new IndexIntegrityValidator(null, null, "index_type-1", "host-1", "port-1", "json-1");\r
63     controller.registerIndexValidator(validator);\r
64   }\r
65 \r
66   @Test\r
67   public void testRegisterIndexValidator_NotNullIndexValidator() {\r
68     IndexValidator validator =\r
69         new IndexIntegrityValidator(null, "index-1", "index_type-1", "host-1", "port-1", "json-1");\r
70     controller.registerIndexValidator(validator);\r
71   }\r
72 \r
73   @Test\r
74   public void testRegisterEntitySynchronizer_NullEntitySynchronizer() throws Exception {\r
75     IndexSynchronizer synchroniser = Mockito.mock(SearchableEntitySynchronizer.class);\r
76     Mockito.when(synchroniser.getIndexName()).thenReturn(null);\r
77     controller.registerEntitySynchronizer(synchroniser);\r
78   }\r
79 \r
80   @Test\r
81   public void testRegisterEntitySynchronizer_NotNullEntitySynchronizer() throws Exception {\r
82     IndexSynchronizer synchroniser = Mockito.mock(SearchableEntitySynchronizer.class);\r
83     Mockito.when(synchroniser.getIndexName()).thenReturn("entity-1");\r
84     controller.registerEntitySynchronizer(synchroniser);\r
85   }\r
86 }\r