diff options
author | ZhangZihao <zhangzihao@chinamobile.com> | 2019-07-16 16:49:27 +0800 |
---|---|---|
committer | Zihao Zhang <zhangzihao@chinamobile.com> | 2019-07-17 02:37:42 +0000 |
commit | 9cf94ff1acf4764085acf5b340b876ab82829e5f (patch) | |
tree | 879f66bb951af91d56a64d2a21839c7ab1e586bf /components/datalake-handler/feeder/src/test | |
parent | c4c391b68ed1a30b3b398c56efadf28b2f33388d (diff) |
design modify 2
Change-Id: I839bee562f03e12de9a3a4bfcd25f4db5fee6f7e
Issue-ID: DCAEGEN2-1658
Signed-off-by: ZhangZihao <zhangzihao@chinamobile.com>
Diffstat (limited to 'components/datalake-handler/feeder/src/test')
7 files changed, 2 insertions, 250 deletions
diff --git a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/DesignControllerTest.java b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/DesignControllerTest.java index 9509bdd3..670f100d 100644 --- a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/DesignControllerTest.java +++ b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/DesignControllerTest.java @@ -166,11 +166,6 @@ public class DesignControllerTest { design.setNote("test"); DesignType designType = new DesignType(); designType.setName("Kibana Dashboard"); - Portal portal = new Portal(); - portal.setName("Kibana"); - portal.setHost("127.0.0.1"); - portal.setPort(5601); - designType.setPortal(portal); design.setDesignType(designType); design.setTopicName(new TopicName("unauthenticated.SEC_FAULT_OUTPUT")); return design; diff --git a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/DesignTypeControllerTest.java b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/DesignTypeControllerTest.java index 69e592a2..79c0c846 100644 --- a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/DesignTypeControllerTest.java +++ b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/DesignTypeControllerTest.java @@ -27,7 +27,6 @@ import org.mockito.InjectMocks; import org.mockito.MockitoAnnotations; import org.mockito.junit.MockitoJUnitRunner; import org.onap.datalake.feeder.domain.DesignType; -import org.onap.datalake.feeder.domain.Portal; import org.onap.datalake.feeder.service.DesignTypeService; import java.lang.reflect.Field; @@ -69,11 +68,6 @@ public class DesignTypeControllerTest { public DesignType fillDomain(){ DesignType designType = new DesignType(); designType.setName("Kibana Dashboard"); - Portal portal = new Portal(); - portal.setName("Kibana"); - portal.setHost("127.0.0.1"); - portal.setPort(5601); - designType.setPortal(portal); return designType; } }
\ No newline at end of file diff --git a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/PortalControllerTest.java b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/PortalControllerTest.java deleted file mode 100644 index 9e843ea5..00000000 --- a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/PortalControllerTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * ============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.controller; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.mockito.junit.MockitoJUnitRunner; -import org.onap.datalake.feeder.controller.domain.PostReturnBody; -import org.onap.datalake.feeder.domain.Db; -import org.onap.datalake.feeder.domain.Portal; -import org.onap.datalake.feeder.dto.PortalConfig; -import org.onap.datalake.feeder.repository.PortalRepository; -import org.onap.datalake.feeder.service.PortalService; -import org.springframework.validation.BindingResult; - -import javax.servlet.http.HttpServletResponse; - -import java.io.IOException; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.when; - -@RunWith(MockitoJUnitRunner.class) -public class PortalControllerTest { - - @Mock - private HttpServletResponse httpServletResponse; - - @Mock - private BindingResult mockBindingResult; - - @Mock - private PortalRepository portalRepository; - - @InjectMocks - private PortalService portalService; - - @Before - public void setupTest() { - MockitoAnnotations.initMocks(this); - when(mockBindingResult.hasErrors()).thenReturn(false); - } - - - @Test - public void testUpdatePortal() throws NoSuchFieldException, IllegalAccessException, IOException { - - PortalController testPortalController = new PortalController(); - setAccessPrivateFields(testPortalController); - Portal testPortal = fillDomain(); - when(portalRepository.findById("Kibana")).thenReturn(Optional.of(testPortal)); - PostReturnBody<PortalConfig> postPortal = testPortalController.updatePortal(testPortal.getPortalConfig(), mockBindingResult, httpServletResponse); - assertEquals(postPortal.getStatusCode(), 200); - //when(mockBindingResult.hasErrors()).thenReturn(true); - - } - - - @Test - public void testGetPortals() throws NoSuchFieldException, IllegalAccessException { - - PortalController testPortalController = new PortalController(); - setAccessPrivateFields(testPortalController); - Portal testPortal = fillDomain(); - List<Portal> portalList = new ArrayList<>(); - portalList.add(testPortal); - when(portalRepository.findAll()).thenReturn(portalList); - assertEquals(1, testPortalController.getPortals().size()); - - } - - - public void setAccessPrivateFields(PortalController portalController) throws NoSuchFieldException, IllegalAccessException { - - Field testPortalService = portalController.getClass().getDeclaredField("portalService"); - testPortalService.setAccessible(true); - testPortalService.set(portalController, portalService); - Field testPortalRepository = portalController.getClass().getDeclaredField("portalRepository"); - testPortalRepository.setAccessible(true); - testPortalRepository.set(portalController, portalRepository); - } - - - public Portal fillDomain(){ - Portal portal = new Portal(); - portal.setName("Kibana"); - portal.setEnabled(true); - portal.setHost("127.0.0.1"); - portal.setPort(5601); - portal.setLogin("admin"); - portal.setPass("password"); - portal.setDb(new Db()); - return portal; - } -}
\ No newline at end of file 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 index ad930630..e02c2d1c 100644 --- 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 @@ -31,19 +31,13 @@ public class DesignTypeTest { DesignType designType = new DesignType(); designType.setName("Kibana Dashboard"); designType.setNote("test"); - Portal portal = new Portal(); - portal.setName("Kibana"); - designType.setPortal(portal); assertEquals("Kibana Dashboard", designType.getName()); assertEquals("test", designType.getNote()); - assertNotEquals("Kibana", designType.getPortal()); designType.setDbType(null); designType.getDbType(); - designType.setDesigns(null); designType.getDesigns(); - designType.getDesignTypeConfig(); } }
\ 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 deleted file mode 100644 index 442d7f19..00000000 --- a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/domain/PortalTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * ============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 org.onap.datalake.feeder.util.TestUtil; - -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(TestUtil.newDb("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 deleted file mode 100644 index 4709b04a..00000000 --- a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/dto/PortalConfigTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * ============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 org.onap.datalake.feeder.util.TestUtil; - -import static org.junit.Assert.*; - -public class PortalConfigTest { - - @Test - public void testIs(){ - - Portal testPortal = new Portal(); - testPortal.setName("Kibana"); - testPortal.setDb(TestUtil.newDb("Elasticsearch")); - Portal testPortal2 = new Portal(); - testPortal2.setName("Kibana"); - testPortal2.setDb(TestUtil.newDb("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); - assertEquals(testPortalConfig.getDb(), "Elasticsearch"); - } -}
\ No newline at end of file diff --git a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/service/DesignServiceTest.java b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/service/DesignServiceTest.java index 3c877189..65b373f5 100644 --- a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/service/DesignServiceTest.java +++ b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/service/DesignServiceTest.java @@ -25,10 +25,8 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.onap.datalake.feeder.config.ApplicationConfiguration; -import org.onap.datalake.feeder.domain.Db; import org.onap.datalake.feeder.domain.Design; import org.onap.datalake.feeder.domain.DesignType; -import org.onap.datalake.feeder.domain.Portal; import static org.mockito.Mockito.when; @@ -50,14 +48,8 @@ public class DesignServiceTest { Design design = new Design(); design.setDesignType(designType); design.setBody("jsonString"); - - Portal portal = new Portal(); - Db db = new Db(); - db.setHost("localhost"); - portal.setDb(db); - when(designType.getPortal()).thenReturn(portal); - when(applicationConfiguration.getKibanaDashboardImportApi()).thenReturn("/api/kibana/dashboards/import?exclude=index-pattern"); - when(applicationConfiguration.getKibanaPort()).thenReturn(5601); + //when(applicationConfiguration.getKibanaDashboardImportApi()).thenReturn("/api/kibana/dashboards/import?exclude=index-pattern"); + //when(applicationConfiguration.getKibanaPort()).thenReturn(5601); designService.deploy(design); System.out.println(); } |