本文整理了Java中org.mozilla.zest.core.v1.ZestVariables.<init>()
方法的一些代码示例,展示了ZestVariables.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZestVariables.<init>()
方法的具体详情如下:
包路径:org.mozilla.zest.core.v1.ZestVariables
类名称:ZestVariables
方法名:<init>
[英]Instantiates a new zest tokens.
[中]实例化一个新的zest标记。
代码示例来源:origin: mozilla/zest
@Override
public ZestVariables deepCopy() {
ZestVariables zt = new ZestVariables();
zt.setTokenStart(this.tokenStart);
zt.setTokenEnd(this.tokenEnd);
for (Entry<String, String> entry : tokens.entrySet()) {
zt.setVariable(entry.getKey(), entry.getValue());
}
return zt;
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldHaveTokenEndByDefault() throws Exception {
// Given
ZestVariables zestVars = new ZestVariables();
// When
String tokenEnd = zestVars.getTokenEnd();
// Then
assertTrue("}}".equals(tokenEnd));
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldHaveTokenStartByDefault() throws Exception {
// Given
ZestVariables zestVars = new ZestVariables();
// When
String tokenStart = zestVars.getTokenStart();
// Then
assertTrue("{{".equals(tokenStart));
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldHaveNoVariablesByDefault() throws Exception {
// Given
ZestVariables zestVars = new ZestVariables();
// When
List<String[]> variables = zestVars.getVariables();
// Then
assertTrue(variables.isEmpty());
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldAddVarWithNameAsValueIfValueIsNull() throws Exception {
// Given
ZestVariables zestVars = new ZestVariables();
String value = null;
// When
zestVars.addVariable(VAR_NAME, value);
// Then
assertTrue(zestVars.getVariables().size() == 1);
assertTrue(VAR_NAME.equals(zestVars.getVariables().get(0)[0]));
assertTrue(VAR_NAME.equals(zestVars.getVariables().get(0)[1]));
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldReturnNullStringIfReplacingVariablesInNullString() throws Exception {
// Given
ZestVariables zestVars = new ZestVariables();
// When
String finalString = zestVars.replaceInString(null, false);
// Then
assertTrue(finalString == null);
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldAddVarWithValue() throws Exception {
// Given
ZestVariables zestVars = new ZestVariables();
// When
zestVars.addVariable(VAR_NAME, VAR_VALUE);
// Then
assertTrue(zestVars.getVariables().size() == 1);
assertTrue(VAR_NAME.equals(zestVars.getVariables().get(0)[0]));
assertTrue(VAR_VALUE.equals(zestVars.getVariables().get(0)[1]));
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldSetVariable() throws Exception {
// Given
ZestVariables zestVars = new ZestVariables();
// When
zestVars.setVariable(VAR_NAME, VAR_NAME);
// Then
assertTrue(zestVars.getVariables().size() == 1);
assertTrue(VAR_NAME.equals(zestVars.getVariables().get(0)[0]));
assertTrue(VAR_NAME.equals(zestVars.getVariables().get(0)[1]));
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldGetNullValueIfVariableWasNotAdded() throws Exception {
// Given
ZestVariables zestVars = new ZestVariables();
// When
String valueObtained = zestVars.getVariable(VAR_NAME);
// Then
assertTrue(valueObtained == null);
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldSetTokenStart() throws Exception {
// Given
ZestVariables zestVars = new ZestVariables();
String tokenStart = "\\|";
// When
zestVars.setTokenStart(tokenStart);
// Then
assertTrue(zestVars.getTokenStart().equals(tokenStart));
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldSetTokenEnd() throws Exception {
// Given
ZestVariables zestVars = new ZestVariables();
String tokenEnd = "|//";
// When
zestVars.setTokenEnd(tokenEnd);
// Then
assertTrue(zestVars.getTokenEnd().equals(tokenEnd));
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldAddVarWithNameAsValue() throws Exception {
// Given
ZestVariables zestVars = new ZestVariables();
// When
zestVars.addVariable(VAR_NAME);
// Then
assertTrue(zestVars.getVariables().size() == 1);
assertTrue(VAR_NAME.equals(zestVars.getVariables().get(0)[0]));
assertTrue(VAR_NAME.equals(zestVars.getVariables().get(0)[1]));
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldGetValueOfVariableAdded() throws Exception {
// Given
ZestVariables zestVars = new ZestVariables();
zestVars.addVariable(VAR_NAME, VAR_VALUE);
// When
String valueObtained = zestVars.getVariable(VAR_NAME);
// Then
assertTrue(valueObtained.equals(VAR_VALUE));
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldNotAddVarIfAlreadyAdded() throws Exception {
// Given
ZestVariables zestVars = new ZestVariables();
zestVars.addVariable(VAR_NAME);
// When
zestVars.addVariable(VAR_NAME);
// Then
assertTrue(zestVars.getVariables().size() == 1);
assertTrue(VAR_NAME.equals(zestVars.getVariables().get(0)[0]));
assertTrue(VAR_NAME.equals(zestVars.getVariables().get(0)[1]));
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldNotAddVarWithValueIfAlreadyAdded() throws Exception {
// Given
ZestVariables zestVars = new ZestVariables();
zestVars.addVariable(VAR_NAME);
// When
zestVars.addVariable(VAR_NAME, VAR_VALUE);
// Then
assertTrue(zestVars.getVariables().size() == 1);
assertTrue(VAR_NAME.equals(zestVars.getVariables().get(0)[0]));
assertTrue(VAR_NAME.equals(zestVars.getVariables().get(0)[1]));
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldSetVariableWithNullName() throws Exception {
// Given
ZestVariables zestVars = new ZestVariables();
String name = null;
// When
zestVars.setVariable(name, VAR_VALUE);
// Then
assertTrue(zestVars.getVariables().size() == 1);
assertTrue(zestVars.getVariables().get(0)[0] == null);
assertTrue(zestVars.getVariables().get(0)[1] == VAR_VALUE);
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldSetVariableWithNullValue() throws Exception {
// Given
ZestVariables zestVars = new ZestVariables();
String value = null;
// When
zestVars.setVariable(VAR_NAME, value);
// Then
assertTrue(zestVars.getVariables().size() == 1);
assertTrue(VAR_NAME.equals(zestVars.getVariables().get(0)[0]));
assertTrue(zestVars.getVariables().get(0)[1] == value);
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldReplaceVariablesInVariablesInString() throws Exception {
// Given
ZestVariables zestVars = new ZestVariables();
zestVars.setVariable("Var1", "-1 < " + token(zestVars, "Var2"));
zestVars.setVariable("Var2", token(zestVars, "Var3"));
zestVars.setVariable("Var3", "1");
String string = token(zestVars, "Var1") + " <= " + token(zestVars, "Var3");
// When
String finalString = zestVars.replaceInString(string, false);
// Then
assertTrue("-1 < 1 <= 1".equals(finalString));
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldReplaceLoopingVariablesInVariablesInString() throws Exception {
// Given
ZestVariables zestVars = new ZestVariables();
zestVars.setVariable("Var1", "No Loop: " + token(zestVars, "Var2"));
zestVars.setVariable("Var2", "[" + token(zestVars, "Var3") + "]");
zestVars.setVariable("Var3", token(zestVars, "Var2"));
String string = token(zestVars, "Var1") + " | " + token(zestVars, "Var3");
// When
String finalString = zestVars.replaceInString(string, false);
// Then
assertTrue(
("No Loop: [" + token(zestVars, "Var2") + "] | " + token(zestVars, "Var2"))
.equals(finalString));
}
代码示例来源:origin: mozilla/zest
@Test
public void shouldReplaceVariablesInEncodedVariablesInString() throws Exception {
// Given
ZestVariables zestVars = new ZestVariables();
zestVars.setVariable("Var%", "-1 < " + token(zestVars, "Var&"));
zestVars.setVariable("Var&", urlencoded(token(zestVars, "Var?")));
zestVars.setVariable("Var?", "1");
String string =
urlencoded(token(zestVars, "Var%")) + " <= " + urlencoded(token(zestVars, "Var?"));
boolean encode = true;
// When
String finalString = zestVars.replaceInString(string, encode);
// Then
assertTrue("-1 < 1 <= 1".equals(finalString));
}
内容来源于网络,如有侵权,请联系作者删除!