Test coverage : openecomp-sdc-notification-api 46/70146/3
authorsiddharth0905 <siddharth.singh4@amdocs.com>
Wed, 10 Oct 2018 09:04:47 +0000 (14:34 +0530)
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>
Thu, 11 Oct 2018 09:34:08 +0000 (09:34 +0000)
Increase test coverage

Change-Id: I13ddec81fd06542d3d11e4236d76416309ae32d9
Issue-ID: SDC-1673
Signed-off-by: siddharth0905 <siddharth.singh4@amdocs.com>
openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/pom.xml
openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/LastSeenNotificationEntity.java
openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/NotificationEntity.java
openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/SubscribersEntity.java
openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/test/java/org/openecomp/sdc/notification/dao/types/NotificationEntityTest.java

index 581f002..f191564 100644 (file)
         <dependency>
             <groupId>org.testng</groupId>
             <artifactId>testng</artifactId>
-            <version>${testng.version}</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 </project>
index bdd2ad4..97aba63 100644 (file)
@@ -20,74 +20,25 @@ import com.datastax.driver.mapping.annotations.Column;
 import com.datastax.driver.mapping.annotations.PartitionKey;
 import com.datastax.driver.mapping.annotations.Table;
 
-import java.util.Objects;
 import java.util.UUID;
 
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
 @Table(keyspace = "dox", name = "last_notification")
 public class LastSeenNotificationEntity {
-  public static final String ENTITY_TYPE = "Event Notification";
-
-  @PartitionKey
-  @Column(name = "owner_id")
-  private String ownerId;
-
-  @Column(name = "event_id")
-  private UUID lastEventId;
-
-  /**
-   * Every entity class must have a default constructor according to
-   * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
-   * Definition of mapped classes</a>.
-   */
-  public LastSeenNotificationEntity() {
-    // Don't delete! Default constructor is required by DataStax driver
-  }
-
-  /**
-   * Instantiates a new Notification entity.
-   *
-   * @param ownerId      the owner id
-   * @param lastEventId  the last event id
-   */
-  public LastSeenNotificationEntity(String ownerId, UUID lastEventId) {
-    this.ownerId = ownerId;
-    this.lastEventId = lastEventId;
-  }
-
-  public String getOwnerId() {
-    return ownerId;
-  }
-
-  public void setOwnerId(String ownerId) {
-    this.ownerId = ownerId;
-  }
-
-  public UUID getLastEventId() {
-    return lastEventId;
-  }
-
-  public void setLastEventId(UUID lastEventId) {
-    this.lastEventId = lastEventId;
-  }
 
-  @Override
-  public boolean equals(Object o) {
-    if (this == o) return true;
-    if (o == null || getClass() != o.getClass()) return false;
-    LastSeenNotificationEntity that = (LastSeenNotificationEntity) o;
-    return Objects.equals(ownerId, that.ownerId) &&
-            Objects.equals(lastEventId, that.lastEventId);
-  }
+    public static final String ENTITY_TYPE = "Event Notification";
 
-  @Override
-  public int hashCode() {
-    return Objects.hash(ownerId, lastEventId);
-  }
+    @PartitionKey
+    @Column(name = "owner_id")
+    private String ownerId;
 
-  @Override
-  public String toString() {
-    return "LastSeenNotificationEntity {"
-        + "ownerId='" + ownerId + '\''
-       + '}';
-  }
+    @Column(name = "event_id")
+    private UUID lastEventId;
 }
index 85af302..b45a2a0 100644 (file)
@@ -21,149 +21,49 @@ import com.datastax.driver.mapping.annotations.Column;
 import com.datastax.driver.mapping.annotations.PartitionKey;
 import com.datastax.driver.mapping.annotations.Table;
 
