design modify 2 06/91506/5
authorZhangZihao <zhangzihao@chinamobile.com>
Tue, 16 Jul 2019 08:49:27 +0000 (16:49 +0800)
committerZihao Zhang <zhangzihao@chinamobile.com>
Wed, 17 Jul 2019 02:37:42 +0000 (02:37 +0000)
Change-Id: I839bee562f03e12de9a3a4bfcd25f4db5fee6f7e
Issue-ID: DCAEGEN2-1658
Signed-off-by: ZhangZihao <zhangzihao@chinamobile.com>
18 files changed:
components/datalake-handler/feeder/src/assembly/scripts/init_db.sql
components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/PortalController.java [deleted file]
components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/domain/Design.java
components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/domain/DesignType.java
components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/domain/Portal.java [deleted file]
components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/dto/DesignConfig.java
components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/dto/PortalConfig.java [deleted file]
components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/repository/PortalRepository.java [deleted file]
components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/repository/TopicRepository.java
components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/service/DesignService.java
components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/service/PortalService.java [deleted file]
components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/DesignControllerTest.java
components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/DesignTypeControllerTest.java
components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/PortalControllerTest.java [deleted file]
components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/domain/DesignTypeTest.java
components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/domain/PortalTest.java [deleted file]
components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/dto/PortalConfigTest.java [deleted file]
components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/service/DesignServiceTest.java

