@Test public void createPicture() throws Exception { int databaseSizeBeforeCreate = pictureRepository.findAll().size(); // Create the Picture PictureDTO pictureDTO = pictureMapper.pictureToPictureDTO(picture); restPictureMockMvc .perform( post("/api/pictures") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(pictureDTO))) .andExpect(status().isCreated()); // Validate the Picture in the database List<Picture> pictures = pictureRepository.findAll(); assertThat(pictures).hasSize(databaseSizeBeforeCreate + 1); Picture testPicture = pictures.get(pictures.size() - 1); assertThat(testPicture.getTitle()).isEqualTo(DEFAULT_TITLE); assertThat(testPicture.getDescription()).isEqualTo(DEFAULT_DESCRIPTION); assertThat(testPicture.getPictureFile()).isEqualTo(DEFAULT_PICTURE_FILE); assertThat(testPicture.getCreated()).isEqualTo(DEFAULT_CREATED); assertThat(testPicture.getModified()).isEqualTo(DEFAULT_MODIFIED); }
@Test public void updatePicture() throws Exception { // Initialize the database pictureRepository.save(picture); int databaseSizeBeforeUpdate = pictureRepository.findAll().size(); // Update the picture picture.setTitle(UPDATED_TITLE); picture.setDescription(UPDATED_DESCRIPTION); picture.setPictureFile(ByteBuffer.wrap(UPDATED_PICTURE_FILE)); picture.setCreated(UPDATED_CREATED); picture.setModified(UPDATED_MODIFIED); PictureDTO pictureDTO = pictureMapper.pictureToPictureDTO(picture); restPictureMockMvc .perform( put("/api/pictures") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(pictureDTO))) .andExpect(status().isOk()); // Validate the Picture in the database List<Picture> pictures = pictureRepository.findAll(); assertThat(pictures).hasSize(databaseSizeBeforeUpdate); Picture testPicture = pictures.get(pictures.size() - 1); assertThat(testPicture.getTitle()).isEqualTo(UPDATED_TITLE); assertThat(testPicture.getDescription()).isEqualTo(UPDATED_DESCRIPTION); assertThat(testPicture.getPictureFile()).isEqualTo(UPDATED_PICTURE_FILE); assertThat(testPicture.getCreated()).isEqualTo(UPDATED_CREATED); assertThat(testPicture.getModified()).isEqualTo(UPDATED_MODIFIED); }