From 615031ac4bb36fb02e72eea9e59c9e3bcec4ab1e Mon Sep 17 00:00:00 2001 From: ZhangZihao Date: Mon, 24 Jun 2019 11:26:35 +0800 Subject: db modify Change-Id: I848b9ac6d45dc60e93be27306cfbed97c73da51d Issue-ID: DCAEGEN2-1622 Signed-off-by: ZhangZihao --- .../feeder/controller/DbControllerTest.java | 8 ++-- .../org/onap/datalake/feeder/dto/DbConfigTest.java | 50 ++++++++++++++++++++++ 2 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/dto/DbConfigTest.java (limited to 'components/datalake-handler/feeder/src/test/java/org') diff --git a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/DbControllerTest.java b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/DbControllerTest.java index b0a78d63..4a6d6bee 100644 --- a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/DbControllerTest.java +++ b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/controller/DbControllerTest.java @@ -27,7 +27,7 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.junit.MockitoJUnitRunner; -import org.onap.datalake.feeder.controller.domain.DbConfig; +import org.onap.datalake.feeder.dto.DbConfig; import org.onap.datalake.feeder.controller.domain.PostReturnBody; import org.onap.datalake.feeder.domain.Db; import org.onap.datalake.feeder.domain.Topic; @@ -109,18 +109,18 @@ public class DbControllerTest { DbController dbController = new DbController(); DbConfig dbConfig = getDbConfig(); when(mockBindingResult.hasErrors()).thenReturn(true); - PostReturnBody db = dbController.updateDb("Elecsticsearch", dbConfig, mockBindingResult, + PostReturnBody db = dbController.updateDb(dbConfig, mockBindingResult, httpServletResponse); assertEquals(null, db); when(mockBindingResult.hasErrors()).thenReturn(false); setAccessPrivateFields(dbController); - db = dbController.updateDb("Elecsticsearch", dbConfig, mockBindingResult, + db = dbController.updateDb(dbConfig, mockBindingResult, httpServletResponse); assertEquals(null, db); when(mockBindingResult.hasErrors()).thenReturn(false); String name = "Elecsticsearch"; when(dbRepository.findById(name)).thenReturn(Optional.of(new Db(name))); - db = dbController.updateDb("Elecsticsearch", dbConfig, mockBindingResult, + db = dbController.updateDb(dbConfig, mockBindingResult, httpServletResponse); assertEquals(200, db.getStatusCode()); Db elecsticsearch = dbController.getDb("Elecsticsearch", httpServletResponse); diff --git a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/dto/DbConfigTest.java b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/dto/DbConfigTest.java new file mode 100644 index 00000000..41dfd820 --- /dev/null +++ b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/dto/DbConfigTest.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : DATALAKE + * ================================================================================ + * Copyright (C) 2018-2019 Huawei. 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 org.onap.datalake.feeder.dto; + +import org.junit.Test; +import org.onap.datalake.feeder.dto.DbConfig; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +public class DbConfigTest { + @Test + public void testDbConfig() { + DbConfig dbConfig = new DbConfig(); + dbConfig.setName("elasticsearch"); + assertTrue("elasticsearch".equals(dbConfig.getName())); + dbConfig.setHost("localhost"); + assertTrue("localhost".equals(dbConfig.getHost())); + dbConfig.setLogin("root"); + assertTrue("root".equals(dbConfig.getLogin())); + dbConfig.setPassword("root123"); + assertTrue("root123".equals(dbConfig.getPassword())); + dbConfig.setDatabase("elasticsearch"); + assertTrue("elasticsearch".equals(dbConfig.getDatabase())); + dbConfig.setPort(123); + //assertEquals(123, dbConfig.getPort()); + assertFalse("123".equals(dbConfig.getPort())); + + dbConfig.setPoperties("driver"); + assertTrue("driver".equals(dbConfig.getPoperties())); + } +} -- cgit 1.2.3-korg