2 * ============LICENSE_START=======================================================
\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
12 * http://www.apache.org/licenses/LICENSE-2.0
\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
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
23 package org.onap.aai.sparky.synchronizer;
\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
30 public class SyncControllerTest {
\r
32 SyncController controller;
\r
35 public void init() throws Exception {
\r
36 controller = new SyncController("name-1");
\r
40 public void testPerformAction_PreSync() {
\r
41 controller.performAction(SyncActions.SYNCHRONIZE);
\r
42 controller.shutdown();
\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
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
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
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
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
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