Clean up MdcData and ImportMetadata 47/89247/4
authorTomasz Golabek <tomasz.golabek@nokia.com>
Tue, 4 Jun 2019 13:31:47 +0000 (15:31 +0200)
committerOren Kleks <orenkle@amdocs.com>
Thu, 20 Jun 2019 06:31:02 +0000 (06:31 +0000)
Removed duplicated class. Added assertions to check the logic.

Change-Id: Ia953ee0c88d71214cf620cdd286f6ecdd3f3d26d
Issue-ID: SDC-2326
Signed-off-by: Tomasz Golabek <tomasz.golabek@nokia.com>
catalog-fe/pom.xml
catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/ImportMetadata.java
catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/MdcData.java
catalog-fe/src/main/java/org/openecomp/sdc/fe/mdc/MdcData.java [deleted file]
catalog-fe/src/test/java/org/openecomp/sdc/fe/impl/ImportMetadataTest.java
catalog-fe/src/test/java/org/openecomp/sdc/fe/impl/MdcDataTest.java [new file with mode: 0644]
catalog-fe/src/test/java/org/openecomp/sdc/fe/mdc/MdcDataTest.java [deleted file]

index 1fb449e..8b07a3e 100644 (file)
 
        <dependencies>
 
+               <dependency>
+                       <groupId>org.projectlombok</groupId>
+                       <artifactId>lombok</artifactId>
+                       <version>${lombok.version}</version>
+               </dependency>
+
                <dependency>
                        <groupId>org.functionaljava</groupId>
                        <artifactId>functionaljava</artifactId>
                        <scope>test</scope>
                </dependency>
 
+               <dependency>
+                       <groupId>com.google.code.bean-matchers</groupId>
+                       <artifactId>bean-matchers</artifactId>
+                       <version>${bean-matchers.version}</version>
+                       <scope>test</scope>
+               </dependency>
+
                <dependency>
                        <groupId>org.eclipse.jetty</groupId>
                        <artifactId>jetty-servlet</artifactId>
index 0d0aa7b..c74c510 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
  */
 
 package org.openecomp.sdc.fe.impl;
 
