AAI-1523 Batch reformat aai-core
[aai/aai-common.git] / aai-core / src / test / java / org / onap / aai / parsers / uri / URIToDBKeyTest.java
index 757fbc1..f19e268 100644 (file)
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.aai.parsers.uri;
 
+import static org.hamcrest.Matchers.hasProperty;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertEquals;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+
+import javax.annotation.PostConstruct;
+import javax.ws.rs.core.UriBuilder;
+import javax.xml.bind.JAXBException;
+
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.onap.aai.AAISetup;
-import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.parsers.exceptions.DoesNotStartWithValidNamespaceException;
 import org.onap.aai.db.props.AAIProperties;
+import org.onap.aai.exceptions.AAIException;
 import org.onap.aai.introspection.*;
-
-import javax.annotation.PostConstruct;
-import javax.ws.rs.core.UriBuilder;
-import javax.xml.bind.JAXBException;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-
-import static org.hamcrest.Matchers.hasProperty;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertEquals;
-
+import org.onap.aai.parsers.exceptions.DoesNotStartWithValidNamespaceException;
 
 public class URIToDBKeyTest extends AAISetup {
 
-    private Loader loader ;
+    private Loader loader;
 
     @Rule
     public ExpectedException thrown = ExpectedException.none();
-    
+
     /**
      * Uri.
      *
@@ -55,22 +56,24 @@ public class URIToDBKeyTest extends AAISetup {
      * @throws UnsupportedEncodingException the unsupported encoding exception
      */
     @PostConstruct
-    public void createLoader(){
+    public void createLoader() {
         loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
     }
-    
+
     @Test
     public void uri() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
-        URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner-key/cloudRegion-key/tenants/tenant/tenantId-key/vservers/vserver/vserverId-key/l-interfaces/l-interface/key3").build();
+        URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion()
+                + "/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner-key/cloudRegion-key/tenants/tenant/tenantId-key/vservers/vserver/vserverId-key/l-interfaces/l-interface/key3")
+                .build();
         URIToDBKey parse = new URIToDBKey(loader, uri);
         Object result = parse.getResult();
 
         String expected = "cloud-region/tenant/vserver/l-interface";
-        
+
         assertEquals("blah", expected, result);
-        
+
     }
-    
+
     /**
      * Uri no version.
      *
@@ -80,17 +83,19 @@ public class URIToDBKeyTest extends AAISetup {
      * @throws UnsupportedEncodingException the unsupported encoding exception
      */
     @Test
-    public void uriNoVersion() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
-        URI uri = UriBuilder.fromPath("/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner-key/cloudRegion-key/tenants/tenant/tenantId-key/vservers/vserver/vserverId-key/l-interfaces/l-interface/key3").build();
+    public void uriNoVersion()
+            throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
+        URI uri = UriBuilder.fromPath(
+                "/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner-key/cloudRegion-key/tenants/tenant/tenantId-key/vservers/vserver/vserverId-key/l-interfaces/l-interface/key3")
+                .build();
         URIToDBKey parse = new URIToDBKey(loader, uri);
         Object result = parse.getResult();
-        
+
         String expected = "cloud-region/tenant/vserver/l-interface";
-        
+
         assertEquals("blah", expected, result);
-        
+
     }
-    
 
     /**
      * Bad URI.
@@ -102,14 +107,16 @@ public class URIToDBKeyTest extends AAISetup {
      */
     @Test
     public void badURI() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
-        URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud-infrastructure/tenants/tenant/key1/vservers/vserver/key2/l-interadsfaces/l-interface/key3").build();
-        
+        URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion()
+                + "/cloud-infrastructure/tenants/tenant/key1/vservers/vserver/key2/l-interadsfaces/l-interface/key3")
+                .build();
+
         thrown.expect(AAIException.class);
-        thrown.expect(hasProperty("code",  is("AAI_3001")));
-        
+        thrown.expect(hasProperty("code", is("AAI_3001")));
+
         new URIToDBKey(loader, uri);
     }
-    
+
     /**
      * NotValid namespace.
      *
@@ -119,13 +126,15 @@ public class URIToDBKeyTest extends AAISetup {
      * @throws UnsupportedEncodingException the unsupported encoding exception
      */
     @Test
-    public void notValidNamespace() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
-        URI uri = UriBuilder.fromPath("/cloud-region/cloud-regions/cloud-region/cloudOwner-key/cloudRegion-key/tenants/tenant/tenantId-key/vservers/vserver/vserverId-key/l-interfaces/l-interface/key3").build();
+    public void notValidNamespace()
+            throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
+        URI uri = UriBuilder.fromPath(
+                "/cloud-region/cloud-regions/cloud-region/cloudOwner-key/cloudRegion-key/tenants/tenant/tenantId-key/vservers/vserver/vserverId-key/l-interfaces/l-interface/key3")
+                .build();
         thrown.expect(DoesNotStartWithValidNamespaceException.class);
         URIToDBKey parse = new URIToDBKey(loader, uri);
     }
-    
-    
+
     /**
      * No valid tokens.
      *
@@ -135,15 +144,16 @@ public class URIToDBKeyTest extends AAISetup {
      * @throws UnsupportedEncodingException the unsupported encoding exception
      */
     @Test
-    public void noValidTokens() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
+    public void noValidTokens()
+            throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
         URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud/blah/blah").build();
-        
+
         thrown.expect(AAIException.class);
-        thrown.expect(hasProperty("code",  is("AAI_3000")));
-        
+        thrown.expect(hasProperty("code", is("AAI_3000")));
+
         new URIToDBKey(loader, uri);
     }
-    
+
     /**
      * Starts with valid namespace.
      *
@@ -153,17 +163,20 @@ public class URIToDBKeyTest extends AAISetup {
      * @throws UnsupportedEncodingException the unsupported encoding exception
      */
     @Test
-    public void startsWithValidNamespace() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
-        URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion() + "/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner-key/cloudRegion-key/tenants/tenant/tenantId-key/vservers/vserver/vserverId-key/l-interfaces/l-interface/key3").build();
-        
+    public void startsWithValidNamespace()
+            throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
+        URI uri = UriBuilder.fromPath("/aai/" + loader.getVersion()
+                + "/cloud-infrastructure/cloud-regions/cloud-region/cloudOwner-key/cloudRegion-key/tenants/tenant/tenantId-key/vservers/vserver/vserverId-key/l-interfaces/l-interface/key3")
+                .build();
+
         URIToDBKey parse = new URIToDBKey(loader, uri);
         Object result = parse.getResult();
 
         String expected = "cloud-region/tenant/vserver/l-interface";
-        
+
         assertEquals("blah", expected, result);
     }
-    
+
     /**
      * Naming exceptions.
      *
@@ -173,14 +186,15 @@ public class URIToDBKeyTest extends AAISetup {
      */
     @Test
     public void namingExceptions() throws IllegalArgumentException, AAIException, UnsupportedEncodingException {
-        URI uri = UriBuilder.fromPath("network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655").build();
+        URI uri = UriBuilder.fromPath("network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655")
+                .build();
         URIToDBKey parse = new URIToDBKey(loader, uri);
         Object result = parse.getResult();
 
         String expected = "vce/port-group/cvlan-tag";
-        
+
         assertEquals("blah", expected, result);
-        
+
     }
-        
+
 }