@Before public void setUp() { RestAssured.port = serverPort; DeviceEntity deviceEntity = DeviceBuilder.aDevice() .withName(NAME) .withDescription(Optional.of(DESCRIPTION)) .withLocation(Optional.of(LOCATION)) .buildPersistent(deviceJpaRepository); uuid = deviceEntity.getId(); version = deviceEntity.getVersion(); }
@Test public void updatesDevice() { // @formatter:off given() .pathParam("apiVersion", apiVersion) .pathParam("uuid", uuid) .body(new DevicePutJsonImpl()) .contentType(ContentType.JSON) .when() .put(URL) .then() .statusCode(HttpStatus.OK.value()); // @formatter:on List<DeviceEntity> devices = deviceJpaRepository.findAllByOrderByCreationDateDesc(); assertThat(devices.size()).isEqualTo(1); DeviceEntity deviceEntity = devices.get(0); assertThat(deviceEntity.getName()).isEqualTo(UPDATED_NAME); assertThat(deviceEntity.getDescription().get()).isEqualTo(UPDATED_DESCRIPTION); assertThat(deviceEntity.getLocation().get()).isEqualTo(UPDATED_LOCATION); assertThat(deviceEntity.getId()).isEqualTo(uuid); assertThat(deviceEntity.getVersion()).isEqualTo(version + 1); }