From 76cd2593032c578b0af9fe089cf6431c7a2060d4 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 5 Mar 2019 12:06:50 -0500 Subject: Add junit test cases Add junit test cases for sli/core repository. Change-Id: Ifcec596cf9f835249a7967c9c7830253b53d2ef6 Issue-ID: CCSDK-1128 Signed-off-by: Timoney, Dan (dt5972) --- .../ccsdk/sli/core/sli/ITCaseSvcLogicParser.java | 15 ++++++++++ .../ccsdk/sli/core/sliapi/TestSliapiProvider.java | 32 +++++++++++++++++++++- .../src/test/resources/simplelogger.properties | 23 ++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 sliapi/provider/src/test/resources/simplelogger.properties diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java index f5cbf50b0..6f303a598 100644 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java @@ -112,6 +112,21 @@ public class ITCaseSvcLogicParser { if (testCaseUrl == null) { fail("Could not resolve test case file " + testCaseFile); } + + // Test parsing and printing + try { + SvcLogicParser parser = new SvcLogicParser(); + + for (SvcLogicGraph graph : parser.parse(testCaseUrl.getPath())) { + System.out.println("XML for graph "+graph.getModule()+":"+graph.getRpc()); + graph.printAsXml(System.out); + System.out.println("GV for graph "+graph.getModule()+":"+graph.getRpc()); + graph.printAsGv(System.out); + } + } catch (Exception e) { + + fail("Validation failure [" + e.getMessage() + "]"); + } try { SvcLogicParser.load(testCaseUrl.getPath(), store); diff --git a/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java b/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java index 5106d6fc2..0326429c9 100644 --- a/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java +++ b/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java @@ -152,6 +152,7 @@ public class TestSliapiProvider { public void testExecuteGraph() { ExecuteGraphInputBuilder inputBuilder = new ExecuteGraphInputBuilder(); + // Valid test - graph exists inputBuilder.setMode(ExecuteGraphInput.Mode.Sync); inputBuilder.setModuleName("sli"); inputBuilder.setRpcName("healthcheck"); @@ -160,9 +161,38 @@ public class TestSliapiProvider { pBuilder.setParameterName("int-parameter"); pBuilder.setIntValue(1); pList.add(pBuilder.build()); + pBuilder.setParameterName("bool-parameter"); + pBuilder.setIntValue(null); + pBuilder.setBooleanValue(true); + pList.add(pBuilder.build()); + pBuilder.setParameterName("str-parameter"); + pBuilder.setBooleanValue(null); + pBuilder.setStringValue("value"); + pList.add(pBuilder.build()); + inputBuilder.setSliParameter(pList); + provider.executeGraph(inputBuilder.build()); + + + // Invalid test - graph does not exist + inputBuilder.setMode(ExecuteGraphInput.Mode.Sync); + inputBuilder.setModuleName("sli"); + inputBuilder.setRpcName("no-such-graph"); + pList = new LinkedList<>(); + pBuilder = new SliParameterBuilder(); + pBuilder.setParameterName("int-parameter"); + pBuilder.setIntValue(1); + pList.add(pBuilder.build()); + pBuilder.setParameterName("bool-parameter"); + pBuilder.setIntValue(null); + pBuilder.setBooleanValue(true); + pList.add(pBuilder.build()); + pBuilder.setParameterName("str-parameter"); + pBuilder.setBooleanValue(null); + pBuilder.setStringValue("value"); + pList.add(pBuilder.build()); inputBuilder.setSliParameter(pList); - provider.executeGraph(inputBuilder.build()); + assertTrue(provider.vlbcheck(mock(VlbcheckInput.class)) instanceof Future); } diff --git a/sliapi/provider/src/test/resources/simplelogger.properties b/sliapi/provider/src/test/resources/simplelogger.properties new file mode 100644 index 000000000..417c4d143 --- /dev/null +++ b/sliapi/provider/src/test/resources/simplelogger.properties @@ -0,0 +1,23 @@ +### +# ============LICENSE_START======================================================= +# ONAP : CCSDK +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. 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========================================================= +### + +org.slf4j.simpleLogger.defaultLogLevel=info +org.slf4j.simplelogger.log.org.onap.ccsdk.sli.core.sliapi.sliapiProvider=debug -- cgit 1.2.3-korg