From d1afb8eee237ddb42d7a051ee6aef616640ee5ff Mon Sep 17 00:00:00 2001 From: rusefillc Date: Sun, 17 Oct 2021 11:48:41 -0400 Subject: [PATCH] annotate_if #3358 --- .../ui/livedata/LiveDataParserTest.java | 33 ++++++------------- java_console/ui/ui.iml | 1 + 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/java_console/ui/src/test/java/com/rusefi/ui/livedata/LiveDataParserTest.java b/java_console/ui/src/test/java/com/rusefi/ui/livedata/LiveDataParserTest.java index 96520527bf..2b5c894ec5 100644 --- a/java_console/ui/src/test/java/com/rusefi/ui/livedata/LiveDataParserTest.java +++ b/java_console/ui/src/test/java/com/rusefi/ui/livedata/LiveDataParserTest.java @@ -1,30 +1,26 @@ package com.rusefi.ui.livedata; import com.rusefi.livedata.LiveDataParserPanel; -import org.antlr.v4.runtime.ParserRuleContext; import org.antlr.v4.runtime.tree.ParseTree; import org.antlr.v4.runtime.tree.ParseTreeWalker; -import org.jetbrains.annotations.NotNull; import org.junit.Test; import java.awt.*; -import java.io.IOException; import java.util.Map; import java.util.TreeMap; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.*; + public class LiveDataParserTest { @Test - public void testParsing() throws IOException { + public void testParsing() { Map values = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); values.put("engineTooSlow", Boolean.TRUE); values.put("engineTooFast", Boolean.FALSE); - VariableValueSource valueSource = new VariableValueSource() { - @Override - public Object getValue(String name) { - return values.get(name); - } - }; + VariableValueSource valueSource = values::get; String sourceCode = "bool AcState::getAcState(DECLARE_ENGINE_PARAMETER_SIGNATURE) {\n" + "\tauto rpm = Sensor::getOrZero(SensorType::Rpm);\n" + @@ -43,24 +39,15 @@ public class LiveDataParserTest { "return ff;\n" + "}"; - SourceCodePainter painter = new SourceCodePainter() { - @Override - public void paintBackground(Color color, Range range) { - System.out.println("paint " + color + " " + range); - } - - @Override - public void paintForeground(Color color, Range range) { - System.out.println("paintForeground"); - - } - }; + SourceCodePainter painter = mock(SourceCodePainter.class); ParseTree tree = LiveDataParserPanel.getParseTree(sourceCode); new ParseTreeWalker().walk(new PrintCPP14ParserListener(), tree); LiveDataParserPanel.applyVariables(valueSource, sourceCode, painter, tree); + verify(painter, times(2)).paintForeground(eq(Color.blue), any()); + verify(painter).paintBackground(eq(Color.red), any()); + verify(painter).paintBackground(eq(Color.green), any()); } - } diff --git a/java_console/ui/ui.iml b/java_console/ui/ui.iml index 2966d3746d..079d17b264 100644 --- a/java_console/ui/ui.iml +++ b/java_console/ui/ui.iml @@ -32,5 +32,6 @@ + \ No newline at end of file