AAI-1523 Batch reformat aai-core
[aai/aai-common.git] / aai-core / src / test / java / org / onap / aai / parsers / relationship / RelationshipToURITest.java
index 42f1fd4..ea872d4 100644 (file)
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.aai.parsers.relationship;
 
+import static org.hamcrest.Matchers.hasProperty;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertEquals;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
 import org.apache.commons.io.IOUtils;
 import org.junit.Ignore;
 import org.junit.Rule;
@@ -32,38 +42,28 @@ import org.onap.aai.parsers.exceptions.AmbiguousMapAAIException;
 import org.onap.aai.setup.SchemaVersion;
 import org.springframework.test.annotation.DirtiesContext;
 
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import static org.hamcrest.Matchers.hasProperty;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertEquals;
-
 @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
 public class RelationshipToURITest extends AAISetup {
 
     private final ModelType modelType = ModelType.MOXY;
     private final SchemaVersion version10 = new SchemaVersion("v10");
-    
-    
+
     @Rule
     public ExpectedException thrown = ExpectedException.none();
-    
+
     @Test
     public void onlyLink() throws AAIException, URISyntaxException, IOException {
         Loader loader = loaderFactory.createLoaderForVersion(modelType, version10);
         Introspector obj = loader.unmarshal("relationship", this.getJsonString("only-related-link.json"));
         URI expected = new URI("/aai/v10/network/generic-vnfs/generic-vnf/key1");
-        
+
         RelationshipToURI parse = new RelationshipToURI(loader, obj);
-        
+
         URI uri = parse.getUri();
-        
+
         assertEquals("related-link is equal", expected.getPath(), uri.getPath());
     }
-    
+
     @Test
     public void onlyData() throws AAIException, URISyntaxException, IOException {
         Loader loader = loaderFactory.createLoaderForVersion(modelType, version10);
@@ -71,71 +71,68 @@ public class RelationshipToURITest extends AAISetup {
         URI expected = new URI("/network/generic-vnfs/generic-vnf/key1");
 
         RelationshipToURI parse = new RelationshipToURI(loader, obj);
-        
+
         URI uri = parse.getUri();
-        
+
         assertEquals("related-link is equal", expected, uri);
     }
-    
+
     @Test
     public void failV10() throws AAIException, URISyntaxException, IOException {
         Loader loader = loaderFactory.createLoaderForVersion(modelType, version10);
         Introspector obj = loader.unmarshal("relationship", this.getJsonString("both-failv10-successv9.json"));
         URI expected = new URI("/aai/v10/network/generic-vnfs/generic-vnf/key1");
-        
+
         thrown.expect(AAIIdentityMapParseException.class);
         thrown.expect(hasProperty("code", is("AAI_3000")));
         RelationshipToURI parse = new RelationshipToURI(loader, obj);
         URI uri = parse.getUri();
-        
+
     }
-    
+
     @Test
     public void failNothingToParse() throws AAIException, URISyntaxException, IOException {
         Loader loader = loaderFactory.createLoaderForVersion(modelType, version10);
         Introspector obj = loader.unmarshal("relationship", this.getJsonString("nothing-to-parse.json"));
         URI expected = new URI("/aai/v10/network/generic-vnfs/generic-vnf/key1");
-        
+
         thrown.expect(AAIIdentityMapParseException.class);
         thrown.expect(hasProperty("code", is("AAI_3000")));
         RelationshipToURI parse = new RelationshipToURI(loader, obj);
-        
+
         URI uri = parse.getUri();
-        
+
     }
-    
+
     @Test
     public void successV10() throws AAIException, URISyntaxException, IOException {
         Loader loader = loaderFactory.createLoaderForVersion(modelType, version10);
         Introspector obj = loader.unmarshal("relationship", this.getJsonString("both-successv10-failv9.json"));
         URI expected = new URI("/aai/v10/network/generic-vnfs/generic-vnf/key1");
-        
+
         RelationshipToURI parse = new RelationshipToURI(loader, obj);
-        
 
         URI uri = parse.getUri();
-        
+
         assertEquals("related-link is equal", expected, uri);
 
-        
     }
-    
+
     @Test
     public void ambiguousRelationship() throws AAIException, URISyntaxException, IOException {
         Loader loader = loaderFactory.createLoaderForVersion(modelType, version10);
         Introspector obj = loader.unmarshal("relationship", this.getJsonString("ambiguous-relationship.json"));
         URI expected = new URI("/aai/v10/network/generic-vnfs/generic-vnf/key1");
-        
+
         thrown.expect(AmbiguousMapAAIException.class);
         thrown.expect(hasProperty("code", is("AAI_6146")));
-        
+
         RelationshipToURI parse = new RelationshipToURI(loader, obj);
-        
+
         URI uri = parse.getUri();
-        
+
         assertEquals("related-link is equal", expected, uri);
 
-        
     }
 
     @Ignore
@@ -144,54 +141,53 @@ public class RelationshipToURITest extends AAISetup {
         Loader loader = loaderFactory.createLoaderForVersion(modelType, version10);
         Introspector obj = loader.unmarshal("relationship", this.getJsonString("too-many-items-relationship.json"));
         URI expected = new URI("/network/generic-vnfs/generic-vnf/key1/l-interfaces/l-interface/key2");
-        
+
         RelationshipToURI parse = new RelationshipToURI(loader, obj);
 
         URI uri = parse.getUri();
-        
+
         assertEquals("related-link is equal", expected.toString(), uri.toString());
-        
+
     }
-    
+
     @Test
     public void twoTopLevelNodes() throws AAIException, URISyntaxException, IOException {
         Loader loader = loaderFactory.createLoaderForVersion(modelType, version10);
         Introspector obj = loader.unmarshal("relationship", this.getJsonString("two-top-level-relationship.json"));
         URI expected = new URI("/network/generic-vnfs/generic-vnf/key1/l-interfaces/l-interface/key2");
-        
+
         thrown.expect(AmbiguousMapAAIException.class);
         thrown.expect(hasProperty("code", is("AAI_6146")));
-        
+
         RelationshipToURI parse = new RelationshipToURI(loader, obj);
-        
+
         URI uri = parse.getUri();
-        
+
         assertEquals("related-link is equal", expected, uri);
-        
+
     }
-    
+
     @Test
     public void topLevelWithTwoKeys() throws AAIException, URISyntaxException, IOException {
         Loader loader = loaderFactory.createLoaderForVersion(modelType, version10);
         Introspector obj = loader.unmarshal("relationship", this.getJsonString("top-level-two-keys-relationship.json"));
-        URI expected = new URI("/cloud-infrastructure/cloud-regions/cloud-region/key1/key2/availability-zones/availability-zone/key3");
-        
+        URI expected = new URI(
+                "/cloud-infrastructure/cloud-regions/cloud-region/key1/key2/availability-zones/availability-zone/key3");
+
         RelationshipToURI parse = new RelationshipToURI(loader, obj);
-        
+
         URI uri = parse.getUri();
-        
+
         assertEquals("related-link is equal", expected.toString(), uri.toString());
-        
+
     }
-    
-    
+
     private String getJsonString(String filename) throws IOException {
-        
-        
+
         FileInputStream is = new FileInputStream("src/test/resources/bundleconfig-local/etc/relationship/" + filename);
-        String s =  IOUtils.toString(is, "UTF-8"); 
+        String s = IOUtils.toString(is, "UTF-8");
         IOUtils.closeQuietly(is);
-        
+
         return s;
     }
 }