summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src')
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/LastSeenNotificationEntity.java77
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/NotificationEntity.java162
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/SubscribersEntity.java60
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/test/java/org/openecomp/sdc/notification/dao/types/NotificationEntityTest.java9
4 files changed, 56 insertions, 252 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/LastSeenNotificationEntity.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/LastSeenNotificationEntity.java
index bdd2ad4fad..97aba63f1c 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/LastSeenNotificationEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/LastSeenNotificationEntity.java
@@ -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;
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/NotificationEntity.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/NotificationEntity.java
index 85af302205..b45a2a0c7d 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/NotificationEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/NotificationEntity.java
@@ -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);
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/SubscribersEntity.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/SubscribersEntity.java
index 1f3d04ab0d..b1b80cd135 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/SubscribersEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/SubscribersEntity.java
@@ -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 +
- '}';
- }
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/test/java/org/openecomp/sdc/notification/dao/types/NotificationEntityTest.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/test/java/org/openecomp/sdc/notification/dao/types/NotificationEntityTest.java
index fc5792b4d4..eff4d24995 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/test/java/org/openecomp/sdc/notification/dao/types/NotificationEntityTest.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/test/java/org/openecomp/sdc/notification/dao/types/NotificationEntityTest.java
@@ -16,11 +16,12 @@
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