Initial commit for AAI-UI(sparky-backend)
[aai/sparky-be.git] / src / test / java / org / openecomp / 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.openecomp.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.Mockito;
35 import org.openecomp.sparky.config.oxm.OxmModelLoader;
36 import org.openecomp.sparky.util.LogValidator;
37 import org.powermock.modules.junit4.PowerMockRunner;
38
39 import ch.qos.logback.classic.Level;
40
41
42 /**
43  * The Class IndexDocumentTest.
44  */
45 @RunWith(PowerMockRunner.class)
46 public class IndexDocumentTest {
47
48   private LogValidator logValidator;
49   private OxmModelLoader oxmModelLoader;
50
51   /**
52    * Inits the.
53    *
54    * @throws Exception the exception
55    */
56   @Before
57   public void init() throws Exception {
58     logValidator = new LogValidator();
59     logValidator.initializeLogger(Level.WARN);
60     oxmModelLoader = Mockito.mock(OxmModelLoader.class);
61   }
62
63   /**
64    * Validate basic construction.
65    *
66    * @throws NoSuchAlgorithmException the no such algorithm exception
67    * @throws IOException Signals that an I/O exception has occurred.
68    */
69   @Test
70   public void validateBasicConstruction() throws NoSuchAlgorithmException, IOException {
71
72     /*
73      * String testDate = "2016-12-21 00:00:00.00"; OxmEntityDescriptor d = new
74      * OxmEntityDescriptor(); d.setEntityName("service-instance");
75      * d.setPrimaryKeyAttributeName(Arrays.asList("service-instance-id"));
76      * d.setSearchableAttributes(Arrays.asList("service-instance-id"));
77      * 
78      * Mockito.when(oxmModelLoader.getEntityDescriptor(anyString())).thenReturn(d);
79      * 
80      * SearchableEntity id1 = new SearchableEntity(oxmModelLoader);
81      * 
82      * id1.setEntityType("service-instance"); id1.setEntityPrimaryKeyValue("DUP2");
83      * id1.addSearchTagWithIdx("DUP2", String.valueOf(1));
84      * 
85      * id1.deriveFields(); id1.setEntityTimeStamp(testDate); ObjectMapper mapper = new
86      * ObjectMapper();
87      * 
88      * String objStr = id1.getIndexDocumentJson();
89      * 
90      * JsonNode indexDocNode = mapper.readTree(objStr);
91      * 
92      * ///
93      * 
94      * ObjectNode expectedNode = mapper.createObjectNode(); expectedNode.put("entityType",
95      * "service-instance"); expectedNode.put("entityPrimaryKeyValue", "DUP2");
96      * expectedNode.put("searchTagIDs", "1"); expectedNode.put("searchTags", "DUP2");
97      * expectedNode.put("crossEntityReferenceValues", ""); expectedNode.put("lastmodTimestamp",
98      * testDate);
99      * 
100      * assertTrue(NodeUtils.isEqual(expectedNode, indexDocNode)); // Test if the timestamp is
101      * calculated when the node is being created
102      * assertTrue(NodeUtils.getNodeFieldAsText(indexDocNode, "lastmodTimestamp") != null);
103      */
104
105   }
106
107 }