@Test @UsingDataSet({"social_connection.yml"}) public void save_ExistingSocialConnection_ProfileSavedSocialConnectionUpdated() throws Exception { Profile profile = createProfile(); SocialConnection connection = socialConnectionRepository.findByConnectionId("test_connection"); profile.addSocialConnection(connection); Profile saved = profileRepository.save(profile); Assert.assertNotNull(saved); }
@Test @ShouldMatchDataSet( value = {"profile.yml"}, excludeColumns = {"id"}) public void save_NewProfile_ShouldBeCreated() throws Exception { Profile profile = createProfile(); Profile saved = profileRepository.save(profile); Assert.assertNotNull(saved); Assert.assertNotNull(saved.getId()); }
@Test @UsingDataSet({"profile.yml"}) @ShouldMatchDataSet( value = {"profile.yml", "social_connection.yml"}, excludeColumns = {"id"}) public void shouldAddSocialConnectionToProfile() throws Exception { Profile profile = profileRepository.get(1000L); profile.addSocialConnection(createSocialConnection()); profileRepository.save(profile); }
@Test @ShouldMatchDataSet( value = {"profile.yml", "social_connection.yml"}, excludeColumns = {"id"}) public void save_NewProfileWithSocialConnection_ShouldPersist() throws Exception { Profile profile = createProfile(); profile.addSocialConnection(createSocialConnection()); Profile saved = profileRepository.save(profile); Profile persistedProfile = profileRepository.get(saved.getId()); for (SocialConnection socialConnection : persistedProfile.getSocialConnections()) { Assert.assertNotNull(socialConnection.getId()); } }
@Test(expected = Exception.class) public void save_ExistingEmail_ThrowsException() throws Exception { Profile profile = createProfile(); profileRepository.save(profile); profileRepository.save(profile); }