Skip to content

Commit

Permalink
49 increment coverage for testing PR (#51)
Browse files Browse the repository at this point in the history
* Building test

* Mocking Random Generator.

* Add custom Dates Format

* Add Test

* Add Test

* Add Test

* Add Test

* Standardize test section

* README.md codacy corrections

* README.md codacy corrections

* README.md codacy corrections

* Fix import & format

* #14 Merge Master fix things

* Align style files with main branch

* #14 Merge Master fix things

* #14 Fix MarkdownLint complains

* #14 fix Codacy issues

* #14 Merge Master fix things

* Short random values limitation fix

* BigInteger imports missed

* #14 Fix numbers

* #14 Fix Date Parser

* #14 Fix Date Parser

* #14 Merge with Master

* #14 Merge with Master

* 49-increment-coverage-for-testing

* #49 Version bump

---------

Co-authored-by: Jose Enrique García Maciñeiras <[email protected]>
Co-authored-by: Alejandro Pena Lorenzo <[email protected]>
Co-authored-by: Jose E. Garcia Maciñeiras <[email protected]>
  • Loading branch information
4 people authored Jan 17, 2024
1 parent eb3193f commit 5e906db
Show file tree
Hide file tree
Showing 5 changed files with 338 additions and 19 deletions.
12 changes: 11 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.sngular</groupId>
<artifactId>pact-annotation-processor</artifactId>
<version>1.2.1</version>
<version>1.2.2</version>

<name>PactDslBuilder - Annotation Processor</name>
<description>Pact DSL Builder annotation processor.</description>
Expand Down Expand Up @@ -60,6 +60,16 @@
</roles>
<timezone>Europe/Madrid</timezone>
</developer>
<developer>
<id>MiguelSngularGithub</id>
<name>Miguel Angel Escobar Perez</name>
<email>[email protected]</email>
<organizationUrl />
<roles>
<role>Software Engineer</role>
</roles>
<timezone>America/CDMX</timezone>
</developer>
</developers>

<scm>
Expand Down
48 changes: 43 additions & 5 deletions src/test/resources/basic/CharacterDataTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ public class CharacterDataTypes {
@Example("nameExample")
private String name;

// @Example("a")
// private char charField;
//
// @Example("charArray")
// private char[] charArrayField;
@Example("a")
private char primitiveChar;

@Example("b")
private Character charObject;

@Example("true")
private boolean primitiveBoolean;

@Example("false")
private Boolean booleanObject;

protected String getName() {
return name;
Expand All @@ -22,4 +28,36 @@ protected String getName() {
protected void setName(final String name) {
this.name = name;
}

public char getPrimitiveChar() {
return primitiveChar;
}

public void setPrimitiveChar(char primitiveChar) {
this.primitiveChar = primitiveChar;
}

public Character getCharObject() {
return charObject;
}

public void setCharObject(Character charObject) {
this.charObject = charObject;
}

public boolean isPrimitiveBoolean() {
return primitiveBoolean;
}

public void setPrimitiveBoolean(boolean primitiveBoolean) {
this.primitiveBoolean = primitiveBoolean;
}

public Boolean getBooleanObject() {
return booleanObject;
}

public void setBooleanObject(Boolean booleanObject) {
this.booleanObject = booleanObject;
}
}
51 changes: 50 additions & 1 deletion src/test/resources/basic/CharacterDataTypesBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,75 @@
public class CharacterDataTypesBuilder {
String name = "nameExample";

String primitiveChar = "a";

String charObject = "b";

boolean primitiveBoolean = true;

boolean booleanObject = false;

public CharacterDataTypesBuilder setName(final String name) {
this.name = name;
return this;
}

public CharacterDataTypesBuilder setPrimitiveChar(final String primitiveChar) {
this.primitiveChar = primitiveChar;
return this;
}

public CharacterDataTypesBuilder setCharObject(final String charObject) {
this.charObject = charObject;
return this;
}

public CharacterDataTypesBuilder setPrimitiveBoolean(final boolean primitiveBoolean) {
this.primitiveBoolean = primitiveBoolean;
return this;
}

public CharacterDataTypesBuilder setBooleanObject(final boolean booleanObject) {
this.booleanObject = booleanObject;
return this;
}

public DslPart build() {
PactDslJsonBody pactDslJsonBody = new PactDslJsonBody();
if (Objects.nonNull(name)) {
pactDslJsonBody.stringType("name", name);
}

if (Objects.nonNull(primitiveChar)) {
pactDslJsonBody.stringType("primitiveChar", primitiveChar);
}

if (Objects.nonNull(charObject)) {
pactDslJsonBody.stringType("charObject", charObject);
}

if (Objects.nonNull(primitiveBoolean)) {
pactDslJsonBody.booleanType("primitiveBoolean", primitiveBoolean);
}

if (Objects.nonNull(booleanObject)) {
pactDslJsonBody.booleanType("booleanObject", booleanObject);
}

return pactDslJsonBody;
}

public CharacterDataTypes buildExpectedInstance() {
CharacterDataTypes object = new CharacterDataTypes();
object.setName(this.name);
object.setPrimitiveChar(this.primitiveChar.charAt(0));
object.setCharObject(this.charObject.charAt(0));
object.setPrimitiveBoolean(this.primitiveBoolean);
object.setBooleanObject(this.booleanObject);
return object;
}

private static void applyCustomModifiers(PactDslJsonBody pactDslJsonBody) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
}

}

123 changes: 112 additions & 11 deletions src/test/resources/basic/NumericDataTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import com.sngular.annotation.pact.Example;
import com.sngular.annotation.pact.PactDslBodyBuilder;

import java.math.BigInteger;
import java.math.BigDecimal;

@PactDslBodyBuilder
public class NumericDataTypes {

Expand All @@ -18,17 +21,35 @@ public class NumericDataTypes {
@Example("40")
private long primitiveLong;

// @Example("50")
// private Float floatObject;
//
// @Example("60")
// private float primitiveFloat;
//
// @Example("70")
// private BigInteger bigInteger;
//
// @Example("80")
// private BigDecimal bigDecimal;
@Example("50.1234")
private Float floatObject;

@Example("60.2345")
private float primitiveFloat;

@Example("70.3456")
private Double doubleObject;

@Example("80.4567")
private double primitiveDouble;

@Example("90")
private Short shortObject;

@Example("100")
private short primitiveShort;

@Example("110")
private Byte byteObject;

@Example("120")
private byte primitiveByte;

@Example("1303812548123548216")
private BigInteger bigIntegerObject;

@Example("1402354872534672834.2345")
private BigDecimal bigDecimalObject;

protected Integer getInteger() {
return integer;
Expand Down Expand Up @@ -61,4 +82,84 @@ protected long getPrimitiveLong() {
protected void setPrimitiveLong(final long primitiveLong) {
this.primitiveLong = primitiveLong;
}

public Float getFloatObject() {
return floatObject;
}

public void setFloatObject(Float floatObject) {
this.floatObject = floatObject;
}

public float getPrimitiveFloat() {
return primitiveFloat;
}

public void setPrimitiveFloat(float primitiveFloat) {
this.primitiveFloat = primitiveFloat;
}

public Double getDoubleObject() {
return doubleObject;
}

public void setDoubleObject(Double doubleObject) {
this.doubleObject = doubleObject;
}

public double getPrimitiveDouble() {
return primitiveDouble;
}

public void setPrimitiveDouble(double primitiveDouble) {
this.primitiveDouble = primitiveDouble;
}

public Short getShortObject() {
return shortObject;
}

public void setShortObject(Short shortObject) {
this.shortObject = shortObject;
}

public short getPrimitiveShort() {
return primitiveShort;
}

public void setPrimitiveShort(short primitiveShort) {
this.primitiveShort = primitiveShort;
}

public Byte getByteObject() {
return byteObject;
}

public void setByteObject(Byte byteObject) {
this.byteObject = byteObject;
}

public byte getPrimitiveByte() {
return primitiveByte;
}

public void setPrimitiveByte(byte primitiveByte) {
this.primitiveByte = primitiveByte;
}

public BigInteger getBigIntegerObject() {
return bigIntegerObject;
}

public void setBigIntegerObject(BigInteger bigIntegerObject) {
this.bigIntegerObject = bigIntegerObject;
}

public BigDecimal getBigDecimalObject() {
return bigDecimalObject;
}

public void setBigDecimalObject(BigDecimal bigDecimalObject) {
this.bigDecimalObject = bigDecimalObject;
}
}
Loading

0 comments on commit 5e906db

Please sign in to comment.