Updated to use dublin schema version

Using 1.0.2 schema-service version
Fixed the junit test failure for default service version

Issue-ID: AAI-2338
Change-Id: Ie0ddda41f6895ff0ce8e97ad065fb935462e643a
Signed-off-by: Polavarapu, Chaitanya (cp8128) <cp8128@att.com>
diff --git a/pom.xml b/pom.xml
index 5a5167d..1b7e91a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -58,7 +58,7 @@
 		<javax.ws.rs.version>2.1</javax.ws.rs.version>
 		<mvn.jaxb2.version>0.13.2</mvn.jaxb2.version>
 		<aai-schema.group.id>org.onap.aai.schema-service</aai-schema.group.id>
-		<aai-schema.version>1.0.1</aai-schema.version>
+		<aai-schema.version>1.0.2</aai-schema.version>
 		<apache.lang3.version>3.7</apache.lang3.version>
 		<aai.rest.client.version>1.2.1</aai.rest.client.version>
 		<sdc.distribution.client.version>1.3.0</sdc.distribution.client.version>
diff --git a/src/main/java/org/onap/aai/babel/xml/generator/ModelGenerator.java b/src/main/java/org/onap/aai/babel/xml/generator/ModelGenerator.java
index c5ea37a..6695241 100644
--- a/src/main/java/org/onap/aai/babel/xml/generator/ModelGenerator.java
+++ b/src/main/java/org/onap/aai/babel/xml/generator/ModelGenerator.java
@@ -45,8 +45,6 @@
 
     private static final Logger logger = LogHelper.INSTANCE;
 
