42db5c9fffccdc7c0e218b4f971a2707f1d471a7
[aai/sparky-be.git] / src / test / java / org / onap / aai / sparky / synchronizer / IndexDocumentTest.java
1 /**
2  * ============LICENSE_START===================================================
3  * SPARKY (AAI UI service)
4  * ============================================================================
5  * Copyright © 2017 AT&T Intellectual Property.
6  * Copyright © 2017 Amdocs
7  * All rights reserved.
8  * ============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=====================================================
21  *
22  * ECOMP and OpenECOMP are trademarks
23  * and service marks of AT&T Intellectual Property.
24  */
25
26 package org.onap.aai.sparky.synchronizer;
27
28 import java.io.IOException;
29 import java.security.NoSuchAlgorithmException;
30
31 import org.junit.Before;
32 import org.junit.Test;
33 import org.junit.runner.RunWith;
34 import org.mockito.runners.MockitoJUnitRunner;
35 import org.onap.aai.sparky.util.LogValidator;
36
37 import ch.qos.logback.classic.Level;
38
39
40 /**
41  * The Class IndexDocumentTest.
42  */
43 @RunWith(MockitoJUnitRunner.class)
44 public class IndexDocumentTest {
45
46   private LogValidator logValidator;
47
48
49   /**
50    * Inits the.
51    *
52    * @throws Exception the exception
53    */
54   @Before
55   public void init() throws Exception {
56     logValidator = new LogValidator();
57     logValidator.initializeLogger(Level.WARN);
58   }
59
60   /**
61    * Validate basic construction.
62    *
63    * @throws NoSuchAlgorithmException the no such algorithm exception
64    * @throws IOException Signals that an I/O exception has occurred.
65    */
66   @Test
67   public void validateBasicConstruction() throws NoSuchAlgorithmException, IOException {
68
69     /*
70      * String testDate = "2016-12-21 00:00:00.00"; OxmEntityDescriptor d = new
71      * OxmEntityDescriptor(); d.setEntityName("service-instance");
72      * d.setPrimaryKeyAttributeName(Arrays.asList("service-instance-id"));
73      * d.setSearchableAttributes(Arrays.asList("service-instance-id"));
74      * 
75      * Mockito.when(oxmModelLoader.getEntityDescriptor(anyString())).thenReturn(d);
76      * 
77      * SearchableEntity id1 = new SearchableEntity(oxmModelLoader);
78      * 
79      * id1.setEntityType("service-instance"); id1.setEntityPrimaryKeyValue("DUP2");
80      * id1.addSearchTagWithIdx("DUP2", String.valueOf(1));
81      * 
82      * id1.deriveFields(); id1.setEntityTimeStamp(testDate); ObjectMapper mapper = new
83      * ObjectMapper();
84      * 
85      * String objStr = id1.getIndexDocumentJson();
86      * 
87      * JsonNode indexDocNode = mapper.readTree(objStr);
88      * 
89      * ///
90      * 
91      * ObjectNode expectedNode = mapper.createObjectNode(); expectedNode.put("entityType",
92      * "service-instance"); expectedNode.put("entityPrimaryKeyValue", "DUP2");
93      * expectedNode.put("searchTagIDs", "1"); expectedNode.put("searchTags", "DUP2");
94      * expectedNode.put("crossEntityReferenceValues", ""); expectedNode.put("lastmodTimestamp",
95      * testDate);
96      * 
97      * assertTrue(NodeUtils.isEqual(expectedNode, indexDocNode)); // Test if the timestamp is
98      * calculated when the node is being created
99      * assertTrue(NodeUtils.getNodeFieldAsText(indexDocNode, "lastmodTimestamp") != null);
100      */
101
102   }
103
104 }