From 03f48c7ea7de11d7c7d0933a0438afa4280e3bf7 Mon Sep 17 00:00:00 2001 From: amshegokar Date: Tue, 30 Jan 2018 18:20:05 +0530 Subject: [PATCH] Unit Tests for appc-dg-mdsal-store classes-Part 1 Adding Unit test for org.onap.appc.mdsal.operation package https://sonar.onap.org/drilldown/measures/org.onap.appc:appc?highlight=overall_coverage&metric=overall_uncovered_lines&rids%5B%5D=117465&rids%5B%5D=124943 Change-Id: I8c5b08406b5308dcfef1fd71826f9d8bc908e908 Issue-ID: APPC-501 Signed-off-by: amshegokar --- .../TestConfigOperationRequestFormatter.java | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/test/java/org/onap/appc/mdsal/operation/TestConfigOperationRequestFormatter.java diff --git a/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/test/java/org/onap/appc/mdsal/operation/TestConfigOperationRequestFormatter.java b/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/test/java/org/onap/appc/mdsal/operation/TestConfigOperationRequestFormatter.java new file mode 100644 index 000000000..a55bd8153 --- /dev/null +++ b/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/test/java/org/onap/appc/mdsal/operation/TestConfigOperationRequestFormatter.java @@ -0,0 +1,47 @@ +package org.onap.appc.mdsal.operation; + +import static org.junit.Assert.*; +import org.junit.Before; +import org.junit.Test; + +public class TestConfigOperationRequestFormatter { + private ConfigOperationRequestFormatter requestFormatter; + + @Before + public void setUp() { + requestFormatter = new ConfigOperationRequestFormatter(); + } + + @Test + public void testBuildPath_ValidPath() { + String validBuildPath = "/restconf/config/appc-dg-mdsal-store:appc-dg-mdsal-bundle/appc-dg-mdsal-bundle/appc-dg-mdsal-model/"; + String module = "appc-dg-mdsal-store"; + String containerName = "appc-dg-mdsal-bundle"; + String[] subModules = { "appc-dg-mdsal-bundle", "appc-dg-mdsal-model" }; + assertEquals(validBuildPath, requestFormatter.buildPath(module, containerName, subModules)); + } + @Test + public void testBuildPath_One_SubModule() { + String validBuildPath = "/restconf/config/appc-dg-mdsal-store:appc-dg-mdsal-bundle/appc-dg-mdsal-bundle/"; + String module = "appc-dg-mdsal-store"; + String containerName = "appc-dg-mdsal-bundle"; + String[] subModules = { "appc-dg-mdsal-bundle"}; + assertEquals(validBuildPath, requestFormatter.buildPath(module, containerName, subModules)); + } + @Test + public void testBuildPath_Zero_SubModule() { + String validBuildPathWithoutSubModule = "/restconf/config/appc-dg-mdsal-store:appc-dg-mdsal-bundle/"; + String module = "appc-dg-mdsal-store"; + String containerName = "appc-dg-mdsal-bundle"; + assertEquals(validBuildPathWithoutSubModule, requestFormatter.buildPath(module, containerName)); + } + @Test + public void testBuildPath_InvalidPath() { + String inValidBuildPath = "/restcon/config/appc-dg-mdsal-storeappc-dg-mdsal-bundle/appc-dg-mdsal-bundle/appc-dg-mdsal-model/"; + String module = "appc-dg-mdsal-store"; + String containerName = "appc-dg-mdsal-bundle"; + String[] subModules = { "appc-dg-mdsal-bundle", "appc-dg-mdsal-model" }; + assertNotEquals(inValidBuildPath, requestFormatter.buildPath(module, containerName,subModules)); + + } +} -- 2.16.6