From 6e1a53af3af64578619763238649ed7b76865241 Mon Sep 17 00:00:00 2001 From: Tomek Kaminski Date: Wed, 22 May 2019 19:35:27 +0200 Subject: Refactor tests for TopicResource class Change-Id: Iff89df7e1b43ec13b200282a2d74882d95c3d84e Issue-ID: DMAAP-1209 Signed-off-by: Tomek Kaminski --- .../java/org/onap/dmaap/dbcapi/model/Topic.java | 22 ++++++++++++++++++++++ .../onap/dmaap/dbcapi/resources/TopicResource.java | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/dmaap/dbcapi/model/Topic.java b/src/main/java/org/onap/dmaap/dbcapi/model/Topic.java index cffe448..b715a24 100644 --- a/src/main/java/org/onap/dmaap/dbcapi/model/Topic.java +++ b/src/main/java/org/onap/dmaap/dbcapi/model/Topic.java @@ -20,6 +20,7 @@ package org.onap.dmaap.dbcapi.model; +import com.google.common.base.Objects; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Date; @@ -330,4 +331,25 @@ public class Topic extends DmaapObject { public byte[] getBytes() { return toProvJSON().getBytes(StandardCharsets.UTF_8); } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Topic topic = (Topic) o; + return Objects.equal(fqtn, topic.fqtn) && + Objects.equal(topicName, topic.topicName) && + Objects.equal(tnxEnabled, topic.tnxEnabled) && + Objects.equal(owner, topic.owner); + } + + @Override + public int hashCode() { + return Objects.hashCode(fqtn, topicName, tnxEnabled, owner); + } } diff --git a/src/main/java/org/onap/dmaap/dbcapi/resources/TopicResource.java b/src/main/java/org/onap/dmaap/dbcapi/resources/TopicResource.java index 3206cf7..01926b7 100644 --- a/src/main/java/org/onap/dmaap/dbcapi/resources/TopicResource.java +++ b/src/main/java/org/onap/dmaap/dbcapi/resources/TopicResource.java @@ -63,6 +63,7 @@ public class TopicResource extends BaseLoggingClass { private TopicService mr_topicService = new TopicService(); private ResponseBuilder responseBuilder = new ResponseBuilder(); private RequiredChecker checker = new RequiredChecker(); + static final String UNSUPPORTED_PUT_MSG = "Method /PUT not supported for /topics"; public TopicResource() { DmaapConfig p = (DmaapConfig)DmaapConfig.getConfig(); @@ -157,7 +158,7 @@ public class TopicResource extends BaseLoggingClass { ApiError apiError = new ApiError(); apiError.setCode(Status.BAD_REQUEST.getStatusCode()); - apiError.setMessage( "Method /PUT not supported for /topics"); + apiError.setMessage(UNSUPPORTED_PUT_MSG); return responseBuilder.error(apiError); } -- cgit 1.2.3-korg