blob: e9200a3ee32a9d69965feeafdb4b0cdcf0547b4b [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;
61 public static final int ONE = 1;
xueliang37a396a2016-09-09 14:43:49 +090062
63 private FujitsuVoltXmlUtilityMock() {
64 }
65
66 /**
67 * Builds XML start tag with name provided.
68 *
69 * @param name tag name
70 * @return string
71 */
72 public static String startTag(String name) {
73 return startTag(name, true);
74 }
75
76 /**
77 * Builds XML end tag with name provided.
78 *
79 * @param name tag name
80 * @return string
81 */
82 public static String endTag(String name) {
83 return endTag(name, true);
84 }
85
86 /**
87 * Builds XML empty tag with name provided.
88 *
89 * @param name tag name
90 * @return string
91 */
92 public static String emptyTag(String name) {
93 return emptyTag(name, true);
94 }
95
96 /**
97 * Builds XML start tag with name provided.
98 *
99 * @param name tag name
100 * @param addNewLine option to add new line character after tag
101 * @return string
102 */
103 public static String startTag(String name, boolean addNewLine) {
104 if (addNewLine) {
105 return (TEST_ANGLE_LEFT + name + TEST_ANGLE_RIGHT + TEST_NEW_LINE);
106 } else {
107 return (TEST_ANGLE_LEFT + name + TEST_ANGLE_RIGHT);
108 }
109 }
110
111 /**
112 * Builds XML end tag with name provided.
113 *
114 * @param name tag name
115 * @param addNewLine option to add new line character after tag
116 * @return string
117 */
118 public static String endTag(String name, boolean addNewLine) {
119 if (addNewLine) {
120 return (TEST_ANGLE_LEFT + TEST_SLASH + name + TEST_ANGLE_RIGHT + TEST_NEW_LINE);
121 } else {
122 return (TEST_ANGLE_LEFT + TEST_SLASH + name + TEST_ANGLE_RIGHT);
123 }
124 }
125
126 /**
127 * Builds XML empty element tag with name provided.
128 *
129 * @param name tag name
130 * @param addNewLine option to add new line character after tag
131 * @return string
132 */
133 public static String emptyTag(String name, boolean addNewLine) {
134 if (addNewLine) {
135 return (TEST_ANGLE_LEFT + name + TEST_SLASH + TEST_ANGLE_RIGHT + TEST_NEW_LINE);
136 } else {
137 return (TEST_ANGLE_LEFT + name + TEST_SLASH + TEST_ANGLE_RIGHT);
138 }
139 }
140
141}