summaryrefslogtreecommitdiffstats
path: root/src/test/java/com/att/nsa/cambria/metabroker
diff options
context:
space:
mode:
authorrn509j <rn509j@att.com>2017-09-30 18:45:25 -0400
committerrn509j <rn509j@att.com>2017-09-30 18:46:32 -0400
commit2881443ed939d6d3c1a55719cca95ee9e7483165 (patch)
tree8293edbe9f7a0ecbca9d4531ec8036826e48ae87 /src/test/java/com/att/nsa/cambria/metabroker
parent9b4fc97236c644f35a13fefff32c60808e4bab7e (diff)
commiting code for test coverage
DMAAP-149 Signed-off-by: rn509j <rn509j@att.com> Change-Id: Ie2eb909b5af3a2043bbe917f6cbcc3cb1efb07a8
Diffstat (limited to 'src/test/java/com/att/nsa/cambria/metabroker')
-rw-r--r--src/test/java/com/att/nsa/cambria/metabroker/BrokerImpl.java69
-rw-r--r--src/test/java/com/att/nsa/cambria/metabroker/BrokerImplTest.java109
-rw-r--r--src/test/java/com/att/nsa/cambria/metabroker/JUnitTestSuite.java42
-rw-r--r--src/test/java/com/att/nsa/cambria/metabroker/TestRunner.java41
-rw-r--r--src/test/java/com/att/nsa/cambria/metabroker/TopicImplTest.java25
-rw-r--r--src/test/java/com/att/nsa/cambria/metabroker/TopicImplem.java139
-rw-r--r--src/test/java/com/att/nsa/cambria/metabroker/TopicImplemTest.java176
7 files changed, 601 insertions, 0 deletions
diff --git a/src/test/java/com/att/nsa/cambria/metabroker/BrokerImpl.java b/src/test/java/com/att/nsa/cambria/metabroker/BrokerImpl.java
new file mode 100644
index 0000000..5e5638a
--- /dev/null
+++ b/src/test/java/com/att/nsa/cambria/metabroker/BrokerImpl.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * 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=========================================================
+ */
+
+package com.att.nsa.cambria.metabroker;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.att.nsa.cambria.CambriaApiException;
+import com.att.nsa.configs.ConfigDbException;
+import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
+
+public class BrokerImpl implements Broker {
+
+ @Override
+ public List<Topic> getAllTopics() throws ConfigDbException {
+ // TODO Auto-generated method stub
+ Topic top = new TopicImplem();
+
+ List<Topic> list = new ArrayList<Topic>();
+
+ for (int i = 0; i < 5; i++) {
+ top = new TopicImplem();
+ list.add(top);
+
+ }
+
+ return null;
+
+ }
+
+ @Override
+ public Topic getTopic(String topic) throws ConfigDbException {
+ // TODO Auto-generated method stub
+ return new TopicImplem();
+ }
+
+ @Override
+ public Topic createTopic(String topic, String description, String ownerApiKey, int partitions, int replicas,
+ boolean transactionEnabled) throws TopicExistsException, CambriaApiException {
+ // TODO Auto-generated method stub
+ return new TopicImplem(topic, description, ownerApiKey, transactionEnabled);
+ }
+
+ @Override
+ public void deleteTopic(String topic) throws AccessDeniedException, CambriaApiException, TopicExistsException {
+ // TODO Auto-generated method stub
+ Topic top = new TopicImplem();
+
+ }
+
+}
diff --git a/src/test/java/com/att/nsa/cambria/metabroker/BrokerImplTest.java b/src/test/java/com/att/nsa/cambria/metabroker/BrokerImplTest.java
new file mode 100644
index 0000000..0cc1d30
--- /dev/null
+++ b/src/test/java/com/att/nsa/cambria/metabroker/BrokerImplTest.java
@@ -0,0 +1,109 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * 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=========================================================
+ */
+
+
+package com.att.nsa.cambria.metabroker;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.att.nsa.cambria.CambriaApiException;
+import com.att.nsa.cambria.metabroker.Broker.TopicExistsException;
+import com.att.nsa.configs.ConfigDbException;
+import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
+
+public class BrokerImplTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGetOwners() {
+
+ try {
+ new BrokerImpl().getAllTopics();
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ assertTrue(true);
+ }
+
+ @Test
+ public void testGetTopic() {
+
+ try {
+ new BrokerImpl().getTopic("topicName");
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testCreateTopic() {
+
+ try {
+ new BrokerImpl().createTopic("topicName", "testing topic", "owner123", 3, 3, true);
+
+ } catch (CambriaApiException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (TopicExistsException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testDeleteTopic() {
+
+ try {
+ new BrokerImpl().deleteTopic("topicName");
+ } catch (CambriaApiException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (TopicExistsException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ assertTrue(true);
+
+ }
+}
diff --git a/src/test/java/com/att/nsa/cambria/metabroker/JUnitTestSuite.java b/src/test/java/com/att/nsa/cambria/metabroker/JUnitTestSuite.java
new file mode 100644
index 0000000..0e2535b
--- /dev/null
+++ b/src/test/java/com/att/nsa/cambria/metabroker/JUnitTestSuite.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * 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=========================================================
+ */
+
+package com.att.nsa.cambria.metabroker;
+
+import junit.framework.TestSuite;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+import org.apache.log4j.Logger;
+
+@RunWith(Suite.class)
+@SuiteClasses({ BrokerImplTest.class, TopicImplemTest.class, })
+public class JUnitTestSuite {
+ private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class);
+
+ public static void main(String[] args) {
+ LOGGER.info("Running the test suite");
+
+ TestSuite tstSuite = new TestSuite();
+ LOGGER.info("Total Test Counts " + tstSuite.countTestCases());
+ }
+
+}
diff --git a/src/test/java/com/att/nsa/cambria/metabroker/TestRunner.java b/src/test/java/com/att/nsa/cambria/metabroker/TestRunner.java
new file mode 100644
index 0000000..e96d9c2
--- /dev/null
+++ b/src/test/java/com/att/nsa/cambria/metabroker/TestRunner.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * 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=========================================================
+ */
+
+package com.att.nsa.cambria.metabroker;
+
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+import org.apache.log4j.Logger;
+
+public class TestRunner {
+ private static final Logger LOGGER = Logger.getLogger(TestRunner.class);
+
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+ Result result = JUnitCore.runClasses(JUnitTestSuite.class);
+ for (Failure failure : result.getFailures()) {
+ LOGGER.info(failure.toString());
+
+ }
+ LOGGER.info(result.wasSuccessful());
+ }
+
+}
diff --git a/src/test/java/com/att/nsa/cambria/metabroker/TopicImplTest.java b/src/test/java/com/att/nsa/cambria/metabroker/TopicImplTest.java
new file mode 100644
index 0000000..67cf60d
--- /dev/null
+++ b/src/test/java/com/att/nsa/cambria/metabroker/TopicImplTest.java
@@ -0,0 +1,25 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * 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=========================================================
+ */
+
+package com.att.nsa.cambria.metabroker;
+
+public class TopicImplTest {
+
+}
diff --git a/src/test/java/com/att/nsa/cambria/metabroker/TopicImplem.java b/src/test/java/com/att/nsa/cambria/metabroker/TopicImplem.java
new file mode 100644
index 0000000..e5423ab
--- /dev/null
+++ b/src/test/java/com/att/nsa/cambria/metabroker/TopicImplem.java
@@ -0,0 +1,139 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * 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=========================================================
+ */
+
+package com.att.nsa.cambria.metabroker;
+
+import java.util.Set;
+
+import com.att.nsa.configs.ConfigDbException;
+import com.att.nsa.security.NsaAcl;
+import com.att.nsa.security.NsaApiKey;
+
+public class TopicImplem implements Topic {
+ private String name, owner, description;
+ boolean isTransactionEnabled;
+ private Set<String> set = null;
+ private NsaAcl readerAcl, writerAcl;
+
+ public TopicImplem() {
+ name = getName();
+ owner = getOwner();
+ description = getDescription();
+ isTransactionEnabled = true;
+ readerAcl = getReaderAcl();
+ writerAcl = getWriterAcl();
+ }
+
+ public TopicImplem(String topic, String description, String ownerApiKey, boolean transactionEnabled) {
+
+ this.name = topic;
+ this.owner = ownerApiKey;
+ this.description = description;
+ isTransactionEnabled = transactionEnabled;
+
+
+ }
+ @Override
+ public Set<String> getOwners() {
+ // TODO Auto-generated method stub
+ for (int i = 0; i < 5; i++) {
+ set.add("string" + (i + 1));
+ }
+ return set;
+ }
+
+ @Override
+ public String getName() {
+ // TODO Auto-generated method stub
+ return "testTopic";
+ }
+
+ @Override
+ public String getOwner() {
+ // TODO Auto-generated method stub
+ return "owner";
+ }
+
+ @Override
+ public String getDescription() {
+ // TODO Auto-generated method stub
+ return "topic for testing purposes";
+ }
+
+ @Override
+ public boolean isTransactionEnabled() {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+ @Override
+ public NsaAcl getReaderAcl() {
+ // TODO Auto-generated method stub
+ return new NsaAcl();
+ }
+
+ @Override
+ public NsaAcl getWriterAcl() {
+ // TODO Auto-generated method stub
+ return new NsaAcl();
+ }
+
+ @Override
+ public void checkUserRead(NsaApiKey user) throws AccessDeniedException {
+ // TODO Auto-generated method stub
+ NsaApiKey u = user;
+ }
+
+ @Override
+ public void checkUserWrite(NsaApiKey user) throws AccessDeniedException {
+ // TODO Auto-generated method stub
+
+ NsaApiKey u = user;
+ }
+
+ @Override
+ public void permitWritesFromUser(String publisherId, NsaApiKey asUser)
+ throws AccessDeniedException, ConfigDbException {
+ // TODO Auto-generated method stub
+ String id = publisherId;
+
+ }
+
+ @Override
+ public void denyWritesFromUser(String publisherId, NsaApiKey asUser)
+ throws AccessDeniedException, ConfigDbException {
+ // TODO Auto-generated method stub
+ String id = publisherId;
+
+ }
+
+ @Override
+ public void permitReadsByUser(String consumerId, NsaApiKey asUser) throws AccessDeniedException, ConfigDbException {
+ // TODO Auto-generated method stub
+ String id = consumerId;
+ }
+
+ @Override
+ public void denyReadsByUser(String consumerId, NsaApiKey asUser) throws AccessDeniedException, ConfigDbException {
+ // TODO Auto-generated method stub
+ String id = consumerId;
+ }
+
+}
diff --git a/src/test/java/com/att/nsa/cambria/metabroker/TopicImplemTest.java b/src/test/java/com/att/nsa/cambria/metabroker/TopicImplemTest.java
new file mode 100644
index 0000000..c3ef097
--- /dev/null
+++ b/src/test/java/com/att/nsa/cambria/metabroker/TopicImplemTest.java
@@ -0,0 +1,176 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * 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=========================================================
+ */
+
+package com.att.nsa.cambria.metabroker;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.att.nsa.configs.ConfigDbException;
+import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
+
+public class TopicImplemTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+
+ @Test
+ public void testGetOwners() {
+
+ assertNotNull(new TopicImplem().getOwner());
+
+ }
+
+ @Test
+ public void testGetName() {
+
+ assertNotNull(new TopicImplem().getName());
+
+ }
+
+ @Test
+ public void testGetOwner() {
+
+ assertNotNull(new TopicImplem().getOwner());
+
+ }
+
+ @Test
+ public void testGetDescription() {
+
+ assertNotNull(new TopicImplem().getDescription());
+
+ }
+
+ @Test
+ public void testIsTransactionEnabled() {
+
+ assertTrue(new TopicImplem().isTransactionEnabled());
+
+ }
+
+ @Test
+ public void testGetReaderAcl() {
+ new TopicImplem().getReaderAcl();
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testGetWriterAcl() {
+ new TopicImplem().getReaderAcl();
+ assertTrue(true);
+
+ }
+
+
+ @Test
+ public void testCheckUserRead() {
+ try {
+ new TopicImplem().checkUserRead(null);
+ } catch (AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testCheckUserWrite() {
+ try {
+ new TopicImplem().checkUserWrite(null);
+ } catch (AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testPermitWritesFromUser() {
+ try {
+ new TopicImplem().permitWritesFromUser("publisherId", null);
+ } catch (AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testDenyWritesFromUser() {
+ try {
+ new TopicImplem().denyWritesFromUser("publisherId", null);
+ } catch (AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testPermitReadsByUser() {
+ try {
+ new TopicImplem().permitReadsByUser("consumerId", null);
+ } catch (AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+
+ @Test
+ public void testDenyReadsByUser() {
+ try {
+ new TopicImplem().denyReadsByUser("consumerId", null);
+ } catch (AccessDeniedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ConfigDbException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ assertTrue(true);
+
+ }
+}