Estou com essa exception ao tentar utilizar o expect(). tenho o seguinte código:
@Test
public void deveDeletarBovino() {
String data = "20/05/2010";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");
LocalDate date = LocalDate.parse(data, formatter);
Bovine bovine = new Bovine();
bovine.setId(2571);
bovine.setBirth(date);
bovine.setWeight(1500.0);
bovine.setValue(new BigDecimal(130));
bovine.setWeightArrobaFree();
bovine.setType(BovineType.BEZERRO);
bovine.setSex(Sex.FEMALE);
bovine.setAge();
bovine.setNick("TESTES4");
int id = bovine.getId();
given().port(port).header("accept", "application/json").contentType("application/json").body(bovine).when()
.post("/cattlefarm/api/listaBovinos/" + id);
expect().statusCode(200).when().delete("/cattlefarm/api/listaBovinos/" + id);
}
ele lança a seguinte exception:
java.lang.SecurityException: class "org.hamcrest.Matchers"'s signer information does not match signer information of other classes in the same package
Quando utilizo o assertEquals do JUnit o teste passa:
public void deveDeletarBovino() {
String data = "20/05/2010";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");
LocalDate date = LocalDate.parse(data, formatter);
Bovine bovine = new Bovine();
bovine.setId(2571);
bovine.setBirth(date);
bovine.setWeight(1500.0);
bovine.setValue(new BigDecimal(130));
bovine.setWeightArrobaFree();
bovine.setType(BovineType.BEZERRO);
bovine.setSex(Sex.FEMALE);
bovine.setAge();
bovine.setNick("TESTES4");
int id = bovine.getId();
given().port(port).header("accept", "application/json").contentType("application/json").body(bovine).when()
.post("/cattlefarm/api/listaBovinos/" + id);
int statusCode = given().port(port).when().delete("/cattlefarm/api/listaBovinos/" + id).andReturn()
.statusCode();
assertEquals(200, statusCode);
}
Me parece um conflito, com o Junit e o RestAssured. Estou Usando Spring-boot e Java 10. segue o link do projeto: https://github.com/igor-rodrigues2017/cattlefarm