DoubleLiteralEvaluator implements NumberEvaluator<StellarParser.DoubleLiteralContext> { @Override public Token<Double> evaluate(StellarParser.DoubleLiteralContext context, FrameContext.Context contextVariety) { if (context == null) { throw new IllegalArgumentException("Cannot evaluate a context that is null."); } return new Token<>(Double.parseDouble(context.getText()), Double.class, contextVariety); }  @Override Token<Double> evaluate(StellarParser.DoubleLiteralContext context, FrameContext.Context contextVariety);  }
@Test public void verifyHappyPathEvaluation() { when(context.getText()).thenReturn("100D"); Token<? extends Number> evaluated = evaluator.evaluate(context, null); assertEquals(new Token<>(100D, Double.class, null), evaluated); verify(context).getText(); verifyNoMoreInteractions(context); }
@Test public void verifyNumberFormationExceptionWithEmptyString() { when(context.getText()).thenReturn(""); assertThrows(NumberFormatException.class, () -> evaluator.evaluate(context, null)); }
@Test public void throwIllegalArgumentExceptionWhenContextIsNull() { IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> evaluator.evaluate(null, null)); assertEquals("Cannot evaluate a context that is null.", e.getMessage()); }