-    private static final String VERSION_DELIMITER = ".";
-    private static final String VERSION_DELIMITER_REGEXP = "\\" + VERSION_DELIMITER;
     private static final String DEFAULT_SERVICE_VERSION = "1.0";
 
     /**
@@ -115,12 +113,9 @@
     }
 
     private static String getServiceVersion(String artifactVersion) {
-        logger.debug("Artifact version=" + artifactVersion );
-        
-        // As of 1902, AAI-16260, we no longer edit the passed in artifact/service version.
+        logger.debug("Artifact version=" + artifactVersion);
         try {
-        	// just make sure it's an integer 
-            Integer.parseInt(artifactVersion.split(VERSION_DELIMITER_REGEXP)[0]);
+            return String.valueOf(Float.parseFloat(artifactVersion));
         } catch (Exception e) {
             logger.warn(ApplicationMsgs.DISTRIBUTION_EVENT,
                     "Error generating service version from artifact version: " + artifactVersion
@@ -128,8 +123,5 @@
                             + e);
             return DEFAULT_SERVICE_VERSION;
         }
-
-        logger.debug("Use Artifact version as the serviceVersion=" + artifactVersion );
-        return artifactVersion;
     }
 }
diff --git a/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java b/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java
index d011ba6..45eadb0 100644
--- a/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java
+++ b/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java
@@ -103,6 +103,56 @@
         assertThat(response.toString(), response.getStatus(), is(Response.Status.OK.getStatusCode()));
         assertThat(response.getEntity(), is(getResponseJson("response.json")));
     }
+    
+    /**
+     * Test with a valid request without Minor Artifact version.
+     *
+     * @throws URISyntaxException
+     *             if the URI cannot be created
+     * @throws IOException
+     *             if the resource cannot be loaded
+     */
+    @Test
+    public void testGenerateArtifactsWithoutMinorArtifactVersion() throws URISyntaxException, IOException {
+        Response response = invokeService(CsarTest.VNF_VENDOR_CSAR.getJsonRequestWithArtifactVersion("1"),
+        		Optional.of("transaction-id"), auth);
+        assertThat(response.toString(), response.getStatus(), is(Response.Status.OK.getStatusCode()));
+        assertThat(response.getEntity(), is(getResponseJson("response.json")));
+    }
+    
+    /**
+     * Test with a valid request without Minor Artifact version.
+     *
+     * @throws URISyntaxException
+     *             if the URI cannot be created
+     * @throws IOException
+     *             if the resource cannot be loaded
+     */
+    @Test
+    public void testGenerateArtifactsWithInvalidArtifactVersion() throws URISyntaxException, IOException {
+        Response response = invokeService(CsarTest.VNF_VENDOR_CSAR.getJsonRequestWithArtifactVersion("a"),
+        		Optional.of("transaction-id"), auth);
+        assertThat(response.toString(), response.getStatus(), is(Response.Status.OK.getStatusCode()));
+        assertThat(response.getEntity(), is(getResponseJson("response.json")));
+    }
+    
+    
+    /**
+     * Test with a valid request with Artifact version less than 1.
+     *
+     * @throws URISyntaxException
+     *             if the URI cannot be created
+     * @throws IOException
+     *             if the resource cannot be loaded
+     */
+    @Test
+    public void testGenerateArtifactsWithArtifactVerLessThan1() throws URISyntaxException, IOException {
+        Response response = invokeService(CsarTest.VNF_VENDOR_CSAR.getJsonRequestWithArtifactVersion("0.1"),
+        		Optional.of("transaction-id"), auth);
+        assertThat(response.toString(), response.getStatus(), is(Response.Status.OK.getStatusCode()));
+        assertThat(response.getEntity(), is(getResponseJson("responseWithVersionLessThan1.json")));
+    }
+
 
     /**
      * Test with a valid request, using a CSAR file that has no VNF configuration present.
diff --git a/src/test/java/org/onap/aai/babel/testdata/CsarTest.java b/src/test/java/org/onap/aai/babel/testdata/CsarTest.java
index 8b28551..1885555 100644
--- a/src/test/java/org/onap/aai/babel/testdata/CsarTest.java
+++ b/src/test/java/org/onap/aai/babel/testdata/CsarTest.java
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * org.onap.aai
  * ================================================================================
- * Copyright © 2017-2019 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2019 European Software Marketing Ltd.
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 European Software Marketing Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,12 +39,18 @@
     VNF_VENDOR_CSAR("catalog_csar.csar"),
     NO_VNF_CONFIG_CSAR("noVnfConfiguration.csar"),
     SD_WAN_CSAR_FILE("service-SdWanServiceTest-csar.csar"),
+    COS_AVPN_CSAR_FILE("service_CosAvpn_csar.csar"),
     MISSING_METADATA_CSAR("service-MissingMetadataTest.csar"),
     NO_YAML_FILES("noYmlFilesArchive.zip"),
     PORT_MIRROR_CSAR("service_PortMirror.csar"),
     MULTIPLE_VNF_CSAR("catalog_csar_too_many_vnfConfigurations.csar"),
     NETWORK_COLLECTION_CSAR_FILE("service_NetworkCollection.csar"),
+    RG_COLLECTOR_615_CSAR_FILE("service-RgCollector615-csar.csar"),
+    VDBE_SERVICE_CSAR_FILE("service-VdbeSrv-csar.csar"),
+    VNFOD_SERVICE("service-Dev2devnfodservice17July-csar.csar"),
+    CHILD_RESOURCE_CSAR_FILE("service-NetworkCloudVnfServiceMock-csar.csar"),
     SERVICE_PROXY_CSAR_FILE("service-S1-csar.csar");
+
     // @formatter:on
 
     private String filename;
@@ -102,4 +108,19 @@
         request.setCsar(new String(GeneratorUtil.encode(getContent())));
         return new Gson().toJson(request);
     }
+    
+    /**
+     * Create a BabelRequest containing the encoded CSAR content by passing in the artifact version.
+     * 
+     * @return a new Babel request for this CSAR
+     * @throws IOException
+     *             if an I/O exception occurs
+     */
+    public String getJsonRequestWithArtifactVersion(String artifactVersion) throws IOException {
+        BabelRequest request = new BabelRequest();
+        request.setArtifactName(getName());
+        request.setArtifactVersion(artifactVersion);
+        request.setCsar(new String(GeneratorUtil.encode(getContent())));
+        return new Gson().toJson(request);
+    }
 }
