sngular/pact-annotation-processor

Error generating BigInteger

tfdsimoes opened this issue · 1 comments

Giving the following code

@PactDslBodyBuilder
public class DemoClass {

    private BigInteger aBigInteger1;

    @Example("123")
    private BigInteger getaBigInteger2;
}

The code generated is

public class DemoClassBuilder {
        java.math.BigInteger aBigInteger1;


        java.math.BigInteger getaBigInteger2;

;

  public DemoClassBuilder setABigInteger1(final java.math.BigInteger aBigInteger1) {
    this.aBigInteger1 = aBigInteger1;
    return this;
  }
  public DemoClassBuilder setGetaBigInteger2(final java.math.BigInteger getaBigInteger2) {
    this.getaBigInteger2 = getaBigInteger2;
    return this;
  }

    public DslPart build() {
        PactDslJsonBody pactDslJsonBody = new PactDslJsonBody();



        return pactDslJsonBody;
    }

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

}

No values are set using Example or random generated. Bisdes in DslPart build() there is no set of the new BigInteger variables

Giving the code

@PactDslBodyBuilder
@Data
public class DemoClass {

    private BigInteger aBinInteger1;

    @Example("122333")
    private BigInteger aBinInteger2;
}

It will generate

public class DemoClassBuilder {
        BigInteger aBinInteger1 = new BigInteger("2111329377");
        BigInteger aBinInteger2 = new BigInteger("122333");

    public DemoClassBuilder setABinInteger1(final BigInteger aBinInteger1) {
    this.aBinInteger1 = aBinInteger1;
    return this;
  }
    public DemoClassBuilder setABinInteger2(final BigInteger aBinInteger2) {
    this.aBinInteger2 = aBinInteger2;
    return this;
  }

    public DslPart build() {
        PactDslJsonBody pactDslJsonBody = new PactDslJsonBody();
          if (Objects.nonNull(aBinInteger1)) {
            pactDslJsonBody.integerType("aBinInteger1", aBinInteger1.intValue());
          }
          if (Objects.nonNull(aBinInteger2)) {
            pactDslJsonBody.integerType("aBinInteger2", aBinInteger2.intValue());
          }


        return pactDslJsonBody;
    }

    public DemoClass buildExpectedInstance() {
        DemoClass object = new DemoClass();
          object.setABinInteger1(this.aBinInteger1);
          object.setABinInteger2(this.aBinInteger2);
        return object;
    }

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

}

The List gives a problem, but it should take care in other issue 37, since there is a lot of work to be done in Collections