-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6948 from ORCID/TogglzCleanup
Togglz cleanup
- Loading branch information
Showing
33 changed files
with
173 additions
and
606 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
package org.orcid.api.memberV2.server.delegator; | ||
|
||
import static org.hamcrest.core.AnyOf.anyOf; | ||
import static org.hamcrest.core.Is.is; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertThat; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.fail; | ||
|
||
|
@@ -14,14 +11,12 @@ | |
|
||
import javax.annotation.Resource; | ||
import javax.ws.rs.core.Response; | ||
import org.orcid.test.DBUnitTest; | ||
import org.orcid.test.helper.Utils; | ||
|
||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.orcid.core.exception.OrcidUnauthorizedException; | ||
import org.orcid.core.togglz.Features; | ||
import org.orcid.core.utils.SecurityContextTestUtils; | ||
import org.orcid.jaxb.model.common_v2.Visibility; | ||
import org.orcid.jaxb.model.groupid_v2.GroupIdRecord; | ||
|
@@ -39,7 +34,9 @@ | |
import org.orcid.jaxb.model.record_v2.ResearcherUrl; | ||
import org.orcid.jaxb.model.record_v2.Work; | ||
import org.orcid.jaxb.model.record_v2.WorkBulk; | ||
import org.orcid.test.DBUnitTest; | ||
import org.orcid.test.OrcidJUnit4ClassRunner; | ||
import org.orcid.test.helper.Utils; | ||
import org.springframework.test.context.ContextConfiguration; | ||
|
||
@RunWith(OrcidJUnit4ClassRunner.class) | ||
|
@@ -142,50 +139,13 @@ public void testViewEmails() { | |
assertEquals("/4444-4444-4444-4443/email", emails.getPath()); | ||
Utils.verifyLastModified(emails.getLastModifiedDate()); | ||
assertNotNull(emails.getEmails()); | ||
|
||
if (Features.HIDE_UNVERIFIED_EMAILS.isActive()) { | ||
assertEquals(1, emails.getEmails().size()); | ||
Email email = emails.getEmails().get(0); | ||
Utils.verifyLastModified(email.getLastModifiedDate()); | ||
assertEquals(email.getEmail(), "[email protected]"); | ||
assertEquals(Visibility.PRIVATE, email.getVisibility()); | ||
assertEquals("APP-5555555555555555", email.retrieveSourcePath()); | ||
assertEquals(true, email.isVerified()); | ||
assertEquals(false, email.isPrimary()); | ||
} else { | ||
assertEquals(3, emails.getEmails().size()); | ||
for (Email email : emails.getEmails()) { | ||
Utils.verifyLastModified(email.getLastModifiedDate()); | ||
assertThat(email.getEmail(), anyOf(is("[email protected]"), is("[email protected]"), is("[email protected]"))); | ||
switch (email.getEmail()) { | ||
case "[email protected]": | ||
assertEquals(Visibility.LIMITED, email.getVisibility()); | ||
assertEquals("4444-4444-4444-4443", email.retrieveSourcePath()); | ||
assertEquals(false, email.isVerified()); | ||
assertEquals(false, email.isPrimary()); | ||
break; | ||
case "[email protected]": | ||
assertEquals(Visibility.PUBLIC, email.getVisibility()); | ||
assertEquals("4444-4444-4444-4443", email.retrieveSourcePath()); | ||
assertEquals(false, email.isVerified()); | ||
assertEquals(false, email.isPrimary()); | ||
break; | ||
case "[email protected]": | ||
assertEquals(Visibility.PRIVATE, email.getVisibility()); | ||
assertEquals("APP-5555555555555555", email.retrieveSourcePath()); | ||
assertEquals(true, email.isVerified()); | ||
assertEquals(false, email.isPrimary()); | ||
break; | ||
case "[email protected]": | ||
assertEquals(Visibility.PRIVATE, email.getVisibility()); | ||
assertEquals("APP-5555555555555555", email.retrieveSourcePath()); | ||
assertEquals(false, email.isVerified()); | ||
assertEquals(true, email.isPrimary()); | ||
break; | ||
default: | ||
fail("Invalid email: " + email.getEmail()); | ||
} | ||
} | ||
} | ||
assertEquals(1, emails.getEmails().size()); | ||
Email email = emails.getEmails().get(0); | ||
Utils.verifyLastModified(email.getLastModifiedDate()); | ||
assertEquals(email.getEmail(), "[email protected]"); | ||
assertEquals(Visibility.PRIVATE, email.getVisibility()); | ||
assertEquals("APP-5555555555555555", email.retrieveSourcePath()); | ||
assertEquals(true, email.isVerified()); | ||
assertEquals(false, email.isPrimary()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,6 @@ | |
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.orcid.core.exception.OrcidUnauthorizedException; | ||
import org.orcid.core.togglz.Features; | ||
import org.orcid.core.utils.SecurityContextTestUtils; | ||
import org.orcid.jaxb.model.common_v2.Visibility; | ||
import org.orcid.jaxb.model.groupid_v2.GroupIdRecord; | ||
|
@@ -515,58 +514,28 @@ public void testReadPrivateEmails_OtherThingsJustPublic_Person() { | |
Emails email = p.getEmails(); | ||
assertNotNull(email); | ||
Utils.verifyLastModified(email.getLastModifiedDate()); | ||
|
||
if (Features.HIDE_UNVERIFIED_EMAILS.isActive()) { | ||
assertEquals(4, email.getEmails().size()); | ||
|
||
boolean found1 = false, found2 = false, found3 = false, found4 = false; | ||
|
||
for (Email element : email.getEmails()) { | ||
if (element.getEmail().equals("[email protected]")) { | ||
found1 = true; | ||
} else if (element.getEmail().equals("[email protected]")) { | ||
found2 = true; | ||
} else if (element.getEmail().equals("[email protected]")) { | ||
found3 = true; | ||
} else if (element.getEmail().equals("[email protected]")) { | ||
found4 = true; | ||
} else { | ||
fail("Invalid email " + element.getEmail()); | ||
} | ||
} | ||
|
||
assertTrue(found1); | ||
assertTrue(found2); | ||
assertTrue(found3); | ||
assertTrue(found4); | ||
} else { | ||
assertEquals(5, email.getEmails().size()); | ||
|
||
boolean found1 = false, found2 = false, found3 = false, found4 = false, found5 = false; | ||
|
||
for (Email element : email.getEmails()) { | ||
if (element.getEmail().equals("[email protected]")) { | ||
found1 = true; | ||
} else if (element.getEmail().equals("[email protected]")) { | ||
found2 = true; | ||
} else if (element.getEmail().equals("[email protected]")) { | ||
found3 = true; | ||
} else if (element.getEmail().equals("[email protected]")) { | ||
found4 = true; | ||
} else if (element.getEmail().equals("[email protected]")) { | ||
found5 = true; | ||
} else { | ||
fail("Invalid email " + element.getEmail()); | ||
} | ||
assertEquals(4, email.getEmails().size()); | ||
|
||
boolean found1 = false, found2 = false, found3 = false, found4 = false; | ||
|
||
for (Email element : email.getEmails()) { | ||
if (element.getEmail().equals("[email protected]")) { | ||
found1 = true; | ||
} else if (element.getEmail().equals("[email protected]")) { | ||
found2 = true; | ||
} else if (element.getEmail().equals("[email protected]")) { | ||
found3 = true; | ||
} else if (element.getEmail().equals("[email protected]")) { | ||
found4 = true; | ||
} else { | ||
fail("Invalid email " + element.getEmail()); | ||
} | ||
|
||
assertTrue(found1); | ||
assertTrue(found2); | ||
assertTrue(found3); | ||
assertTrue(found4); | ||
assertTrue(found5); | ||
} | ||
|
||
assertTrue(found1); | ||
assertTrue(found2); | ||
assertTrue(found3); | ||
assertTrue(found4); | ||
this.assertAllPublicButEmails(p); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,6 @@ | |
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.orcid.core.exception.OrcidUnauthorizedException; | ||
import org.orcid.core.togglz.Features; | ||
import org.orcid.core.utils.SecurityContextTestUtils; | ||
import org.orcid.jaxb.model.common_v2.Iso3166Country; | ||
import org.orcid.jaxb.model.common_v2.Locale; | ||
|
@@ -1004,59 +1003,30 @@ public void testReadPrivateEmails_OtherThingsJustPublic_Record() { | |
assertNotNull(p.getEmails()); | ||
Emails email = p.getEmails(); | ||
assertNotNull(email); | ||
Utils.verifyLastModified(email.getLastModifiedDate()); | ||
|
||
if (Features.HIDE_UNVERIFIED_EMAILS.isActive()) { | ||
assertEquals(4, email.getEmails().size()); | ||
|
||
boolean found1 = false, found2 = false, found3 = false, found4 = false; | ||
|
||
for (Email element : email.getEmails()) { | ||
if (element.getEmail().equals("[email protected]")) { | ||
found1 = true; | ||
} else if (element.getEmail().equals("[email protected]")) { | ||
found2 = true; | ||
} else if (element.getEmail().equals("[email protected]")) { | ||
found3 = true; | ||
} else if (element.getEmail().equals("[email protected]")) { | ||
found4 = true; | ||
} else { | ||
fail("Invalid email " + element.getEmail()); | ||
} | ||
} | ||
|
||
assertTrue(found1); | ||
assertTrue(found2); | ||
assertTrue(found3); | ||
assertTrue(found4); | ||
} else { | ||
assertEquals(5, email.getEmails().size()); | ||
|
||
boolean found1 = false, found2 = false, found3 = false, found4 = false, found5 = false; | ||
|
||
for (Email element : email.getEmails()) { | ||
if (element.getEmail().equals("[email protected]")) { | ||
found1 = true; | ||
} else if (element.getEmail().equals("[email protected]")) { | ||
found2 = true; | ||
} else if (element.getEmail().equals("[email protected]")) { | ||
found3 = true; | ||
} else if (element.getEmail().equals("[email protected]")) { | ||
found4 = true; | ||
} else if (element.getEmail().equals("[email protected]")) { | ||
found5 = true; | ||
} else { | ||
fail("Invalid email " + element.getEmail()); | ||
} | ||
Utils.verifyLastModified(email.getLastModifiedDate()); | ||
assertEquals(4, email.getEmails().size()); | ||
|
||
boolean found1 = false, found2 = false, found3 = false, found4 = false; | ||
|
||
for (Email element : email.getEmails()) { | ||
if (element.getEmail().equals("[email protected]")) { | ||
found1 = true; | ||
} else if (element.getEmail().equals("[email protected]")) { | ||
found2 = true; | ||
} else if (element.getEmail().equals("[email protected]")) { | ||
found3 = true; | ||
} else if (element.getEmail().equals("[email protected]")) { | ||
found4 = true; | ||
} else { | ||
fail("Invalid email " + element.getEmail()); | ||
} | ||
|
||
assertTrue(found1); | ||
assertTrue(found2); | ||
assertTrue(found3); | ||
assertTrue(found4); | ||
assertTrue(found5); | ||
} | ||
|
||
assertTrue(found1); | ||
assertTrue(found2); | ||
assertTrue(found3); | ||
assertTrue(found4); | ||
|
||
this.assertAllPublicButEmails(p); | ||
} | ||
|
||
|
Oops, something went wrong.