VariableContext { public VariableContext setImmutables(Set<String> variableNames) { if (this.immutableNames != null) { throw new IllegalStateException("Immutable variables are already defined," + " variable immutability cannot be changed once set!"); } this.immutableNames = ImmutableSet.copyOf(variableNames); return this; }  VariableContext setImmutables(Set<String> variableNames); VariableContext setImmutables(String... variableNames); VariableContext put(String name, String value); String get(String name); void putExtraDataset(String name, Set<String> set); Set<String> getExtraDataset(String name); boolean containsKey(String name); String replaceVariables(String input); String replacePathVariables(String input);  }
@Test(expected = IllegalStateException.class) public void testImmutablesCanOnlySetOnceFromSet() { VariableContext variables = new VariableContext(); ImmutableSet<String> immutables = ImmutableSet.of("%user", "%primary_group", "%secondary_group"); variables.setImmutables(immutables); variables.setImmutables(immutables); }
@Test(expected = IllegalStateException.class) public void testImmutablesCanOnlySetOnceFromArray() { VariableContext variables = new VariableContext(); variables.setImmutables("%user", "%primary_group", "%secondary_group"); variables.setImmutables("%user", "%primary_group", "%secondary_group"); }
@Test(expected = IllegalStateException.class) public void testImmutablesCanOnlySetOnceFromSetAndArray() { VariableContext variables = new VariableContext(); ImmutableSet<String> immutables = ImmutableSet.of("%user", "%primary_group", "%secondary_group"); variables.setImmutables(immutables); variables.setImmutables("%user", "%primary_group", "%secondary_group"); }