blob: 19a6981a5cab640b6c5b4c875f0353360697a16e [file] [log] [blame]
xueliang37a396a2016-09-09 14:43:49 +09001/*
2 * Copyright 2016-present Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.drivers.fujitsu;
18
19/**
20 * Mock FujitsuVoltXmlUtility.
21 * This is to avoid using the same names/definitions
22 * in FujitsuVoltXmlUtility in test codes - not tied to actual codes.
23 */
24final class FujitsuVoltXmlUtilityMock {
25
26 public static final String TEST_COLON = ":";
27 public static final String TEST_DOT = ".";
28 public static final String TEST_HYPHEN = "-";
29 public static final String TEST_SLASH = "/";
30 public static final String TEST_SPACE = " ";
31 public static final String TEST_NEW_LINE = "\n";
32 public static final String TEST_ANGLE_LEFT = "<";
33 public static final String TEST_ANGLE_RIGHT = ">";
34
35 public static final String TEST_REPORT_ALL = "report-all";
36 public static final String TEST_RUNNING = "running";
37
38 public static final String TEST_VOLT_NE_NAMESPACE =
39 "xmlns=\"http://fujitsu.com/ns/volt/1.1\"";
40 public static final String TEST_VOLT_NE = "volt-ne";
41 public static final String TEST_PONLINK_ID = "ponlink-id";
42 public static final String TEST_ONU_ID = "onu-id";
43 public static final String TEST_ROOT = "fakeroot";
44
45 public static final String TEST_VOLT_NE_OPEN = TEST_ANGLE_LEFT + TEST_VOLT_NE + TEST_SPACE;
46 public static final String TEST_VOLT_NE_CLOSE = TEST_ANGLE_LEFT + TEST_SLASH + TEST_VOLT_NE + TEST_ANGLE_RIGHT;
47
48 public static final String TEST_BASE_NAMESPACE =
49 " xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n";
50
51 public static final String TEST_DUPLICATE_SPACES_REGEX = " +";
52 public static final String TEST_WHITESPACES_REGEX = "\\s+";
53 public static final String TEST_EMPTY_STRING = "";
54
55 public static final String TEST_VOLT_NAMESPACE = TEST_VOLT_NE_OPEN +
56 TEST_VOLT_NE_NAMESPACE;
57
xueliang5b3d34442016-09-23 10:37:33 +090058 public static final int FIRST_PART = 0;
59 public static final int SECOND_PART = 1;
60 public static final int THIRD_PART = 2;
xueliangffe73e42016-09-27 10:38:56 +090061 public static final int ZERO = 0;
xueliang5b3d34442016-09-23 10:37:33 +090062 public static final int ONE = 1;
xueliang37a396a2016-09-09 14:43:49 +090063
64 private FujitsuVoltXmlUtilityMock() {
65 }
66
67 /**
68 * Builds XML start tag with name provided.
69 *
70 * @param name tag name
71 * @return string
72 */
73 public static String startTag(String name) {
74 return startTag(name, true);
75 }
76
77 /**
78 * Builds XML end tag with name provided.
79 *
80 * @param name tag name
81 * @return string
82 */
83 public static String endTag(String name) {
84 return endTag(name, true);
85 }
86
87 /**
88 * Builds XML empty tag with name provided.
89 *
90 * @param name tag name
91 * @return string
92 */
93 public static String emptyTag(String name) {
94 return emptyTag(name, true);
95 }
96
97 /**
98 * Builds XML start tag with name provided.
99 *
100 * @param name tag name
101 * @param addNewLine option to add new line character after tag
102 * @return string
103 */
104 public static String startTag(String name, boolean addNewLine) {
105 if (addNewLine) {
106 return (TEST_ANGLE_LEFT + name + TEST_ANGLE_RIGHT + TEST_NEW_LINE);
107 } else {
108 return (TEST_ANGLE_LEFT + name + TEST_ANGLE_RIGHT);
109 }
110 }
111
112 /**
113 * Builds XML end tag with name provided.
114 *
115 * @param name tag name
116 * @param addNewLine option to add new line character after tag
117 * @return string
118 */
119 public static String endTag(String name, boolean addNewLine) {
120 if (addNewLine) {
121 return (TEST_ANGLE_LEFT + TEST_SLASH + name + TEST_ANGLE_RIGHT + TEST_NEW_LINE);
122 } else {
123 return (TEST_ANGLE_LEFT + TEST_SLASH + name + TEST_ANGLE_RIGHT);
124 }
125 }
126
127 /**
128 * Builds XML empty element tag with name provided.
129 *
130 * @param name tag name
131 * @param addNewLine option to add new line character after tag
132 * @return string
133 */
134 public static String emptyTag(String name, boolean addNewLine) {
135 if (addNewLine) {
136 return (TEST_ANGLE_LEFT + name + TEST_SLASH + TEST_ANGLE_RIGHT + TEST_NEW_LINE);
137 } else {
138 return (TEST_ANGLE_LEFT + name + TEST_SLASH + TEST_ANGLE_RIGHT);
139 }
140 }
141
142}