index 1fd9aa8..028305d 100644 (file)
@@ -34,30 +34,15 @@ CREATE TABLE `db` (
   CONSTRAINT `FK3njadtw43ieph7ftt4kxdhcko` FOREIGN KEY (`db_type_id`) REFERENCES `db_type` (`id`)\r
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r
 \r
-CREATE TABLE `portal` (\r
-  `name` varchar(255) NOT NULL,\r
-  `enabled` bit(1) DEFAULT NULL,\r
-  `host` varchar(255) DEFAULT NULL,\r
-  `login` varchar(255) DEFAULT NULL,\r
-  `pass` varchar(255) DEFAULT NULL,\r
-  `port` int(11) DEFAULT NULL,\r
-  `related_db` int(11) DEFAULT NULL,\r
-  PRIMARY KEY (`name`),\r
-  KEY `FKtl6e8ydm1k7k9r5ukv9j0bd0n` (`related_db`),\r
-  CONSTRAINT `FKtl6e8ydm1k7k9r5ukv9j0bd0n` FOREIGN KEY (`related_db`) REFERENCES `db` (`id`)\r
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r
-\r
 CREATE TABLE `design_type` (\r
   `id` varchar(255) NOT NULL,\r
   `name` varchar(255) DEFAULT NULL,\r
   `note` varchar(255) DEFAULT NULL,\r
   `db_type_id` varchar(255) NOT NULL,\r
-  `portal` varchar(255) DEFAULT NULL,\r
   PRIMARY KEY (`id`),\r
   KEY `FKm8rkv2qkq01gsmeq1c3y4w02x` (`db_type_id`),\r
   KEY `FKs2nspbhf5wv5d152l4j69yjhi` (`portal`),\r
-  CONSTRAINT `FKm8rkv2qkq01gsmeq1c3y4w02x` FOREIGN KEY (`db_type_id`) REFERENCES `db_type` (`id`),\r
-  CONSTRAINT `FKs2nspbhf5wv5d152l4j69yjhi` FOREIGN KEY (`portal`) REFERENCES `portal` (`name`)\r
+  CONSTRAINT `FKm8rkv2qkq01gsmeq1c3y4w02x` FOREIGN KEY (`db_type_id`) REFERENCES `db_type` (`id`)\r
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r
 \r
 CREATE TABLE `design` (\r
diff --git a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/PortalController.java b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/PortalController.java
deleted file mode 100644 (file)
index 2844fac..0000000
+++ /dev/null
@@ -1,115 +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 io.swagger.annotations.ApiOperation;
-import org.onap.datalake.feeder.controller.domain.PostReturnBody;
-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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.MediaType;
-import org.springframework.validation.BindingResult;
-import org.springframework.web.bind.annotation.*;
-
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * This controller manages Portal settings
- *
- *
- * @author guochunmeng
- */
-@RestController
-@RequestMapping(value = "/portals", produces = { MediaType.APPLICATION_JSON_VALUE })
-public class PortalController {
-
-    private final Logger log = LoggerFactory.getLogger(this.getClass());
-
-    @Autowired
-    private PortalRepository portalRepository;
-
-    @Autowired
-    private PortalService portalService;
-
-    @PutMapping("")
-    @ResponseBody
-    @ApiOperation("update portal")
-    public PostReturnBody<PortalConfig> updatePortal(@RequestBody PortalConfig portalConfig, BindingResult result, HttpServletResponse response) throws IOException {
-
-        if (result.hasErrors()) {
-            sendError(response, 400, "Error binding PortalConfig: "+result.toString());
-            return null;
-        }
-
-        Portal portal = null;
-        try {
-            portal = portalRepository.findById(portalConfig.getName()).get();
-            log.info("Update portal "+portalConfig);
-            portalService.fillPortalConfiguration(portalConfig, portal);
-            portalRepository.save(portal);
-            return mkPostReturnBody(200, portal);
-        } catch (Exception e) {
-            log.debug("Update or delete portal failed, Portal: "+portalConfig, e.getMessage());
-            sendError(response, 400, "Error update or delete portal: "+portal);
-            return null;
-        }
-    }
-
-
-    @GetMapping("")
-    @ResponseBody
-    @ApiOperation(value = "List all portals")
-    public List<PortalConfig> getPortals() {
-
-        List<Portal> portalList = null;
-        List<PortalConfig> portalConfigList = new ArrayList<>();
-        portalList = (List<Portal>)portalRepository.findAll();
-        if (portalList != null && portalList.size() > 0) {
-            log.info("PortalList is not null");
-            for(Portal portal : portalList) {
-                portalConfigList.add(portal.getPortalConfig());
-            }
-        }
-        return portalConfigList;
-    }
-
-
-    private void sendError(HttpServletResponse response, int sc, String msg) throws IOException {
-        log.info(msg);
-        response.sendError(sc, msg);
-    }
-
-
-    private PostReturnBody<PortalConfig> mkPostReturnBody(int statusCode, Portal portal) {
-        PostReturnBody<PortalConfig> retBody = new PostReturnBody<>();
-        retBody.setStatusCode(statusCode);
-        retBody.setReturnBody(portal.getPortalConfig());
-        return retBody;
-    }
-
-}
\ No newline at end of file
index dde17b3..faf3755 100644 (file)
@@ -24,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonBackReference;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Set;
 
 import javax.persistence.*;
@@ -86,6 +88,16 @@ public class Design {
                designConfig.setSubmitted(getSubmitted());
                designConfig.setTopicName(getTopicName().getId());
         designConfig.setDesignType(getDesignType().getId());
+        designConfig.setDesignTypeName(getDesignType().getName());
+
+        Set<Db> designDb = getDbs();
+        List<Integer> dbList = new ArrayList<>();
+        if (designDb != null) {
+            for (Db item : designDb) {
+                    dbList.add(item.getId());
+            }
+        }
+        designConfig.setDbs(dbList);
 
                return designConfig;
     }
index dd327ea..14026fe 100644 (file)
@@ -49,12 +49,6 @@ public class DesignType {
     @Column(name = "`name`")
     private String name;
 
-    //To be removed
-    @ManyToOne(fetch=FetchType.EAGER)
-    @JoinColumn(name="portal")
-    @JsonBackReference
-    private Portal portal;
-
     @ManyToOne(fetch=FetchType.LAZY)
     @JoinColumn(name="db_type_id", nullable = false)
     @JsonBackReference
diff --git a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/domain/Portal.java b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/domain/Portal.java
deleted file mode 100644 (file)
index d2214dc..0000000
+++ /dev/null
@@ -1,79 +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 com.fasterxml.jackson.annotation.JsonBackReference;
-import lombok.Getter;
-import lombok.Setter;
-import org.onap.datalake.feeder.dto.PortalConfig;
-
-import javax.persistence.*;
-
-/**
- * Domain class representing portal
- *
- * @author guochunmeng
- */
-
-@Getter
-@Setter
-@Entity
-@Table(name = "portal")
-public class Portal {
-
-    @Id
-    @Column(name = "`name`")
-    private String name;
-
-    @Column(name = "`enabled`")
-    private Boolean enabled;
-
-    @Column(name = "`host`")
-    private String host;
-
-    @Column(name = "`port`")
-    private Integer port;
-
-    @Column(name = "`login`")
-    private String login;
-
-    @Column(name = "`pass`")
-    private String pass;
-
-    @ManyToOne(fetch=FetchType.EAGER)
-    @JoinColumn(name = "related_db")
-    @JsonBackReference
-    private Db db;
-
-    public PortalConfig getPortalConfig() {
-        PortalConfig portalConfig = new PortalConfig();
-
-        portalConfig.setName(getName());
-        portalConfig.setLogin(getLogin());
-        portalConfig.setPass(getPass());
-        portalConfig.setEnabled(getEnabled());
-        portalConfig.setHost(getHost());
-        portalConfig.setPort(getPort());
-        portalConfig.setDb(getDb().getName());
-
-        return portalConfig;
-    }
-}
index d115529..3425600 100755 (executable)
@@ -23,6 +23,8 @@ package org.onap.datalake.feeder.dto;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.util.List;
+
 /**
  * JSON request body for portalDesign Config.
  *
@@ -40,5 +42,7 @@ public class DesignConfig {
     private String note;
     private String topicName;
     private String designType;
+    private String designTypeName;//UI show name
+    private List<Integer> dbs;
 
 }
diff --git a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/dto/PortalConfig.java b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/dto/PortalConfig.java
deleted file mode 100644 (file)
index 76b1ceb..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : DataLake
- * ================================================================================
- * Copyright 2019 QCT
- *=================================================================================
- * 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 lombok.Getter;
-import lombok.Setter;
-
-/**
- * JSON request body for Portal Config.
- *
- * @author guochunmeng
- *
- */
-@Setter
-@Getter
-public class PortalConfig {
-
-    private String name;
-
-    private Boolean enabled;
-
-    private String host;
-
-    private Integer port;
-
-    private String login;
-
-    private String pass;
-
-    private String db;
-
-}
diff --git a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/repository/PortalRepository.java b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/repository/PortalRepository.java
deleted file mode 100644 (file)
index f4ce0ee..0000000
+++ /dev/null
@@ -1,42 +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.repository;
-
-import org.onap.datalake.feeder.domain.Portal;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
-import org.springframework.data.jpa.repository.Query;
-import org.springframework.data.repository.CrudRepository;
-import org.springframework.data.repository.Repository;
-
-import java.util.List;
-
-/**
- * Portal Repository
- *
- * @author guochunmeng
- */
-
-public interface PortalRepository extends CrudRepository<Portal, String> {
-
-    List<Portal> findByEnabled(Boolean enabled);
-
-}
index b4dd637..8f72dfe 100644 (file)
@@ -19,9 +19,6 @@
 */\r
 package org.onap.datalake.feeder.repository;\r
 \r
-import java.util.List;\r
-\r
-import org.onap.datalake.feeder.domain.Portal;\r
 import org.onap.datalake.feeder.domain.Topic;\r
 \r
 import org.springframework.data.repository.CrudRepository;\r
index 61411a4..4ba4f8f 100755 (executable)
@@ -24,12 +24,14 @@ import java.util.ArrayList;
 import java.util.List;\r
 import java.util.Optional;\r
 import java.util.Set;\r
+import java.util.HashSet;\r
 \r
 import org.onap.datalake.feeder.config.ApplicationConfiguration;\r
 import org.onap.datalake.feeder.domain.*;\r
 import org.onap.datalake.feeder.domain.Design;\r
 import org.onap.datalake.feeder.dto.DesignConfig;\r
 import org.onap.datalake.feeder.enumeration.DesignTypeEnum;\r
+import org.onap.datalake.feeder.repository.DbRepository;\r
 import org.onap.datalake.feeder.repository.DesignTypeRepository;\r
 import org.onap.datalake.feeder.repository.DesignRepository;\r
 import org.onap.datalake.feeder.repository.TopicNameRepository;\r
@@ -64,6 +66,9 @@ public class DesignService {
        @Autowired\r
        private ApplicationConfiguration applicationConfiguration;\r
 \r
+       @Autowired\r
+       private DbRepository dbRepository;\r
+\r
        public Design fillDesignConfiguration(DesignConfig designConfig) {\r
                Design design = new Design();\r
                fillDesign(designConfig, design);\r
@@ -89,7 +94,6 @@ public class DesignService {
                        throw new IllegalArgumentException("topicName is null " + designConfig.getTopicName());\r
                design.setTopicName(topicName.get());\r
 \r
-\r
                if (designConfig.getDesignType() == null)\r
                        throw new IllegalArgumentException("Can not find designType in design_type, designType id " + designConfig.getDesignType());\r
                Optional<DesignType> designType = designTypeRepository.findById(designConfig.getDesignType());\r
@@ -97,6 +101,23 @@ public class DesignService {
                        throw new IllegalArgumentException("designType is null");\r
                design.setDesignType(designType.get());\r
 \r
+               Set<Db> dbs = new HashSet<>();\r
+               if (designConfig.getDbs() != null) {\r
+                       for (Integer item : designConfig.getDbs()) {\r
+                               Optional<Db> db = dbRepository.findById(item);\r
+                               if (db.isPresent()) {\r
+                                       dbs.add(db.get());\r
+                               }\r
+                       }\r
+                       if (dbs.size() > 0)\r
+                               design.setDbs(dbs);\r
+                       else {\r
+                               design.getDbs().clear();\r
+                               design.setDbs(dbs);\r
+                       }\r
+               } else {\r
+                       design.setDbs(dbs);\r
+               }\r
        }\r
 \r
        public Design getDesign(Integer id) {\r
@@ -111,7 +132,7 @@ public class DesignService {
                List<DesignConfig> designConfigList = new ArrayList<>();\r
                designList = (List<Design>) designRepository.findAll();\r
                if (designList != null && designList.size() > 0) {\r
-                       log.info("PortalDesignList is not null");\r
+                       log.info("DesignList is not null");\r
                        for (Design design : designList) {\r
                                designConfigList.add(design.getDesignConfig());\r
                        }\r
@@ -137,18 +158,8 @@ public class DesignService {
        private boolean deployKibanaImport(Design design) throws RuntimeException {\r
                POST_FLAG = "KibanaDashboardImport";\r
                String requestBody = design.getBody();\r
-               Portal portal = design.getDesignType().getPortal();\r
-               String portalHost = portal.getHost();\r
-               Integer portalPort = portal.getPort();\r
                String url = "";\r
-\r
-               if (portalHost == null || portalPort == null) {\r
-                       String dbHost = portal.getDb().getHost();\r
-                       Integer dbPort = portal.getDb().getPort();\r
-                       url = kibanaImportUrl(dbHost, dbPort);\r
-               } else {\r
-                       url = kibanaImportUrl(portalHost, portalPort);\r
-               }\r
+               //TODO\r
                return HttpClientUtil.sendPostHttpClient(url, requestBody, POST_FLAG);\r
 \r
        }\r
diff --git a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/service/PortalService.java b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/service/PortalService.java
deleted file mode 100644 (file)
index 28efd15..0000000
+++ /dev/null
@@ -1,79 +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.service;
-
-
-import org.onap.datalake.feeder.domain.Portal;
-import org.onap.datalake.feeder.dto.PortalConfig;
-import org.onap.datalake.feeder.repository.PortalRepository;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Service for portals
- *
- * @author guochunmeng
- *
- */
-@Service
-public class PortalService {
-
-    @Autowired
-    private PortalRepository portalRepository;
-
-    public Portal fillPortalConfiguration(PortalConfig portalConfig)
-    {
-        Portal portal = new Portal();
-        fillPortal(portalConfig, portal);
-        return portal;
-    }
-    public void fillPortalConfiguration(PortalConfig portalConfig, Portal portal)
-    {
-        fillPortal(portalConfig, portal);
-    }
-
-    private void fillPortal(PortalConfig portalConfig, Portal portal) {
-
-        portal.setName(portalConfig.getName());
-        portal.setLogin(portalConfig.getLogin());
-        portal.setPass(portalConfig.getPass());
-        portal.setEnabled(portalConfig.getEnabled());
-        portal.setHost(portalConfig.getHost());
-        portal.setPort(portalConfig.getPort());
-
-    }
-
-
-    public List<String> listNames(boolean enabled){
-
-        List<String> names = new ArrayList<>();
-        Iterable<Portal> ret = portalRepository.findByEnabled(enabled);
-        for(Portal portal:ret) {
-            names.add(portal.getName());
-        }
-
-        return names;
-    }
-
-}
index 9509bdd..670f100 100644 (file)
@@ -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;
index 69e592a..79c0c84 100644 (file)
@@ -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 (file)
index 9e843ea..0000000
+++ /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
index ad93063..e02c2d1 100644 (file)
@@ -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 (file)
index 442d7f1..0000000
+++ /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 (file)
index 4709b04..0000000
+++ /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
index 3c87718..65b373f 100644 (file)
@@ -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();
     }