Adding UI extensibility
[aai/sparky-be.git] / src / test / java / org / onap / aai / sparky / editattributes / AttributeUpdaterTest.java
1 package org.onap.aai.sparky.editattributes;
2 /**
3  * ============LICENSE_START=================================================== SPARKY (AAI UI
4  * service) ============================================================================ Copyright ©
5  * 2017 AT&T Intellectual Property. Copyright © 2017 Amdocs All rights reserved.
6  * ============================================================================ Licensed under the
7  * Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License. ============LICENSE_END=====================================================
16  *
17  * ECOMP and OpenECOMP are trademarks and service marks of AT&T Intellectual Property.
18  */
19 /*
20  * package org.openecomp.sparky.editattributes;
21  * 
22  * import static org.junit.Assert.assertEquals;
23  * 
24  * import java.util.HashMap; import java.util.Map;
25  * 
26  * import javax.ws.rs.core.Response.Status;
27  * 
28  * import org.junit.Before; import org.junit.Test; import
29  * org.onap.aai.restclient.client.OperationResult; import
30  * org.onap.aai.sparky.config.oxm.OxmEntityDescriptor; import
31  * org.onap.aai.sparky.config.oxm.OxmEntityLookup; import
32  * org.onap.aai.sparky.config.oxm.OxmModelLoader; import
33  * org.onap.aai.sparky.dal.aai.config.ActiveInventoryConfig; import
34  * org.onap.aai.sparky.editattributes.AttributeUpdater; import
35  * org.openecomp.sparky.dal.aai.config.ActiveInventoryConfigUtil;
36  * 
37  * 
38  * /** The Class AttributeUpdaterTest.
39  *
40  * public class AttributeUpdaterTest {
41  * 
42  * /** Sets the up.
43  *
44  * @throws Exception the exception
45  *
46  * @Before public void setUp() throws Exception {}
47  * 
48  * /**
49  * 
50  * @throws Exception
51  */
52
53 /*
54  * @Test public void testUpdateObjectAttribute() throws Exception {
55  * 
56  * OxmEntityDescriptor desc = new OxmEntityDescriptor(); desc.addPrimaryKeyName("hostname");
57  * desc.setEntityName("pserver");
58  * 
59  * OxmEntityLookup entityLookup = OxmEntityLookup.getInstance();
60  * entityLookup.addEntityDescriptor("pserver", desc);
61  * 
62  * AttributeUpdater updater = new AttributeUpdater(new OxmModelLoader(), entityLookup, new
63  * ActiveInventoryConfig(ActiveInventoryConfigUtil.getValidTestProperties())); Map<String, Object>
64  * attributes = new HashMap<>(); attributes.put("prov-status", "PREPROV");
65  * attributes.put("in-maint", "true"); OperationResult result = updater.updateObjectAttribute(
66  * "cloud-infrastructure/pservers/pserver/something", attributes, "someid");
67  * assertEquals(Status.FORBIDDEN.getStatusCode(), result.getResultCode()); }
68  */
69
70 // This needs the OXM file in place to work.
71 /**
72  * Test get edit object from uri.
73  *
74  * @throws Exception the exception
75  */
76 // @Test
77 /*
78  * public void testGetEditObjectFromUri() throws Exception {
79  * 
80  * OxmModelLoader loader = new OxmModelLoader(); loader.setLatestVersionNum(11);
81  * 
82  * OxmEntityDescriptor desc = new OxmEntityDescriptor(); desc.addPrimaryKeyName("hostname");
83  * desc.setEntityName("pserver");
84  * 
85  * OxmEntityLookup entityLookup = OxmEntityLookup.getInstance();
86  * entityLookup.addEntityDescriptor("pserver", desc);
87  * 
88  * 
89  * DynamicType mockType = Mockito.mock(DynamicType.class); Class<? extends DynamicEntity>
90  * mockDynamicEntity = Mockito.mock(DynamicEntity.class);
91  * 
92  * Mockito.when(mockType.getJavaClass()).thenReturn(mockDynamicEntity);
93  * 
94  * 
95  * 
96  * 
97  * HashMap<String, DynamicType> typeLookup = new HashMap<String,DynamicType>();
98  * typeLookup.put("pserver", mockType);
99  * 
100  * entityLookup.setEntityTypeLookup(typeLookup);
101  * 
102  * 
103  * AttributeUpdater updater = new AttributeUpdater(new OxmModelLoader(), entityLookup, new
104  * ActiveInventoryConfig(ActiveInventoryConfigUtil.getValidTestProperties())); AaiEditObject result
105  * = updater.getEditObjectFromUri("cloud-infrastructure/pservers/pserver/mtznjtax101");
106  * assertEquals("Pserver", result.getObjectType()); assertEquals("pserver",
107  * result.getRootElement()); assertEquals("hostname", result.getKeyName());
108  * assertEquals("mtznjtax101", result.getKeyValue()); }
109  */
110
111 /**
112  * Test get relative uri.
113  *
114  * @throws Exception the exception
115  */
116 /*
117  * @Test public void testGetRelativeUri() throws Exception {
118  * 
119  * OxmEntityDescriptor desc = new OxmEntityDescriptor(); desc.addPrimaryKeyName("hostname");
120  * desc.setEntityName("pserver");
121  * 
122  * OxmEntityLookup entityLookup = OxmEntityLookup.getInstance();
123  * entityLookup.addEntityDescriptor("pserver", desc);
124  * 
125  * AttributeUpdater updater = new AttributeUpdater(new OxmModelLoader(), entityLookup, new
126  * ActiveInventoryConfig(ActiveInventoryConfigUtil.getValidTestProperties())); // Test entity uri
127  * without "/aai/version/" String result =
128  * updater.getRelativeUri("cloud-infrastructure/pservers/pserver/mtznjtax101");
129  * assertEquals("/cloud-infrastructure/pservers/pserver/mtznjtax101", result); result =
130  * updater.getRelativeUri("/aai/v8/cloud-infrastructure/pservers/pserver/mtznjtax101");
131  * assertEquals("/cloud-infrastructure/pservers/pserver/mtznjtax101", result);
132  * 
133  * result = updater.getRelativeUri("/v8/cloud-infrastructure/pservers/pserver/mtznjtax101");
134  * assertEquals("/cloud-infrastructure/pservers/pserver/mtznjtax101", result);
135  * 
136  * result = updater.getRelativeUri("aai/v88/cloud-infrastructure/pservers/pserver/mtznjtax101");
137  * assertEquals("/cloud-infrastructure/pservers/pserver/mtznjtax101", result);
138  * 
139  * result = updater.getRelativeUri("/cloud-infrastructure/pservers/pserver/mtznjtax101");
140  * assertEquals("/cloud-infrastructure/pservers/pserver/mtznjtax101", result); }
141  * 
142  * }
143  */