Initial commit for AAI-UI(sparky-backend)
[aai/sparky-be.git] / src / test / java / org / openecomp / sparky / inventory / GeoIndexDocumentTest.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.inventory;
27
28 import static org.junit.Assert.assertFalse;
29 import static org.junit.Assert.assertTrue;
30
31 import org.junit.Before;
32 import org.junit.Test;
33 import org.junit.runner.RunWith;
34 import org.openecomp.sparky.inventory.entity.GeoIndexDocument;
35 import org.powermock.modules.junit4.PowerMockRunner;
36
37 /**
38  * The Class GeoIndexDocumentTest.
39  */
40 @RunWith(PowerMockRunner.class)
41 public class GeoIndexDocumentTest {
42
43   /**
44    * Inits the.
45    *
46    * @throws Exception the exception
47    */
48   @Before
49   public void init() throws Exception {}
50
51   /**
52    * Checks if is valid geo index document success path.
53    */
54   @Test
55   public void isValidGeoIndexDocument_successPath() {
56
57     GeoIndexDocument geoDoc = new GeoIndexDocument();
58
59     geoDoc.setEntityPrimaryKeyName("pkeyName");
60     geoDoc.setEntityPrimaryKeyValue("pkeyValue");
61     geoDoc.setEntityType("type");
62     geoDoc.setId("12312");
63     geoDoc.setLatitude("-45.123");
64     geoDoc.setLongitude("181.321");
65     geoDoc.setSelfLink("https://server.somewhere.com:8443/aai/v7/id");
66
67     assertTrue(geoDoc.isValidGeoDocument());
68
69   }
70
71   /**
72    * Checks if is valid geo index document fail no geo coordinates.
73    */
74   @Test
75   public void isValidGeoIndexDocument_fail_no_geoCoordinates() {
76
77     GeoIndexDocument geoIndexDoc = new GeoIndexDocument();
78
79     geoIndexDoc.setEntityPrimaryKeyName("pkeyName");
80     geoIndexDoc.setEntityPrimaryKeyValue("pkeyValue");
81     geoIndexDoc.setEntityType("type");
82     geoIndexDoc.setId("12312");
83     geoIndexDoc.setSelfLink("https://server.somewhere.com:8443/aai/v7/id");
84
85     assertFalse(geoIndexDoc.isValidGeoDocument());
86
87   }
88
89   /**
90    * Checks if is valid geo index document fail invalid geo coordinates.
91    */
92   @Test
93   public void isValidGeoIndexDocument_fail_invalid_geoCoordinates() {
94
95     GeoIndexDocument geoIndexDoc = new GeoIndexDocument();
96
97     geoIndexDoc.setEntityPrimaryKeyName("pkeyName");
98     geoIndexDoc.setEntityPrimaryKeyValue("pkeyValue");
99     geoIndexDoc.setEntityType("type");
100     geoIndexDoc.setId("12312");
101     geoIndexDoc.setLatitude("not_a_valid");
102     geoIndexDoc.setLongitude("geo point");
103
104     geoIndexDoc.setSelfLink("https://server.somewhere.com:8443/aai/v7/id");
105
106     assertFalse(geoIndexDoc.isValidGeoDocument());
107
108   }
109
110   /**
111    * Checks if is valid geo index document fail nothing set.
112    */
113   @Test
114   public void isValidGeoIndexDocument_fail_nothing_set() {
115
116     GeoIndexDocument geoIndexDoc = new GeoIndexDocument();
117
118     assertFalse(geoIndexDoc.isValidGeoDocument());
119
120   }
121 }