@Test public void createAndFindPlatformEntityAndItsChildren() throws Exception { String expectedPlatformName = "platformOne"; String expectedVideoGameName1 = "Some Awesome title"; String expectedVideoGameName2 = "Another Awesome title"; Date dateReleased = new Date(); PlatformEntity platformEntity = new PlatformEntity(); platformEntity.setPlatformName(expectedPlatformName); VideoGameEntity videoGameEntity1 = new VideoGameEntity(); videoGameEntity1.setVideoGameName(expectedVideoGameName1); videoGameEntity1.setDateReleased(dateReleased); videoGameEntity1.setVideoGameStatusType(VideoGameStatusType.COMPLETED); videoGameEntity1.setPlatformEntity(platformEntity); VideoGameEntity videoGameEntity2 = new VideoGameEntity(); videoGameEntity2.setVideoGameName(expectedVideoGameName2); videoGameEntity2.setDateReleased(dateReleased); videoGameEntity2.setVideoGameStatusType(VideoGameStatusType.BACKLOG); videoGameEntity2.setPlatformEntity(platformEntity); platformEntity.getVideoGameEntities().add(videoGameEntity1); platformEntity.getVideoGameEntities().add(videoGameEntity2); PlatformEntity savedPlatformEntity = platformService.create(platformEntity); assertionsForPlatformEntityAndChildVideoGameEntity( expectedPlatformName, expectedVideoGameName1, expectedVideoGameName2, dateReleased, savedPlatformEntity); PlatformEntity retrievedPlatformEntity = platformService.findById(savedPlatformEntity.getPlatformId()); assertThat(retrievedPlatformEntity.getPlatformId(), is(savedPlatformEntity.getPlatformId())); assertionsForPlatformEntityAndChildVideoGameEntity( expectedPlatformName, expectedVideoGameName1, expectedVideoGameName2, dateReleased, retrievedPlatformEntity); List<PlatformEntity> platformEntities = platformService.findAll(); assertThat(platformEntities.size(), is(3)); assertionsForPlatformEntityAndChildVideoGameEntity( expectedPlatformName, expectedVideoGameName1, expectedVideoGameName2, dateReleased, retrievedPlatformEntity); }