MagicListVariables implements SpecialCommand { @Override public StellarResult execute(String command, StellarShellExecutor executor) { String vars = executor .getState() .entrySet() .stream() .map(e -> format(e)) .collect(Collectors.joining(", ")); return success(vars); }  @Override String getCommand(); @Override Function<String, Boolean> getMatcher(); @Override StellarResult execute(String command, StellarShellExecutor executor); static final String MAGIC_VARS; }
@Test public void test() { executor.execute("x := 2 + 2"); StellarResult result = executor.execute("%vars"); assertTrue(result.isSuccess()); assertTrue(result.getValue().isPresent()); String vars = ConversionUtils.convert(result.getValue().get(), String.class); assertEquals("x = 4 via `2 + 2`", vars); }
@Test public void testWithNoVars() { StellarResult result = executor.execute("%vars"); assertTrue(result.isSuccess()); assertTrue(result.getValue().isPresent()); String vars = ConversionUtils.convert(result.getValue().get(), String.class); assertEquals("", vars); }