@org.junit.Test public void StoreCommandVariables() { StoredVariables variables = new StoredVariables(); HashMap<String, String> hVars; String[] key1 = {"var1", "replacedText1"}; String[] key2 = {"Var2", "replacedText2"}; String[] key3 = {"VaR!", "replacedText3"}; variables.storeIfCommandVariable( Globals.variablePrefix + key1[0] + Globals.variableSuffix, key1[1]); variables.storeIfCommandVariable( Globals.variablePrefix + key2[0] + Globals.variableSuffix, key2[1]); variables.storeIfCommandVariable( Globals.variablePrefix + key3[0] + Globals.variableSuffix, key3[1]); hVars = variables.getCurrentVariables(); assertEquals(hVars.size(), 3); assertTrue(hVars.containsKey(key1[0])); assertTrue(hVars.containsKey(key2[0])); assertTrue(hVars.containsKey(key3[0])); assertEquals(hVars.get(key1[0]), key1[1]); assertEquals(hVars.get(key2[0]), key2[1]); assertEquals(hVars.get(key3[0]), key3[1]); }
@org.junit.Test public void VariablesReplacement() { StoredVariables variables = new StoredVariables(); String[] key1 = {"varr1", "replacedText11"}; String[] key2 = {"Varr2", "replacedText22"}; String[] key3 = {"vaRr3", "replacedText33"}; variables.storeIfCommandVariable( Globals.variablePrefix + key1[0] + Globals.variableSuffix, key1[1]); variables.storeIfCommandVariable( Globals.variablePrefix + key2[0] + Globals.variableSuffix, key2[1]); variables.storeIfCommandVariable( Globals.variablePrefix + key3[0] + Globals.variableSuffix, key3[1]); assertEquals( variables.replaceVariables(Globals.variablePrefix + key1[0] + Globals.variableSuffix), key1[1]); assertEquals( variables.replaceVariables( " " + Globals.variablePrefix + key1[0] + Globals.variableSuffix + " "), " " + key1[1] + " "); assertEquals( variables.replaceVariables(" " + Globals.variablePrefix + key2[0] + Globals.variableSuffix), " " + key2[1]); assertEquals( variables.replaceVariables(Globals.variablePrefix + key3[0] + Globals.variableSuffix + " "), key3[1] + " "); assertEquals( variables.replaceVariables( Globals.variablePrefix + key3[0] + Globals.variableSuffix + ";" + Globals.variablePrefix + key2[0] + Globals.variableSuffix), key3[1] + ";" + key2[1]); assertEquals( variables.replaceVariables( " " + Globals.variablePrefix + key1[0] + Globals.variableSuffix + "; " + Globals.variablePrefix + key2[0] + Globals.variableSuffix), " " + key1[1] + "; " + key2[1]); // assertEquals(variables.replaceVariables(Globals.variablePrefix+key1[0]+Globals.variableSuffix), key1[1]); // System.out.println(variables.replaceVariables(" // "+Globals.variablePrefix+key1[0]+Globals.variableSuffix+"; // "+Globals.variablePrefix+key2[0]+Globals.variableSuffix)); }
@org.junit.Test public void CheckIfIsCommandVariable() { StoredVariables variables = new StoredVariables(); assertTrue( variables.isCommandVariable(Globals.variablePrefix + "var1" + Globals.variableSuffix)); // assertFalse(variables.isCommandVariable(Globals.variablePrefix+"var1"+Globals.variablePrefix)); assertFalse( variables.isCommandVariable(Globals.variableSuffix + "var1" + Globals.variableSuffix)); assertFalse( variables.isCommandVariable(Globals.variableSuffix + "var1" + Globals.variablePrefix)); assertFalse(variables.isCommandVariable(Globals.variablePrefix + Globals.variableSuffix)); // assertFalse(variables.isCommandVariable(Globals.variablePrefix+Globals.variablePrefix)); assertFalse(variables.isCommandVariable(Globals.variableSuffix + Globals.variableSuffix)); }