-import java.util.Objects;
 import java.util.UUID;
 
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
 @Table(keyspace = "dox", name = "notifications")
 public class NotificationEntity {
 
-  public static final String ENTITY_TYPE = "Event Notification";
-
-  @PartitionKey
-  @Column(name = "owner_id")
-  private String ownerId;
-
-  @Column(name = "read")
-  private boolean read;
-
-  @ClusteringColumn
-  @Column(name = "event_id")
-  private UUID eventId;
-
-  @Column(name = "event_type")
-  private String eventType;
-
-  @Column(name = "event_attributes")
-  private String eventAttributes;
-
-  @Column(name = "originator_id")
-  private String originatorId;
-
-  /**
-   * Every entity class must have a default constructor according to
-   * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
-   * Definition of mapped classes</a>.
-   */
-  public NotificationEntity() {
-    // Don't delete! Default constructor is required by DataStax driver
-  }
-
-  public NotificationEntity(String ownerId) {
-    this.ownerId = ownerId;
-  }
-
-  /**
-   * Instantiates a new Notification entity.
-   *
-   * @param ownerId      the owner id
-   * @param eventId      the event id
-   * @param eventType    the event type
-   * @param originatorId the originator id
-   */
-  public NotificationEntity(String ownerId, UUID eventId, String eventType, String originatorId, boolean read,
-                            String eventAttributes) {
-    this.ownerId = ownerId;
-    this.read = read;
-    this.eventId = eventId;
-    this.eventType = eventType;
-    this.originatorId = originatorId;
-    this.eventAttributes = eventAttributes;
-  }
-
-  public NotificationEntity(String ownerId, UUID eventId, String eventType, String originatorId) {
-               this(ownerId, eventId, eventType, originatorId, false, null);
-  }
-
-  public NotificationEntity(String ownerId, UUID eventId) {
-               this(ownerId, eventId, null, null);
-  }
-
-  public String getOwnerId() {
-    return ownerId;
-  }
-
-  public void setOwnerId(String ownerId) {
-    this.ownerId = ownerId;
-  }
-
-  public boolean isRead() {
-    return read;
-  }
-
-  public void setRead(boolean read) {
-    this.read = read;
-  }
-
-  public UUID getEventId() {
-    return eventId;
-  }
-
-  public void setEventId(UUID eventId) {
-    this.eventId = eventId;
-  }
-
-  public String getEventType() {
-    return eventType;
-  }
+    public static final String ENTITY_TYPE = "Event Notification";
 
-  public void setEventType(String eventType) {
-    this.eventType = eventType;
-  }
+    @PartitionKey
+    @Column(name = "owner_id")
+    private String ownerId;
 
-  public String getEventAttributes() {
-    return eventAttributes;
-  }
+    @Column(name = "read")
+    private boolean read;
 
-  public void setEventAttributes(String eventAttributes) {
-    this.eventAttributes = eventAttributes;
-  }
+    @ClusteringColumn
+    @Column(name = "event_id")
+    private UUID eventId;
 
-  public String getOriginatorId() {
-    return originatorId;
-  }
+    @Column(name = "event_type")
+    private String eventType;
 
-  public void setOriginatorId(String originatorId) {
-    this.originatorId = originatorId;
-  }
+    @Column(name = "event_attributes")
+    private String eventAttributes;
 
+    @Column(name = "originator_id")
+    private String originatorId;
 
-  @Override
-  public boolean equals(Object o) {
-    if (this == o) return true;
-    if (o == null || getClass() != o.getClass()) return false;
-    NotificationEntity that = (NotificationEntity) o;
-    return read == that.read &&
-            Objects.equals(ownerId, that.ownerId) &&
-            Objects.equals(eventId, that.eventId) &&
-            Objects.equals(eventType, that.eventType) &&
-            Objects.equals(eventAttributes, that.eventAttributes) &&
-            Objects.equals(originatorId, that.originatorId);
-  }
+    public NotificationEntity(String ownerId) {
+        this.ownerId = ownerId;
+    }
 
-  @Override
-  public int hashCode() {
-    return Objects.hash(ownerId, read, eventId, eventType, eventAttributes, originatorId);
-  }
+    public NotificationEntity(String ownerId, UUID eventId, String eventType, String originatorId) {
+        this(ownerId, false, eventId, eventType, null, originatorId);
+    }
 
-  @Override
-  public String toString() {
-    return "NotificationEntity {"
-        + "ownerId='" + ownerId + '\''
-        + ", state='" + (read ? "Read" : "Noread") + '\''
-        + ", originatorId='" + originatorId + '\''
-        + ", eventId='" + eventId + '\''
-        + ", eventType='" + eventType + '\''
-        + ", eventAttributes='" + eventAttributes + '\''
-        + '}';
-  }
+    public NotificationEntity(String ownerId, UUID eventId) {
+        this(ownerId, eventId, null, null);
+    }
 }
index 1f3d04a..b1b80cd 100644 (file)
@@ -20,11 +20,15 @@ import com.datastax.driver.mapping.annotations.Column;
 import com.datastax.driver.mapping.annotations.PartitionKey;
 import com.datastax.driver.mapping.annotations.Table;
 
-import java.util.Objects;
 import java.util.Set;
 
-import static java.util.Objects.hash;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
 
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
 @Table(keyspace = "dox", name = "notification_subscribers")
 public class SubscribersEntity {
 
@@ -34,56 +38,4 @@ public class SubscribersEntity {
 
     @Column(name = "subscribers")
     private Set<String> subscribers;
-
-    /**
-     * Every entity class must have a default constructor according to
-     * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
-     * Definition of mapped classes</a>.
-     */
-    public SubscribersEntity() {
-        // Don't delete! Default constructor is required by DataStax driver
-    }
-
-    public SubscribersEntity(String entityId, Set<String> subscribers) {
-        this.entityId = entityId;
-        this.subscribers = subscribers;
-    }
-
-    public String getEntityId() {
-        return entityId;
-    }
-
-    public void setEntityId(String entityId) {
-        this.entityId = entityId;
-    }
-
-    public Set<String> getSubscribers() {
-        return subscribers;
-    }
-
-    public void setSubscribers(Set<String> subscribers) {
-        this.subscribers = subscribers;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-        SubscribersEntity that = (SubscribersEntity) o;
-        return Objects.equals(entityId, that.entityId) &&
-                Objects.equals(subscribers, that.subscribers);
-    }
-
-    @Override
-    public int hashCode() {
-        return hash(entityId, subscribers);
-    }
-
-    @Override
-    public String toString() {
-        return "SubscribersEntity{" +
-                "entityId='" + entityId + '\'' +
-                ", subscribers=" + subscribers +
-                '}';
-    }
 }
index fc5792b..eff4d24 100644 (file)
 
 package org.openecomp.sdc.notification.dao.types;
 
-import org.testng.annotations.Test;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotEquals;
 
 import java.util.UUID;
 
-import static org.testng.Assert.*;
+import org.testng.annotations.Test;
 
 /**
  * @author EVITALIY
@@ -94,7 +95,7 @@ public class NotificationEntityTest {
     }
 
     private NotificationEntity createNotificationEntity(UUID random) {
-        return new NotificationEntity("owner-" + random, random, "type-" + random,
-                "originator-" + random, true, "attributes-" + random);
+        return new NotificationEntity("owner-" + random, true, random, "type-" + random, "attributes-" + random,
+                "originator-" + random);
     }
 }
\ No newline at end of file