changes in DR_PubResourceTest
[dmaap/dbcapi.git] / src / test / java / org / onap / dmaap / dbcapi / resources / TestFeedCreator.java
diff --git a/src/test/java/org/onap/dmaap/dbcapi/resources/TestFeedCreator.java b/src/test/java/org/onap/dmaap/dbcapi/resources/TestFeedCreator.java
new file mode 100644 (file)
index 0000000..e4dedb1
--- /dev/null
@@ -0,0 +1,49 @@
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * org.onap.dmaap\r
+ * ================================================================================\r
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+package org.onap.dmaap.dbcapi.resources;\r
+\r
+import static org.junit.Assert.assertTrue;\r
+\r
+import javax.ws.rs.client.Entity;\r
+import javax.ws.rs.core.MediaType;\r
+import javax.ws.rs.core.Response;\r
+import org.onap.dmaap.dbcapi.model.Feed;\r
+\r
+\r
+public class TestFeedCreator {\r
+\r
+\r
+    private final FastJerseyTestContainer testContainer;\r
+\r
+    public TestFeedCreator(FastJerseyTestContainer testContainer) {\r
+        this.testContainer = testContainer;\r
+    }\r
+\r
+    Feed addFeed(String name, String desc) {\r
+        Feed feed = new Feed(name, "1.0", desc, "dgl", "unrestricted");\r
+        Entity<Feed> reqEntity = Entity.entity(feed, MediaType.APPLICATION_JSON);\r
+        Response resp = testContainer.target("feeds").request().post(reqEntity, Response.class);\r
+        int rc = resp.getStatus();\r
+        System.out.println("POST feed resp=" + rc);\r
+        assertTrue(rc == 200 || rc == 409);\r
+        feed = resp.readEntity(Feed.class);\r
+        return feed;\r
+    }\r
+}\r