Skip to content

Commit

Permalink
quality
Browse files Browse the repository at this point in the history
  • Loading branch information
boretti committed Apr 22, 2018
1 parent 5342d90 commit 06a15d2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,11 @@ public String getFieldCopy(String lhs, String rhs) {

public String getFieldCopyForList(String lhs, String rhs) {
String fieldAccessor = getFieldAccessor();
return "if(" + rhs + "." + fieldAccessor + "==null) {" + lhs + "." + getFieldName() + "(" + MATCHERS
+ ".nullValue()); } else if (" + rhs + "." + fieldAccessor + ".isEmpty()) {" + lhs + "."
+ getFieldName() + "IsEmptyIterable(); } else {" + lhs + "." + getFieldName() + "Contains(" + rhs + "."
+ fieldAccessor + ".stream().map(" + generateMatcherBuilderReferenceFor(generic)
String fieldName = getFieldName();
return "if(" + rhs + "." + fieldAccessor + "==null) {" + lhs + "." + fieldName + "(" + MATCHERS
+ ".nullValue()); } else if (" + rhs + "." + fieldAccessor + ".isEmpty()) {" + lhs + "." + fieldName
+ "IsEmptyIterable(); } else {" + lhs + "." + fieldName + "Contains(" + rhs + "." + fieldAccessor
+ ".stream().map(" + generateMatcherBuilderReferenceFor(generic)
+ ").collect(java.util.stream.Collectors.toList())); }";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,26 @@ public ComparableFieldDescription(ProvidesMatchersAnnotatedElementData containin

@Override
protected Collection<FieldDSLMethod> getSpecificFieldDslMethodFor() {
String fieldtype = getFieldType();
return Arrays.asList(
getDslMethodBuilder().withDeclaration("ComparesEqualTo", this.getFieldType() + " value")
getDslMethodBuilder().withDeclaration("ComparesEqualTo", fieldtype + " value")
.withJavaDoc("that this field is equals to another one, using the compareTo method",
"value the value to compare with", MATCHERS + "#comparesEqualTo(java.lang.Comparable)")
.havingDefault(MATCHERS + ".comparesEqualTo(value)"),
getDslMethodBuilder().withDeclaration("LessThan", this.getFieldType() + " value")
getDslMethodBuilder().withDeclaration("LessThan", fieldtype + " value")
.withJavaDoc("that this field is less than another value", "value the value to compare with",
MATCHERS + "#lessThan(java.lang.Comparable)")
.havingDefault(MATCHERS + ".lessThan(value)"),
getDslMethodBuilder().withDeclaration("lessThanOrEqualTo", this.getFieldType() + " value")
getDslMethodBuilder().withDeclaration("lessThanOrEqualTo", fieldtype + " value")
.withJavaDoc("that this field is less or equal than another value",
"value the value to compare with",
MATCHERS + "#lessThanOrEqualTo(java.lang.Comparable)")
.havingDefault(MATCHERS + ".lessThanOrEqualTo(value)"),
getDslMethodBuilder().withDeclaration("GreaterThan", this.getFieldType() + " value")
getDslMethodBuilder().withDeclaration("GreaterThan", fieldtype + " value")
.withJavaDoc("that this field is greater than another value", "value the value to compare with",
MATCHERS + "#greaterThan(java.lang.Comparable)")
.havingDefault(MATCHERS + ".greaterThan(value)"),
getDslMethodBuilder().withDeclaration("GreaterThanOrEqualTo", this.getFieldType() + " value")
getDslMethodBuilder().withDeclaration("GreaterThanOrEqualTo", fieldtype + " value")
.withJavaDoc("that this field is greater or equal than another value",
"value the value to compare with",
MATCHERS + "#greaterThanOrEqualTo(java.lang.Comparable)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ public OptionalFieldDescription(ProvidesMatchersAnnotatedElementData containingE

@Override
protected Collection<FieldDSLMethod> getSpecificFieldDslMethodFor() {
String fieldType = getFieldType();
return Arrays.asList(
getDslMethodBuilder().withDeclaration("IsPresent", "").withJavaDoc("with a present optional")
.havingDefault("new org.hamcrest.CustomTypeSafeMatcher<" + this.getFieldType()
+ ">(\"optional is present\"){ public boolean matchesSafely(" + this.getFieldType()
.havingDefault("new org.hamcrest.CustomTypeSafeMatcher<" + fieldType
+ ">(\"optional is present\"){ public boolean matchesSafely(" + fieldType
+ " o) {return o.isPresent();}}"),
getDslMethodBuilder().withDeclaration("IsNotPresent", "").withJavaDoc("with a not present optional")
.havingDefault("new org.hamcrest.CustomTypeSafeMatcher<" + this.getFieldType()
+ ">(\"optional is not present\"){ public boolean matchesSafely(" + this.getFieldType()
.havingDefault("new org.hamcrest.CustomTypeSafeMatcher<" + fieldType
+ ">(\"optional is not present\"){ public boolean matchesSafely(" + fieldType
+ " o) {return !o.isPresent();}}"));
}

Expand Down

0 comments on commit 06a15d2

Please sign in to comment.