From 8ecf4157c3a740a89bfea06647e825e7b1a48d2b Mon Sep 17 00:00:00 2001 From: ZhangZihao Date: Tue, 11 Jun 2019 14:32:33 +0800 Subject: [PATCH] Unit test 1 Change-Id: I44ad9a41a35a056a9b8bc9d6c760acb5e5413b80 Issue-ID: DCAEGEN2-1468 Signed-off-by: ZhangZihao --- .../datalake/feeder/domain/DesignTypeTest.java | 43 ++++++++++++++++ .../datalake/feeder/domain/PortalDesignTest.java | 52 +++++++++++++++++++ .../onap/datalake/feeder/domain/PortalTest.java | 49 ++++++++++++++++++ .../onap/datalake/feeder/dto/PortalConfigTest.java | 50 ++++++++++++++++++ .../feeder/dto/PortalDesignConfigTest.java | 60 ++++++++++++++++++++++ 5 files changed, 254 insertions(+) create mode 100644 components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/domain/DesignTypeTest.java create mode 100644 components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/domain/PortalDesignTest.java create mode 100644 components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/domain/PortalTest.java create mode 100644 components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/dto/PortalConfigTest.java create mode 100644 components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/dto/PortalDesignConfigTest.java diff --git a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/domain/DesignTypeTest.java b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/domain/DesignTypeTest.java new file mode 100644 index 00000000..5f3b5993 --- /dev/null +++ b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/domain/DesignTypeTest.java @@ -0,0 +1,43 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : DATALAKE + * ================================================================================ + * Copyright 2019 China Mobile + *================================================================================= + * 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 org.onap.datalake.feeder.domain; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class DesignTypeTest { + + @Test + public void testIs(){ + + DesignType designType = new DesignType(); + designType.setName("Kibana Dashboard"); + designType.setNote("test"); + Portal portal = new Portal(); + portal.setName("Kibana"); + designType.setPortal(portal); + assertTrue("Kibana Dashboard".equals(designType.getName())); + assertTrue("test".equals(designType.getNote())); + assertFalse("Kibana".equals(designType.getPortal())); + } + +} \ No newline at end of file diff --git a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/domain/PortalDesignTest.java b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/domain/PortalDesignTest.java new file mode 100644 index 00000000..1f6d7619 --- /dev/null +++ b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/domain/PortalDesignTest.java @@ -0,0 +1,52 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : DATALAKE + * ================================================================================ + * Copyright 2019 China Mobile + *================================================================================= + * 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 org.onap.datalake.feeder.domain; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class PortalDesignTest { + + @Test + public void testIs() { + + PortalDesign portalDesign = new PortalDesign(); + portalDesign.setId(1); + portalDesign.setSubmitted(false); + portalDesign.setBody("jsonString"); + portalDesign.setName("templateTest"); + Topic topic = new Topic("_DL_DEFAULT_"); + portalDesign.setTopic(topic); + DesignType designType = new DesignType(); + designType.setName("Kibana"); + portalDesign.setDesignType(designType); + portalDesign.setNote("test"); + assertFalse("1".equals(portalDesign.getId())); + assertTrue("templateTest".equals(portalDesign.getName())); + assertTrue("jsonString".equals(portalDesign.getBody())); + assertFalse("_DL_DEFAULT_".equals(portalDesign.getTopic())); + assertTrue("test".equals(portalDesign.getNote())); + assertFalse("Kibana".equals(portalDesign.getDesignType())); + assertFalse("false".equals(portalDesign.getSubmitted())); + } + +} \ No newline at end of file diff --git a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/domain/PortalTest.java b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/domain/PortalTest.java new file mode 100644 index 00000000..8d52145c --- /dev/null +++ b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/domain/PortalTest.java @@ -0,0 +1,49 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : DATALAKE + * ================================================================================ + * Copyright 2019 China Mobile + *================================================================================= + * 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 org.onap.datalake.feeder.domain; + +import org.junit.Test; + +import static org.junit.Assert.*; +import static org.junit.Assert.assertTrue; + +public class PortalTest { + + @Test + public void testIs() { + + Portal portal = new Portal(); + portal.setName("Kibana"); + portal.setEnabled(true); + portal.setHost("localhost"); + portal.setPort(5601); + portal.setLogin("admin"); + portal.setPass("password"); + portal.setDb(new Db("Elasticsearch")); + assertTrue("Kibana".equals(portal.getName())); + assertFalse("true".equals(portal.getEnabled())); + assertTrue("localhost".equals(portal.getHost())); + assertFalse("5601".equals(portal.getPort())); + assertTrue("admin".equals(portal.getLogin())); + assertTrue("password".equals(portal.getPass())); + assertFalse("Elasticsearch".equals(portal.getDb())); + } +} \ No newline at end of file diff --git a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/dto/PortalConfigTest.java b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/dto/PortalConfigTest.java new file mode 100644 index 00000000..f13894c9 --- /dev/null +++ b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/dto/PortalConfigTest.java @@ -0,0 +1,50 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : DATALAKE + * ================================================================================ + * Copyright 2019 China Mobile + *================================================================================= + * 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 org.onap.datalake.feeder.dto; + +import org.junit.Test; +import org.onap.datalake.feeder.domain.Db; +import org.onap.datalake.feeder.domain.Portal; + +import static org.junit.Assert.*; + +public class PortalConfigTest { + + @Test + public void testIs(){ + + Portal testPortal = new Portal(); + testPortal.setName("Kibana"); + testPortal.setDb(new Db("Elasticsearch")); + Portal testPortal2 = new Portal(); + testPortal2.setName("Kibana"); + testPortal2.setDb(new Db("Elasticsearch")); + PortalConfig testPortalConfig = testPortal.getPortalConfig(); + assertNotEquals(testPortalConfig, testPortal2.getPortalConfig()); + assertNotEquals(testPortalConfig, testPortal); + assertNotEquals(testPortalConfig, null); + assertEquals(testPortalConfig.getHost(), null); + assertEquals(testPortalConfig.getPort(), null); + assertEquals(testPortalConfig.getEnabled(), null); + assertEquals(testPortalConfig.getLogin(), null); + assertEquals(testPortalConfig.getPass(), null); + } +} \ No newline at end of file diff --git a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/dto/PortalDesignConfigTest.java b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/dto/PortalDesignConfigTest.java new file mode 100644 index 00000000..d20dcb0a --- /dev/null +++ b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/dto/PortalDesignConfigTest.java @@ -0,0 +1,60 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : DATALAKE + * ================================================================================ + * Copyright 2019 China Mobile + *================================================================================= + * 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 org.onap.datalake.feeder.dto; + +import org.junit.Test; +import org.onap.datalake.feeder.domain.DesignType; +import org.onap.datalake.feeder.domain.PortalDesign; +import org.onap.datalake.feeder.domain.Topic; + +import static org.junit.Assert.*; + +public class PortalDesignConfigTest { + + @Test + public void testIs() { + + PortalDesign testPortaldesign = new PortalDesign(); + testPortaldesign.setId(1); + testPortaldesign.setTopic(new Topic("test")); + DesignType testDesignType = new DesignType(); + testDesignType.setName("test"); + testPortaldesign.setDesignType(testDesignType); + + PortalDesign testPortaldesign2 = new PortalDesign(); + testPortaldesign2.setId(1); + testPortaldesign2.setTopic(new Topic("test")); + DesignType testDesignType2 = new DesignType(); + testDesignType2.setName("test"); + testPortaldesign2.setDesignType(testDesignType2); + + PortalDesignConfig testPortalDesignConfig = testPortaldesign.getPortalDesignConfig(); + + assertNotEquals(testPortalDesignConfig, testPortaldesign2.getPortalDesignConfig()); + assertNotEquals(testPortalDesignConfig, null); + assertNotEquals(testPortalDesignConfig.getId(), null); + assertEquals(testPortalDesignConfig.getBody(), null); + assertEquals(testPortalDesignConfig.getNote(), null); + assertEquals(testPortalDesignConfig.getName(), null); + assertEquals(testPortalDesignConfig.getSubmitted(), null); + } + +} \ No newline at end of file -- 2.16.6