-public class ImportMetadata {
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
 
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
+public class ImportMetadata {
        private String name;
        private long size;
        private String mime;
        private String creator;
        private String md5Checksum;
-
-       public ImportMetadata(String name, long size, String mime, String creator, String md5Checksum) {
-               super();
-               this.name = name;
-               this.size = size;
-               this.mime = mime;
-               this.creator = creator;
-               this.md5Checksum = md5Checksum;
-       }
-
-       public String getName() {
-               return name;
-       }
-
-       public void setName(String name) {
-               this.name = name;
-       }
-
-       public long getSize() {
-               return size;
-       }
-
-       public void setSize(long size) {
-               this.size = size;
-       }
-
-       public String getMime() {
-               return mime;
-       }
-
-       public void setMime(String mime) {
-               this.mime = mime;
-       }
-
-       public String getCreator() {
-               return creator;
-       }
-
-       public void setCreator(String creator) {
-               this.creator = creator;
-       }
-
-       public String getMd5Checksum() {
-               return md5Checksum;
-       }
-
-       public void setMd5Checksum(String md5Checksum) {
-               this.md5Checksum = md5Checksum;
-       }
-
 }
index 816975f..e95f6b8 100644 (file)
@@ -1,38 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
 package org.openecomp.sdc.fe.impl;
 
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor
 public class MdcData {
                private String serviceInstanceID;
                private String userId;
                private String remoteAddr;
                private String localAddr;
                private Long transactionStartTime;
-
-               public MdcData(String serviceInstanceID, String userId, String remoteAddr, String localAddr, Long transactionStartTime) {
-                       super();
-                       this.serviceInstanceID = serviceInstanceID;
-                       this.userId = userId;
-                       this.remoteAddr = remoteAddr;
-                       this.localAddr = localAddr;
-                       this.transactionStartTime = transactionStartTime;
-               }
-
-               public Long getTransactionStartTime() {
-                       return transactionStartTime;
-               }
-
-               public String getUserId() {
-                       return userId;
-               }
-
-               public String getRemoteAddr() {
-                       return remoteAddr;
-               }
-
-               public String getLocalAddr() {
-                       return localAddr;
-               }
-
-               public String getServiceInstanceID() {
-                       return serviceInstanceID;
-               }
        }
\ No newline at end of file
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/mdc/MdcData.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/mdc/MdcData.java
deleted file mode 100644 (file)
index aa78a89..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.openecomp.sdc.fe.mdc;
-
-public class MdcData {
-    private String serviceInstanceID;
-    private String userId;
-    private String remoteAddr;
-    private String localAddr;
-    private Long transactionStartTime;
-
-    public MdcData(String serviceInstanceID, String userId, String remoteAddr, String localAddr, Long transactionStartTime) {
-        super();
-        this.serviceInstanceID = serviceInstanceID;
-        this.userId = userId;
-        this.remoteAddr = remoteAddr;
-        this.localAddr = localAddr;
-        this.transactionStartTime = transactionStartTime;
-    }
-
-    public Long getTransactionStartTime() {
-        return transactionStartTime;
-    }
-
-    public String getUserId() {
-        return userId;
-    }
-
-    public String getRemoteAddr() {
-        return remoteAddr;
-    }
-
-    public String getLocalAddr() {
-        return localAddr;
-    }
-
-    public String getServiceInstanceID() {
-        return serviceInstanceID;
-    }
-}
index 54e0392..2fd5b56 100644 (file)
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
 package org.openecomp.sdc.fe.impl;
 
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
 import org.junit.Test;
 
 public class ImportMetadataTest {
 
-       private ImportMetadata createTestSubject() {
-               return new ImportMetadata("", 1234567, "", "", "");
-       }
-
-       @Test
-       public void testGetName() throws Exception {
-               ImportMetadata testSubject;
-               String result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.getName();
-       }
-
-       @Test
-       public void testSetName() throws Exception {
-               ImportMetadata testSubject;
-               String name = "";
-
-               // default test
-               testSubject = createTestSubject();
-               testSubject.setName(name);
-       }
+       private static final String CHECKSUM = "CHECKSUM";
+       private static final String CREATOR = "CREATOR";
+       private static final String MIME = "MIME";
+       private static final long SIZE = 123L;
+       private static final String NAME = "name";
 
        @Test
-       public void testGetSize() throws Exception {
-               ImportMetadata testSubject;
-               long result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.getSize();
+       public void shouldHaveValidGettersAndSetters() {
+               assertThat(ImportMetadata.class, hasValidGettersAndSetters());
        }
 
        @Test
-       public void testSetSize() throws Exception {
-               ImportMetadata testSubject;
-               long size = 1234567;
-
-               // default test
-               testSubject = createTestSubject();
-               testSubject.setSize(size);
+       public void testConstructor() {
+               ImportMetadata importMetadata = new ImportMetadata(NAME, SIZE, MIME, CREATOR, CHECKSUM);
+               assertThat(importMetadata.getCreator(), equalTo(CREATOR));
+               assertThat(importMetadata.getMd5Checksum(), equalTo(CHECKSUM));
+               assertThat(importMetadata.getMime(), equalTo(MIME));
+               assertThat(importMetadata.getName(), equalTo(NAME));
+               assertThat(importMetadata.getSize(), equalTo(SIZE));
        }
 
-       @Test
-       public void testGetMime() throws Exception {
-               ImportMetadata testSubject;
-               String result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.getMime();
-       }
-
-       @Test
-       public void testSetMime() throws Exception {
-               ImportMetadata testSubject;
-               String mime = "";
-
-               // default test
-               testSubject = createTestSubject();
-               testSubject.setMime(mime);
-       }
-
-       @Test
-       public void testGetCreator() throws Exception {
-               ImportMetadata testSubject;
-               String result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.getCreator();
-       }
-
-       @Test
-       public void testSetCreator() throws Exception {
-               ImportMetadata testSubject;
-               String creator = "";
-
-               // default test
-               testSubject = createTestSubject();
-               testSubject.setCreator(creator);
-       }
-
-       @Test
-       public void testGetMd5Checksum() throws Exception {
-               ImportMetadata testSubject;
-               String result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.getMd5Checksum();
-       }
-
-       @Test
-       public void testSetMd5Checksum() throws Exception {
-               ImportMetadata testSubject;
-               String md5Checksum = "";
-
-               // default test
-               testSubject = createTestSubject();
-               testSubject.setMd5Checksum(md5Checksum);
-       }
 }
\ No newline at end of file
diff --git a/catalog-fe/src/test/java/org/openecomp/sdc/fe/impl/MdcDataTest.java b/catalog-fe/src/test/java/org/openecomp/sdc/fe/impl/MdcDataTest.java
new file mode 100644 (file)
index 0000000..d074706
--- /dev/null
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
+ */
+package org.openecomp.sdc.fe.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class MdcDataTest {
+
+       private static final String INSTANCE_ID = "INSTANCE_ID";
+       private static final String USER_ID = "USER_ID";
+       private static final String REMOTE_ADDRESS = "REMOTE_ADDRESS";
+       private static final String LOCAL_ADDRESS = "LOCAL_ADDRESS";
+       private static final long TRANSACTION_START_TIME = 123L;
+
+       @Test
+       public void testGetTransactionStartTimeIsSetByConstructor() {
+               MdcData testSubject = createTestSubject();
+               assertEquals(testSubject.getTransactionStartTime(), Long.valueOf(TRANSACTION_START_TIME));
+       }
+
+       @Test
+       public void testGetUserIdIsSetByConstructor() {
+               MdcData testSubject = createTestSubject();
+               assertEquals(testSubject.getUserId(), USER_ID);
+       }
+
+       @Test
+       public void testGetRemoteAddrIsSetByConstructor() {
+               MdcData testSubject = createTestSubject();
+               assertEquals(testSubject.getRemoteAddr(), REMOTE_ADDRESS);
+       }
+
+       @Test
+       public void testGetLocalAddrIsSetByConstructor() {
+               MdcData testSubject = createTestSubject();
+               assertEquals(testSubject.getLocalAddr(), LOCAL_ADDRESS);
+       }
+
+       @Test
+       public void testGetServiceInstanceIDIsSetByConstructor(){
+               MdcData testSubject = createTestSubject();
+               assertEquals(testSubject.getServiceInstanceID(), INSTANCE_ID);
+       }
+
+       private MdcData createTestSubject() {
+               return new MdcData(INSTANCE_ID, USER_ID, REMOTE_ADDRESS, LOCAL_ADDRESS, TRANSACTION_START_TIME);
+       }
+
+}
\ No newline at end of file
diff --git a/catalog-fe/src/test/java/org/openecomp/sdc/fe/mdc/MdcDataTest.java b/catalog-fe/src/test/java/org/openecomp/sdc/fe/mdc/MdcDataTest.java
deleted file mode 100644 (file)
index d941431..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.openecomp.sdc.fe.mdc;
-
-import org.junit.Test;
-
-public class MdcDataTest {
-
-       private MdcData createTestSubject() {
-               return new MdcData("", "", "", "", null);
-       }
-
-       @Test
-       public void testGetTransactionStartTime() throws Exception {
-               MdcData testSubject;
-               Long result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.getTransactionStartTime();
-       }
-
-       @Test
-       public void testGetUserId() throws Exception {
-               MdcData testSubject;
-               String result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.getUserId();
-       }
-
-       @Test
-       public void testGetRemoteAddr() throws Exception {
-               MdcData testSubject;
-               String result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.getRemoteAddr();
-       }
-
-       @Test
-       public void testGetLocalAddr() throws Exception {
-               MdcData testSubject;
-               String result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.getLocalAddr();
-       }
-
-       @Test
-       public void testGetServiceInstanceID() throws Exception {
-               MdcData testSubject;
-               String result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.getServiceInstanceID();
-       }
-}
\ No newline at end of file