summaryrefslogtreecommitdiffstats
path: root/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/test/java/org/onap/appc/mdsal/operation/TestConfigOperationRequestFormatter.java
blob: a55bd8153b578a1fc6e822211ec798ff99b5238c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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));

    }
}