From 23541cb9bb06706803935d33ccbedf02481c24f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Blo=CC=88mer?= Date: Thu, 2 Jan 2025 20:00:55 +0100 Subject: [PATCH] Code cleanup --- .../java/de/neuland/pug4j/compiler/Utils.java | 1 - .../pug4j/exceptions/PugException.java | 4 +-- .../expression/GraalJsExpressionHandler.java | 1 - .../pug4j/jexl3/PugJexlArithmetic.java | 2 +- .../pug4j/jexl3/internal/MapBuilder.java | 5 ++-- .../java/de/neuland/pug4j/lexer/Lexer.java | 3 +- .../java/de/neuland/pug4j/model/PugModel.java | 6 ++-- .../java/de/neuland/pug4j/parser/Parser.java | 8 ++---- .../neuland/pug4j/parser/node/AttrsNode.java | 2 +- .../neuland/pug4j/parser/node/BlockNode.java | 1 - .../neuland/pug4j/parser/node/CallNode.java | 28 ++++++------------- .../pug4j/parser/node/CaseConditionNode.java | 24 ---------------- .../neuland/pug4j/parser/node/CaseNode.java | 4 --- .../neuland/pug4j/parser/node/CodeNode.java | 16 ----------- .../pug4j/parser/node/ConditionalNode.java | 7 +++-- .../pug4j/parser/node/ExpressionNode.java | 1 - .../neuland/pug4j/parser/node/FilterNode.java | 8 ------ .../de/neuland/pug4j/parser/node/TagNode.java | 3 +- .../de/neuland/pug4j/AttributeLexerTest.java | 6 ++-- .../GraalJsExpressionHandlerTest.java | 4 +-- .../ComplexIndentOutdentParserTest.java | 2 +- .../pug4j/parser/DoctypeParserTest.java | 2 +- .../pug4j/parser/IncludeParserTest.java | 2 +- .../neuland/pug4j/parser/JadeParserTest.java | 2 +- .../pug4j/parser/LargeBodyTextParserTest.java | 2 +- .../parser/expression/BooleanUtilTest.java | 12 ++++---- 26 files changed, 41 insertions(+), 115 deletions(-) delete mode 100644 src/main/java/de/neuland/pug4j/parser/node/CaseConditionNode.java delete mode 100644 src/main/java/de/neuland/pug4j/parser/node/CodeNode.java diff --git a/src/main/java/de/neuland/pug4j/compiler/Utils.java b/src/main/java/de/neuland/pug4j/compiler/Utils.java index 10f65363..32259467 100644 --- a/src/main/java/de/neuland/pug4j/compiler/Utils.java +++ b/src/main/java/de/neuland/pug4j/compiler/Utils.java @@ -10,7 +10,6 @@ import de.neuland.pug4j.exceptions.ExpressionException; import de.neuland.pug4j.model.PugModel; -import de.neuland.pug4j.parser.node.ExpressionString; public class Utils { public static Pattern interpolationPattern = Pattern.compile("(\\\\)?([#!])\\{"); diff --git a/src/main/java/de/neuland/pug4j/exceptions/PugException.java b/src/main/java/de/neuland/pug4j/exceptions/PugException.java index 66fabdac..570e5342 100644 --- a/src/main/java/de/neuland/pug4j/exceptions/PugException.java +++ b/src/main/java/de/neuland/pug4j/exceptions/PugException.java @@ -1,7 +1,6 @@ package de.neuland.pug4j.exceptions; import java.io.BufferedReader; -import java.io.IOException; import java.io.Reader; import java.net.URL; import java.util.ArrayList; @@ -12,7 +11,6 @@ import de.neuland.pug4j.Pug4J; import de.neuland.pug4j.template.TemplateLoader; import org.apache.commons.lang3.StringUtils; -import org.jetbrains.annotations.NotNull; public abstract class PugException extends RuntimeException { @@ -61,7 +59,7 @@ public int getLineNumber() { public int getColNumber() { return colNumber; } - @NotNull + private String createErrorMessage(String message, int line, int column, String filename) { String fullMessage; String location = line + (column !=0 ? ":" + column : ""); diff --git a/src/main/java/de/neuland/pug4j/expression/GraalJsExpressionHandler.java b/src/main/java/de/neuland/pug4j/expression/GraalJsExpressionHandler.java index f642e54c..924714f6 100644 --- a/src/main/java/de/neuland/pug4j/expression/GraalJsExpressionHandler.java +++ b/src/main/java/de/neuland/pug4j/expression/GraalJsExpressionHandler.java @@ -96,7 +96,6 @@ public Object evaluateExpression(String expression, PugModel model) throws Expre try { jsContextBindings.removeMember(memberKey); }catch(UnsupportedOperationException e){ -// e.printStackTrace(); jsContextBindings.putMember(memberKey, null); } } diff --git a/src/main/java/de/neuland/pug4j/jexl3/PugJexlArithmetic.java b/src/main/java/de/neuland/pug4j/jexl3/PugJexlArithmetic.java index d40dc32c..7f9d55d3 100644 --- a/src/main/java/de/neuland/pug4j/jexl3/PugJexlArithmetic.java +++ b/src/main/java/de/neuland/pug4j/jexl3/PugJexlArithmetic.java @@ -17,7 +17,7 @@ public PugJexlArithmetic(boolean astrict) { * @param left the left operand * @param right the right operator * @param operator the operator - * @return + * @return int */ @Override protected int compare(final Object left, final Object right, final String operator) { diff --git a/src/main/java/de/neuland/pug4j/jexl3/internal/MapBuilder.java b/src/main/java/de/neuland/pug4j/jexl3/internal/MapBuilder.java index 77031a5a..b382ba55 100644 --- a/src/main/java/de/neuland/pug4j/jexl3/internal/MapBuilder.java +++ b/src/main/java/de/neuland/pug4j/jexl3/internal/MapBuilder.java @@ -1,6 +1,5 @@ package de.neuland.pug4j.jexl3.internal; -import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; @@ -8,10 +7,10 @@ public class MapBuilder implements org.apache.commons.jexl3.JexlArithmetic.MapBu protected final Map map; public MapBuilder(int size) { - this.map = new LinkedHashMap(size); + this.map = new LinkedHashMap<>(size); } public MapBuilder(int size, boolean extended) { - this.map = (Map)(extended ? new LinkedHashMap(size) : new LinkedHashMap(size)); + this.map = new LinkedHashMap<>(size); } public void put(Object key, Object value) { diff --git a/src/main/java/de/neuland/pug4j/lexer/Lexer.java b/src/main/java/de/neuland/pug4j/lexer/Lexer.java index 0546dd15..c2539e68 100644 --- a/src/main/java/de/neuland/pug4j/lexer/Lexer.java +++ b/src/main/java/de/neuland/pug4j/lexer/Lexer.java @@ -1496,9 +1496,8 @@ private Token tok(Token token){ newToken.setFileName(this.filename); return newToken; } catch (CloneNotSupportedException e) { - e.printStackTrace(); + throw new PugLexerException("Clone Not Supported",this.filename, this.lineno,this.colno,templateLoader); } - return null; } private boolean pipelessText() { diff --git a/src/main/java/de/neuland/pug4j/model/PugModel.java b/src/main/java/de/neuland/pug4j/model/PugModel.java index a41fb127..470dc433 100644 --- a/src/main/java/de/neuland/pug4j/model/PugModel.java +++ b/src/main/java/de/neuland/pug4j/model/PugModel.java @@ -20,8 +20,8 @@ public class PugModel implements Map { public static final String LOCAL_VARS = "pug4j__localVars"; public static final String PUG4J_MODEL_PREFIX = "pug4j__"; private Deque> scopes = new LinkedList>(); - private Map mixins = new HashMap(); - private Map filter = new HashMap(); + private final Map mixins = new HashMap(); + private final Map filter = new HashMap(); public PugModel(Map defaults) { pushScope(); @@ -138,7 +138,7 @@ public Set keySet() { @Override // adds the object to the correct scope public Object put(String key, Object value) { - Set localVars= getLocalVars(); + Set localVars = getLocalVars(); if(localVars.contains(key)) { return putLocal(key, value); }else{ diff --git a/src/main/java/de/neuland/pug4j/parser/Parser.java b/src/main/java/de/neuland/pug4j/parser/Parser.java index 489cdab2..6bb90816 100644 --- a/src/main/java/de/neuland/pug4j/parser/Parser.java +++ b/src/main/java/de/neuland/pug4j/parser/Parser.java @@ -880,8 +880,6 @@ private Node parseConditional() { conditional.setColumn(conditionalToken.getStartColumn()); conditional.setFileName(filename); - List conditions = conditional.getConditions(); - IfConditionNode main = new IfConditionNode(conditionalToken.getValue(), conditionalToken.getStartLineNumber()); main.setInverse(conditionalToken.isInverseCondition()); main.setFileName(filename); @@ -890,7 +888,7 @@ private Node parseConditional() { }else{ main.setBlock(emptyBlock()); } - conditions.add(main); + conditional.addCondition(main); while (true) { if(peek() instanceof Newline){ @@ -904,7 +902,7 @@ private Node parseConditional() { }else{ elseIf.setBlock(emptyBlock()); } - conditions.add(elseIf); + conditional.addCondition(elseIf); }else if(peek() instanceof Else){ Else token = (Else) expect(Else.class); IfConditionNode elseNode = new IfConditionNode(null, token.getStartLineNumber()); @@ -915,7 +913,7 @@ private Node parseConditional() { }else{ elseNode.setBlock(emptyBlock()); } - conditions.add(elseNode); + conditional.addCondition(elseNode); break; }else{ diff --git a/src/main/java/de/neuland/pug4j/parser/node/AttrsNode.java b/src/main/java/de/neuland/pug4j/parser/node/AttrsNode.java index fd136a30..b56aad27 100644 --- a/src/main/java/de/neuland/pug4j/parser/node/AttrsNode.java +++ b/src/main/java/de/neuland/pug4j/parser/node/AttrsNode.java @@ -91,7 +91,7 @@ protected String visitAttributes(PugModel model, PugTemplate template) { try { o = template.getExpressionHandler().evaluateExpression(attributeBlock, model); } catch (ExpressionException e) { - e.printStackTrace(); + throw new PugCompilerException(this, template.getTemplateLoader(), e); } if(o instanceof Map) { Map map = (Map) o; diff --git a/src/main/java/de/neuland/pug4j/parser/node/BlockNode.java b/src/main/java/de/neuland/pug4j/parser/node/BlockNode.java index 51a08b64..8a85eef1 100644 --- a/src/main/java/de/neuland/pug4j/parser/node/BlockNode.java +++ b/src/main/java/de/neuland/pug4j/parser/node/BlockNode.java @@ -3,7 +3,6 @@ import de.neuland.pug4j.compiler.IndentWriter; import de.neuland.pug4j.exceptions.ExpressionException; import de.neuland.pug4j.exceptions.PugCompilerException; -import de.neuland.pug4j.expression.ExpressionHandler; import de.neuland.pug4j.model.PugModel; import de.neuland.pug4j.parser.Parser; import de.neuland.pug4j.template.PugTemplate; diff --git a/src/main/java/de/neuland/pug4j/parser/node/CallNode.java b/src/main/java/de/neuland/pug4j/parser/node/CallNode.java index 08cbf38e..2d2eefa7 100644 --- a/src/main/java/de/neuland/pug4j/parser/node/CallNode.java +++ b/src/main/java/de/neuland/pug4j/parser/node/CallNode.java @@ -18,13 +18,12 @@ public class CallNode extends AttrsNode { @Override public void execute(IndentWriter writer, PugModel model, PugTemplate template) throws PugCompilerException { boolean dynamic = getName().charAt(0)=='#'; - if (dynamic) - this.dynamicMixins = true; + this.dynamicMixins = dynamic; String newname = (dynamic ? getName().substring(2,getName().length()-1):'"'+getName()+'"'); try { newname = (String) template.getExpressionHandler().evaluateExpression(newname,model); } catch (ExpressionException e) { - e.printStackTrace(); + throw new PugCompilerException(this, template.getTemplateLoader(), e); } MixinNode mixin; @@ -102,7 +101,6 @@ private void writeVariables(PugModel model, MixinNode mixin, PugTemplate templat } } if (key != null) { - model.putLocal(key, value); } } @@ -128,31 +126,23 @@ private void writeVariables(PugModel model, MixinNode mixin, PugTemplate templat private void writeAttributes(PugModel model, MixinNode mixin, PugTemplate template) { LinkedList newAttributes = new LinkedList(attributes); - if (attributeBlocks.size()>0) { - //Todo: AttributesBlock needs to be evaluated - + if (!attributeBlocks.isEmpty()) { for (String attributeBlock : attributeBlocks) { Object o = null; try { o = template.getExpressionHandler().evaluateExpression(attributeBlock, model); } catch (ExpressionException e) { - e.printStackTrace(); + throw new PugCompilerException(this, template.getTemplateLoader(), e); } - if(o!=null) { - if(o instanceof Map) { - for (Map.Entry entry : ((Map) o).entrySet()) { - Attr attr = new Attr(entry.getKey(),entry.getValue(),false); - newAttributes.add(attr); - } - }else if(o instanceof String){ - System.out.print(o); - } - + if(o instanceof Map) { + ((Map) o).entrySet().stream() + .map(entry -> new Attr(entry.getKey(), entry.getValue(), false)) + .forEachOrdered(newAttributes::add); } } } - if (newAttributes.size()>0) { + if (!newAttributes.isEmpty()) { Map attrs = attrs(model, template, newAttributes); model.putLocal("attributes", attrs); }else{ diff --git a/src/main/java/de/neuland/pug4j/parser/node/CaseConditionNode.java b/src/main/java/de/neuland/pug4j/parser/node/CaseConditionNode.java deleted file mode 100644 index e7d41fea..00000000 --- a/src/main/java/de/neuland/pug4j/parser/node/CaseConditionNode.java +++ /dev/null @@ -1,24 +0,0 @@ -package de.neuland.pug4j.parser.node; - -import de.neuland.pug4j.compiler.IndentWriter; -import de.neuland.pug4j.exceptions.PugCompilerException; -import de.neuland.pug4j.model.PugModel; -import de.neuland.pug4j.template.PugTemplate; - -public class CaseConditionNode extends Node { - - private boolean defaultNode = false; - - @Override - public void execute(IndentWriter writer, PugModel model, PugTemplate template) throws PugCompilerException { - block.execute(writer, model, template); - } - - public void setDefault(boolean defaultNode) { - this.defaultNode = defaultNode; - } - - public boolean isDefault() { - return defaultNode; - } -} diff --git a/src/main/java/de/neuland/pug4j/parser/node/CaseNode.java b/src/main/java/de/neuland/pug4j/parser/node/CaseNode.java index 202a4b73..dd64d7c5 100644 --- a/src/main/java/de/neuland/pug4j/parser/node/CaseNode.java +++ b/src/main/java/de/neuland/pug4j/parser/node/CaseNode.java @@ -1,8 +1,5 @@ package de.neuland.pug4j.parser.node; -import java.util.LinkedList; -import java.util.List; - import de.neuland.pug4j.compiler.IndentWriter; import de.neuland.pug4j.exceptions.ExpressionException; import de.neuland.pug4j.exceptions.PugCompilerException; @@ -24,7 +21,6 @@ public void execute(IndentWriter writer, PugModel model, PugTemplate template) t boolean skip = false; for (Node when : block.getNodes()) { if (skip || "default".equals(when.getValue()) || checkCondition(model, when,template.getExpressionHandler())) { - skip = false; if(when.getBlock()!=null) { when.execute(writer, model, template); break; diff --git a/src/main/java/de/neuland/pug4j/parser/node/CodeNode.java b/src/main/java/de/neuland/pug4j/parser/node/CodeNode.java deleted file mode 100644 index 9cfc299f..00000000 --- a/src/main/java/de/neuland/pug4j/parser/node/CodeNode.java +++ /dev/null @@ -1,16 +0,0 @@ -package de.neuland.pug4j.parser.node; - -import de.neuland.pug4j.compiler.IndentWriter; -import de.neuland.pug4j.exceptions.PugCompilerException; -import de.neuland.pug4j.model.PugModel; -import de.neuland.pug4j.template.PugTemplate; - -/** - * Created by christoph on 21.10.15. - */ -public class CodeNode extends Node { - @Override - public void execute(IndentWriter writer, PugModel model, PugTemplate template) throws PugCompilerException { - - } -} diff --git a/src/main/java/de/neuland/pug4j/parser/node/ConditionalNode.java b/src/main/java/de/neuland/pug4j/parser/node/ConditionalNode.java index f350e239..4d25fb19 100644 --- a/src/main/java/de/neuland/pug4j/parser/node/ConditionalNode.java +++ b/src/main/java/de/neuland/pug4j/parser/node/ConditionalNode.java @@ -1,5 +1,6 @@ package de.neuland.pug4j.parser.node; +import java.util.Collections; import java.util.LinkedList; import java.util.List; @@ -34,11 +35,11 @@ private boolean checkCondition(PugModel model, String condition, ExpressionHandl } public List getConditions() { - return conditions; + return Collections.unmodifiableList(conditions); } - public void setConditions(List conditions) { - this.conditions = conditions; + public void addCondition(IfConditionNode condition) { + this.conditions.add(condition); } @Override diff --git a/src/main/java/de/neuland/pug4j/parser/node/ExpressionNode.java b/src/main/java/de/neuland/pug4j/parser/node/ExpressionNode.java index c95ac367..c65e14f8 100644 --- a/src/main/java/de/neuland/pug4j/parser/node/ExpressionNode.java +++ b/src/main/java/de/neuland/pug4j/parser/node/ExpressionNode.java @@ -1,6 +1,5 @@ package de.neuland.pug4j.parser.node; -import com.google.gson.Gson; import org.apache.commons.lang3.StringUtils; import org.apache.commons.text.StringEscapeUtils; diff --git a/src/main/java/de/neuland/pug4j/parser/node/FilterNode.java b/src/main/java/de/neuland/pug4j/parser/node/FilterNode.java index 58918ee1..26f59857 100644 --- a/src/main/java/de/neuland/pug4j/parser/node/FilterNode.java +++ b/src/main/java/de/neuland/pug4j/parser/node/FilterNode.java @@ -2,9 +2,7 @@ import java.util.*; -import com.vladsch.flexmark.ast.Link; import de.neuland.pug4j.compiler.IndentWriter; -import de.neuland.pug4j.compiler.Utils; import de.neuland.pug4j.exceptions.ExpressionException; import de.neuland.pug4j.exceptions.PugCompilerException; import de.neuland.pug4j.expression.ExpressionHandler; @@ -60,12 +58,6 @@ public void execute(IndentWriter writer, PugModel model, PugTemplate template) t result = filter.convert(result, convertToFilterAttributes(template, model, filterValue.getAttributes()), model); } } - -// try { -// result = Utils.interpolate(result, model, false, expressionHandler); -// } catch (ExpressionException e) { -// throw new PugCompilerException(this, template.getTemplateLoader(), e); -// } writer.append(result); } diff --git a/src/main/java/de/neuland/pug4j/parser/node/TagNode.java b/src/main/java/de/neuland/pug4j/parser/node/TagNode.java index 37b5e13e..be893217 100644 --- a/src/main/java/de/neuland/pug4j/parser/node/TagNode.java +++ b/src/main/java/de/neuland/pug4j/parser/node/TagNode.java @@ -131,8 +131,7 @@ private String bufferName(PugTemplate template, PugModel model) { try { return template.getExpressionHandler().evaluateStringExpression(name, model); } catch (ExpressionException e) { - e.printStackTrace(); - return null; + throw new PugCompilerException(this, template.getTemplateLoader(), e); } } else { return name; diff --git a/src/test/java/de/neuland/pug4j/AttributeLexerTest.java b/src/test/java/de/neuland/pug4j/AttributeLexerTest.java index 9fe09b47..ef2eed1f 100644 --- a/src/test/java/de/neuland/pug4j/AttributeLexerTest.java +++ b/src/test/java/de/neuland/pug4j/AttributeLexerTest.java @@ -11,10 +11,9 @@ import org.junit.Test; import java.io.IOException; -import java.util.LinkedList; import java.util.List; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; public class AttributeLexerTest { @@ -33,8 +32,7 @@ private List findAttributes(String attributeString) { } catch (IOException e) { e.printStackTrace(); } - LinkedList tokens = lexer.getTokens(); - return tokens; + return lexer.getTokens(); } private void assertExpressionStringWithValue(Object expression, String expectedValue) { diff --git a/src/test/java/de/neuland/pug4j/expression/GraalJsExpressionHandlerTest.java b/src/test/java/de/neuland/pug4j/expression/GraalJsExpressionHandlerTest.java index 25ab999a..a75db011 100644 --- a/src/test/java/de/neuland/pug4j/expression/GraalJsExpressionHandlerTest.java +++ b/src/test/java/de/neuland/pug4j/expression/GraalJsExpressionHandlerTest.java @@ -41,8 +41,8 @@ public void testArrayList() throws ExpressionException { List addedHostList = Arrays.asList(1,2,3,4); pugModel.put("hostList",addedHostList); graalJsExpressionHandler.evaluateExpression("var list = [1,2,3]", pugModel); - List list = (List) pugModel.get("list"); - List hostList = (List) pugModel.get("hostList"); + List list = (List) pugModel.get("list"); + List hostList = (List) pugModel.get("hostList"); Integer expected = 1; assertEquals(expected,list.get(0)); assertEquals(expected,hostList.get(0)); diff --git a/src/test/java/de/neuland/pug4j/parser/ComplexIndentOutdentParserTest.java b/src/test/java/de/neuland/pug4j/parser/ComplexIndentOutdentParserTest.java index 69c67284..988505b6 100644 --- a/src/test/java/de/neuland/pug4j/parser/ComplexIndentOutdentParserTest.java +++ b/src/test/java/de/neuland/pug4j/parser/ComplexIndentOutdentParserTest.java @@ -2,7 +2,7 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import org.junit.Test; diff --git a/src/test/java/de/neuland/pug4j/parser/DoctypeParserTest.java b/src/test/java/de/neuland/pug4j/parser/DoctypeParserTest.java index 64bf7451..a45a88f0 100644 --- a/src/test/java/de/neuland/pug4j/parser/DoctypeParserTest.java +++ b/src/test/java/de/neuland/pug4j/parser/DoctypeParserTest.java @@ -2,7 +2,7 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import org.junit.Test; diff --git a/src/test/java/de/neuland/pug4j/parser/IncludeParserTest.java b/src/test/java/de/neuland/pug4j/parser/IncludeParserTest.java index 4daa78d3..a83113f1 100644 --- a/src/test/java/de/neuland/pug4j/parser/IncludeParserTest.java +++ b/src/test/java/de/neuland/pug4j/parser/IncludeParserTest.java @@ -3,7 +3,7 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import java.io.FileNotFoundException; import java.net.URISyntaxException; diff --git a/src/test/java/de/neuland/pug4j/parser/JadeParserTest.java b/src/test/java/de/neuland/pug4j/parser/JadeParserTest.java index f2a135aa..210a5737 100644 --- a/src/test/java/de/neuland/pug4j/parser/JadeParserTest.java +++ b/src/test/java/de/neuland/pug4j/parser/JadeParserTest.java @@ -2,7 +2,7 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import org.junit.Test; diff --git a/src/test/java/de/neuland/pug4j/parser/LargeBodyTextParserTest.java b/src/test/java/de/neuland/pug4j/parser/LargeBodyTextParserTest.java index fedaa2f2..c9e2f7a7 100644 --- a/src/test/java/de/neuland/pug4j/parser/LargeBodyTextParserTest.java +++ b/src/test/java/de/neuland/pug4j/parser/LargeBodyTextParserTest.java @@ -3,7 +3,7 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import java.io.FileNotFoundException; import java.net.URISyntaxException; diff --git a/src/test/java/de/neuland/pug4j/parser/expression/BooleanUtilTest.java b/src/test/java/de/neuland/pug4j/parser/expression/BooleanUtilTest.java index 9d4932be..c2a1f8cf 100644 --- a/src/test/java/de/neuland/pug4j/parser/expression/BooleanUtilTest.java +++ b/src/test/java/de/neuland/pug4j/parser/expression/BooleanUtilTest.java @@ -4,7 +4,7 @@ import static org.junit.Assert.assertTrue; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import org.junit.Test; @@ -18,19 +18,19 @@ public void convert() { List falses = new ArrayList(); List trues = new ArrayList(); - falses.add(new Integer(0)); - falses.add(new Double(0.0)); + falses.add(Integer.valueOf(0)); + falses.add(Double.valueOf(0.0)); falses.add(""); falses.add(Boolean.FALSE); falses.add(new ArrayList()); falses.add(new int[] {}); - trues.add(new Integer(1)); - trues.add(new Double(0.5)); + trues.add(Integer.valueOf(1)); + trues.add(Double.valueOf(0.5)); trues.add("a"); trues.add(" "); trues.add(Boolean.TRUE); - trues.add(Arrays.asList("a")); + trues.add(Collections.singletonList("a")); trues.add(new int[] { 1, 2 }); trues.add(new Object());