diff options
author | Guobiao Mo <guobiaomo@chinamobile.com> | 2019-04-06 21:52:09 -0700 |
---|---|---|
committer | Guobiao Mo <guobiaomo@chinamobile.com> | 2019-04-07 01:37:31 -0700 |
commit | 8dc9d71a2465f5c1e4beb52c2375efe02bcde174 (patch) | |
tree | fa2602aca45f7222d21a38800268bcf90db2fd39 /components/datalake-handler/feeder/src/test | |
parent | 3cb79e621ef9982d039d3770fbe02a0bed208481 (diff) |
Use MariaDB to store application configurations
Issue-ID: DCAEGEN2-1400
Change-Id: I86b5bc25d84b98f7ac84b95f1690089dcebe7f0a
Signed-off-by: Guobiao Mo <guobiaomo@chinamobile.com>
Diffstat (limited to 'components/datalake-handler/feeder/src/test')
4 files changed, 88 insertions, 30 deletions
diff --git a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/config/ApplicationConfigurationTest.java b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/config/ApplicationConfigurationTest.java index 934451fe..02db5a25 100644 --- a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/config/ApplicationConfigurationTest.java +++ b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/config/ApplicationConfigurationTest.java @@ -56,10 +56,6 @@ public class ApplicationConfigurationTest { @Test public void readConfig() { - assertNotNull(config.getCouchbaseHost()); - assertNotNull(config.getCouchbaseUser()); - assertNotNull(config.getCouchbasePass()); - assertNotNull(config.getCouchbaseBucket()); assertNotNull(config.getDmaapZookeeperHostPort()); assertNotNull(config.getDmaapKafkaHostPort()); diff --git a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/domain/DbTest.java b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/domain/DbTest.java new file mode 100644 index 00000000..ea1d6894 --- /dev/null +++ b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/domain/DbTest.java @@ -0,0 +1,44 @@ +/* +* ============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 static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import org.junit.Test; + +/** + * Test Db + * + * @author Guobiao Mo + * + */ + +public class DbTest { + + @Test + public void testIs() { + Db couchbase=new Db("Couchbase"); + Db mongoDB=new Db("MongoDB"); + Db mongoDB2=new Db("MongoDB"); + assertNotEquals(couchbase.hashCode(), mongoDB.hashCode()); + assertNotEquals(couchbase, mongoDB); + assertEquals(mongoDB, mongoDB2); + } +} diff --git a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/domain/TopicTest.java b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/domain/TopicTest.java index 23ec3b10..1e402522 100644 --- a/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/domain/TopicTest.java +++ b/components/datalake-handler/feeder/src/test/java/org/onap/datalake/feeder/domain/TopicTest.java @@ -23,8 +23,11 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import java.util.HashSet; + import org.json.JSONObject; -import org.junit.Test; +import org.junit.Test; +import org.onap.datalake.feeder.enumeration.DataFormat; /** * Test Topic @@ -50,17 +53,49 @@ public class TopicTest { } @Test + public void getMessageIdFromMultipleAttributes() { + String text = "{ data: { data2 : { value : 'hello'}, data3 : 'world'}}"; + + JSONObject json = new JSONObject(text); + + Topic topic = new Topic("test getMessageId"); + topic.setMessageIdPath("/data/data2/value,/data/data3"); + + String value = topic.getMessageId(json); + + assertEquals(value, "hello^world"); + } + + @Test public void testIs() { - Topic defaultTopic=new Topic("default"); + Topic defaultTopic=new Topic("_DL_DEFAULT_"); Topic testTopic = new Topic("test"); testTopic.setDefaultTopic(defaultTopic); + + assertTrue(defaultTopic.isDefault()); + assertFalse(testTopic.isDefault()); + + assertTrue(testTopic.equals(new Topic("test"))); + assertEquals(testTopic.hashCode(), (new Topic("test")).hashCode()); + + defaultTopic.setDbs(new HashSet<>()); + defaultTopic.getDbs().add(new Db("Elasticsearch")); + assertTrue(testTopic.supportElasticsearch()); + assertFalse(testTopic.supportCouchbase()); + assertFalse(testTopic.supportDruid()); + assertFalse(testTopic.supportMongoDB()); + + defaultTopic.getDbs().remove(new Db("Elasticsearch")); + assertFalse(testTopic.supportElasticsearch()); - defaultTopic.setSupportElasticsearch(true); - boolean b = testTopic.isSupportElasticsearch(); - assertTrue(b); + defaultTopic.setCorrelateClearedMessage(true); + defaultTopic.setDataFormat("XML"); + defaultTopic.setEnabled(true); + defaultTopic.setSaveRaw(true); + assertTrue(testTopic.isCorrelateClearedMessage()); + assertTrue(testTopic.isEnabled()); + assertTrue(testTopic.isSaveRaw()); - defaultTopic.setSupportElasticsearch(false); - b = testTopic.isSupportElasticsearch(); - assertFalse(b); + assertEquals(defaultTopic.getDataFormat(), DataFormat.XML); } } diff --git a/components/datalake-handler/feeder/src/test/resources/application.properties b/components/datalake-handler/feeder/src/test/resources/application.properties index ede5999b..d6d98e64 100644 --- a/components/datalake-handler/feeder/src/test/resources/application.properties +++ b/components/datalake-handler/feeder/src/test/resources/application.properties @@ -2,14 +2,6 @@ server.port = 1680 - -#For Beijing lab -#dmaapZookeeperHostPort=zookeeper.mr01.onap.vip:80 -#dmaapKafkaHostPort=kafka.mr01.onap.vip:80 -#spring.couchbase.bootstrap-hosts=172.30.1.74 -#couchbaseHost=172.30.1.74 - - #DMaaP #dmaapZookeeperHostPort=127.0.0.1:2181 #dmaapKafkaHostPort=127.0.0.1:9092 @@ -30,13 +22,4 @@ logging.level.org.springframework.web=ERROR logging.level.com.att.nsa.apiClient.http=ERROR logging.level.org.onap.datalake=DEBUG - -#DL Feeder DB: Couchbase -couchbaseHost=dl_couchbase -#couchbaseHost=172.30.1.74 -couchbaseUser=dmaap -couchbasePass=dmaap1234 -couchbaseBucket=dmaap - -#DL Feeder DB: Elasticsearch -elasticsearchHost=dl_es + |