@Test public void createAndFindVideoGameEntityAndItsParent() throws Exception { PlatformEntity platformEntity = new PlatformEntity(); String platformName = "I am a platform"; platformEntity.setPlatformName(platformName); Date videoGamedateReleased = new Date(); String videoGameName = "new title"; VideoGameEntity videoGameEntity = new VideoGameEntity(); videoGameEntity.setDateReleased(videoGamedateReleased); videoGameEntity.setVideoGameStatusType(VideoGameStatusType.PLAYING); videoGameEntity.setVideoGameName(videoGameName); videoGameEntity.setPlatformEntity(platformEntity); VideoGameEntity savedVideoGameEntity = videoGameService.create(videoGameEntity); VideoGameEntity retrievedVideoGameEntity = videoGameService.findById(savedVideoGameEntity.getVideoGameId()); assertThat( retrievedVideoGameEntity.getVideoGameId(), is(savedVideoGameEntity.getVideoGameId())); assertThat( retrievedVideoGameEntity.getVideoGameName(), is(savedVideoGameEntity.getVideoGameName())); assertThat(retrievedVideoGameEntity.getVideoGameStatusType(), is(VideoGameStatusType.PLAYING)); assertThat(retrievedVideoGameEntity.getPlatformEntity().getPlatformName(), is(platformName)); }
@Test public void updateVideoGameEntity() throws Exception { long existingVideoGameId = 22L; String updatedVideoGameName = "some new name"; Date updatedDateReleased = new Date(); VideoGameEntity updatedVideoGameEntity = new VideoGameEntity(); updatedVideoGameEntity.setVideoGameId(existingVideoGameId); updatedVideoGameEntity.setVideoGameName(updatedVideoGameName); updatedVideoGameEntity.setDateReleased(updatedDateReleased); updatedVideoGameEntity.setVideoGameStatusType(VideoGameStatusType.COMPLETED); VideoGameEntity retrievedVideoGameEntity = videoGameService.update(updatedVideoGameEntity); assertThat(retrievedVideoGameEntity.getVideoGameId(), is(existingVideoGameId)); assertThat(retrievedVideoGameEntity.getVideoGameName(), is(updatedVideoGameName)); assertThat( retrievedVideoGameEntity.getVideoGameStatusType(), is(VideoGameStatusType.COMPLETED)); assertThat(retrievedVideoGameEntity.getDateReleased(), is(updatedDateReleased)); assertThat(retrievedVideoGameEntity.getPlatformEntity(), is(nullValue())); }