@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());
   }
 }
 @Transactional(TransactionMode.DISABLED)
 @Test
 @UsingDataSet({"profile.yml", "social_connections.yml"})
 public void findByEmail_EntityGraph_NotLoadSocialConnections() throws Exception {
   Profile profile = profileRepository.findByEmail("*****@*****.**");
   assertEntityGraph(profile);
 }
 @Test
 @UsingDataSet({"profiles.yml"})
 public void findProfilesWithFullnameLike_ValidFullnameInitialsInMixedCase_ReturnsValidProfiles()
     throws Exception {
   List<Profile> profiles = profileRepository.findProfilesWithFullnameLike("tESt");
   Assert.assertThat(profiles, hasSize(3));
 }
 @Test
 public void findProfiles_UsernameNotExists_ReturnEmptyList() throws Exception {
   List<Profile> profiles =
       profileRepository.findProfiles(
           Arrays.asList("test_user_invalid_1", "test_user_invalid_2", "test_user_invalid_3"));
   Assert.assertThat(profiles, hasSize(0));
 }
 @Test
 @UsingDataSet({"profile.yml"})
 public void shouldUpdateAnExistingProfile() throws Exception {
   Profile profile = entityManager.find(Profile.class, 1000L);
   profile.setFullname("Updated User");
   profileRepository.update(profile);
 }
 @Test
 @UsingDataSet({"profiles.yml"})
 public void findProfiles_2ValidNameAndOneInvalid_Return2Profiles() throws Exception {
   List<Profile> profiles =
       profileRepository.findProfiles(
           Arrays.asList("test_user_1", "test_user_2", "test_user_invalid"));
   Assert.assertThat(profiles, hasSize(2));
 }
 @Test
 @UsingDataSet({"profiles.yml"})
 @ShouldMatchDataSet({"profiles.yml"})
 public void findProfiles_ListOfUsernames_ReturnListOfProfiles() throws Exception {
   List<Profile> profiles =
       profileRepository.findProfiles(Arrays.asList("test_user_1", "test_user_2", "test_user_3"));
   Assert.assertThat(profiles, hasSize(3));
 }
 @Test
 @UsingDataSet({"profile.yml"})
 @ShouldMatchDataSet(
     value = {"profile.yml"},
     excludeColumns = {"id"})
 public void findByUsername_ExistingProfile_Found() throws Exception {
   Profile profile = profileRepository.findByUsername("test_user");
   Assert.assertNotNull(profile);
 }
 @Test
 @UsingDataSet({"profile.yml"})
 @ShouldMatchDataSet(
     value = {"profile.yml"},
     excludeColumns = {"id"})
 public void get_ExistingProfile_Found() throws Exception {
   Profile profile = profileRepository.get(1000L);
   Assert.assertNotNull(profile);
 }
 @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());
 }
 @Transactional(TransactionMode.DISABLED)
 @Test
 @UsingDataSet({"profile.yml", "social_connections.yml"})
 public void shouldFindProfileWithSocialConnections() throws Exception {
   Profile profile = profileRepository.findWithSocialConnections("test_user");
   Assert.assertThat(profile.getSocialConnections(), hasSize(2));
   for (SocialConnection socialConnection : profile.getSocialConnections()) {
     Assert.assertEquals(SocialProvider.TWITTER, socialConnection.getProvider());
   }
 }
 @Transactional(TransactionMode.DISABLED)
 @Test
 @UsingDataSet({"profiles.yml", "profiles_social_connections.yml"})
 public void findProfiles_ListOfUsername_ReturnListOfProfilesWithoutSocialConnections()
     throws Exception {
   List<Profile> profiles =
       profileRepository.findProfiles(Arrays.asList("test_user_1", "test_user_2", "test_user_3"));
   Assert.assertThat(profiles, hasSize(3));
   profiles.forEach(this::assertEntityGraph);
 }
 @Test(expected = Exception.class)
 public void save_ExistingEmail_ThrowsException() throws Exception {
   Profile profile = createProfile();
   profileRepository.save(profile);
   profileRepository.save(profile);
 }
 @Test
 public void findProfiles_FullnameInitialInvalid_ReturnEmptyList() throws Exception {
   List<Profile> profiles = profileRepository.findProfilesWithFullnameLike("invalid");
   Assert.assertThat(profiles, hasSize(0));
 }
 @Test
 @UsingDataSet({"profile.yml"})
 public void findByUsername_InvalidUsername_NoProfileFound() throws Exception {
   Profile profile = profileRepository.findByUsername("invalid_user");
   Assert.assertNull(profile);
 }
 @Test
 @UsingDataSet({"profile.yml"})
 public void findByEmail_InvalidEmail_NoProfileFound() throws Exception {
   Profile profile = profileRepository.findByEmail("*****@*****.**");
   Assert.assertNull(profile);
 }