diff --git a/src/test/resources/response/responseWithVersionLessThan1.json b/src/test/resources/response/responseWithVersionLessThan1.json
new file mode 100644
index 0000000..2ffeff6
--- /dev/null
+++ b/src/test/resources/response/responseWithVersionLessThan1.json
@@ -0,0 +1 @@
+[{"name":"AAI-29NFOD_S-service-0.1.xml","type":"MODEL","payload":"<model xmlns=\"http://org.onap.aai.inventory/v16\">\n    <model-invariant-id>29NFOD_S-invariant-id</model-invariant-id>\n    <model-type>service</model-type>\n    <model-vers>\n        <model-ver>\n            <model-version-id>29NFOD_S-version-id</model-version-id>\n            <model-name>29NFOD_S</model-name>\n            <model-version>0.1</model-version>\n            <model-description>29NFOD</model-description>\n            <model-elements>\n                <model-element>\n                    <new-data-del-flag>T</new-data-del-flag>\n                    <cardinality>unbounded</cardinality>\n                    <model-elements>\n                        <model-element>\n                            <new-data-del-flag>T</new-data-del-flag>\n                            <cardinality>unbounded</cardinality>\n                            <model-elements/>\n                            <relationship-list>\n                                <relationship>\n                                    <related-to>model-ver</related-to>\n                                    <relationship-data>\n                                        <relationship-key>model-ver.model-version-id</relationship-key>\n                                        <relationship-value>29NFOD 0-version-id</relationship-value>\n                                    </relationship-data>\n                                    <relationship-data>\n                                        <relationship-key>model.model-invariant-id</relationship-key>\n                                        <relationship-value>29NFOD 0-invariant-id</relationship-value>\n                                    </relationship-data>\n                                </relationship>\n                            </relationship-list>\n                        </model-element>\n                    </model-elements>\n                    <relationship-list>\n                        <relationship>\n                            <related-to>model-ver</related-to>\n                            <relationship-data>\n                                <relationship-key>model-ver.model-version-id</relationship-key>\n                                <relationship-value>service-instance-version-id</relationship-value>\n                            </relationship-data>\n                            <relationship-data>\n                                <relationship-key>model.model-invariant-id</relationship-key>\n                                <relationship-value>service-instance-invariant-id</relationship-value>\n                            </relationship-data>\n                        </relationship>\n                    </relationship-list>\n                </model-element>\n            </model-elements>\n        </model-ver>\n    </model-vers>\n</model>"},{"name":"AAI-29NFOD-resource-1.0.xml","type":"MODEL","payload":"<model xmlns=\"http://org.onap.aai.inventory/v16\">\n    <model-invariant-id>29NFOD 0-invariant-id</model-invariant-id>\n    <model-type>resource</model-type>\n    <model-vers>\n        <model-ver>\n            <model-version-id>29NFOD 0-version-id</model-version-id>\n            <model-name>29NFOD</model-name>\n            <model-version>1.0</model-version>\n            <model-description>29NFOD</model-description>\n            <model-elements>\n                <model-element>\n                    <new-data-del-flag>T</new-data-del-flag>\n                    <cardinality>unbounded</cardinality>\n                    <model-elements/>\n                    <relationship-list>\n                        <relationship>\n                            <related-to>model-ver</related-to>\n                            <relationship-data>\n                                <relationship-key>model-ver.model-version-id</relationship-key>\n                                <relationship-value>generic-vnf-version-id</relationship-value>\n                            </relationship-data>\n                            <relationship-data>\n                                <relationship-key>model.model-invariant-id</relationship-key>\n                                <relationship-value>generic-vnf-invariant-id</relationship-value>\n                            </relationship-data>\n                        </relationship>\n                    </relationship-list>\n                </model-element>\n            </model-elements>\n        </model-ver>\n    </model-vers>\n</model>"},{"name":"vnfVendorImageConfigurations","type":"VNFCATALOG","payload":"[{\"application\":\"VM00\",\"application-vendor\":\"29NFOD\",\"application-version\":\"3.16.1\"},{\"application\":\"VM00\",\"application-vendor\":\"29NFOD\",\"application-version\":\"3.16.9\"},{\"application\":\"VM01\",\"application-vendor\":\"29NFOD\",\"application-version\":\"3.16.1\"},{\"application\":\"VM01\",\"application-vendor\":\"29NFOD\",\"application-version\":\"3.16.9\"}]"}]