### Question:
TypeCalculation { public static Long calculateLiteralValue( String calculation, Map<String, Long> inputs) { try { ParserRuleContext tree = parseTypeCalculation(calculation); CalculateTypeVisitor visitor = new CalculateTypeVisitor(inputs); BigInteger result = visitor.visit(tree); return result.longValueExact(); } catch (StackOverflowError e) { throw new ParsingException("Type calculation is too large (stack overflow while parsing)"); } } private  TypeCalculation(); static Long calculateLiteralValue(
            String calculation,
            Map<String, Long> inputs);  }### Answer:
@Test public void testBasicUsage() { assertEquals(calculateLiteralValue("42", ImmutableMap.of()), Long.valueOf(42)); assertEquals(calculateLiteralValue("NULL", ImmutableMap.of()), Long.valueOf(0)); assertEquals(calculateLiteralValue("null", ImmutableMap.of()), Long.valueOf(0)); assertEquals(calculateLiteralValue("x", ImmutableMap.of("x", 42L)), Long.valueOf(42)); assertEquals(calculateLiteralValue("(42)", ImmutableMap.of()), Long.valueOf(42)); assertEquals(calculateLiteralValue("(NULL)", ImmutableMap.of()), Long.valueOf(0)); assertEquals(calculateLiteralValue("(x)", ImmutableMap.of("x", 42L)), Long.valueOf(42)); assertEquals(calculateLiteralValue("42 + 55", ImmutableMap.of()), Long.valueOf(42 + 55)); assertEquals(calculateLiteralValue("42 - 55", ImmutableMap.of()), Long.valueOf(42 - 55)); assertEquals(calculateLiteralValue("42 * 55", ImmutableMap.of()), Long.valueOf(42 * 55)); assertEquals(calculateLiteralValue("42 / 6", ImmutableMap.of()), Long.valueOf(42 / 6)); assertEquals(calculateLiteralValue("42 + 55 * 6", ImmutableMap.of()), Long.valueOf(42 + 55 * 6)); assertEquals(calculateLiteralValue("(42 + 55) * 6", ImmutableMap.of()), Long.valueOf((42 + 55) * 6)); assertEquals(calculateLiteralValue("min(10,2)", ImmutableMap.of()), Long.valueOf(2)); assertEquals(calculateLiteralValue("min(10,2*10)", ImmutableMap.of()), Long.valueOf(10)); assertEquals(calculateLiteralValue("max(10,2*10)", ImmutableMap.of()), Long.valueOf(20)); assertEquals(calculateLiteralValue("max(10,2)", ImmutableMap.of()), Long.valueOf(10)); assertEquals(calculateLiteralValue("x + y", ImmutableMap.of("x", 42L, "y", 55L)), Long.valueOf(42 + 55)); }