-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
disallowed null country in billing address in member service
- Loading branch information
1 parent
b8bf14c
commit 670b42a
Showing
2 changed files
with
63 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,14 +16,7 @@ | |
import org.mockito.Mock; | ||
import org.mockito.Mockito; | ||
import org.mockito.MockitoAnnotations; | ||
import org.orcid.memberportal.service.member.client.model.Country; | ||
import org.orcid.memberportal.service.member.client.model.MemberContact; | ||
import org.orcid.memberportal.service.member.client.model.MemberContacts; | ||
import org.orcid.memberportal.service.member.client.model.MemberDetails; | ||
import org.orcid.memberportal.service.member.client.model.MemberOrgId; | ||
import org.orcid.memberportal.service.member.client.model.MemberOrgIds; | ||
import org.orcid.memberportal.service.member.client.model.MemberUpdateData; | ||
import org.orcid.memberportal.service.member.client.model.State; | ||
import org.orcid.memberportal.service.member.client.model.*; | ||
import org.orcid.memberportal.service.member.domain.Member; | ||
import org.orcid.memberportal.service.member.services.MemberService; | ||
import org.orcid.memberportal.service.member.validation.MemberValidation; | ||
|
@@ -105,6 +98,24 @@ public void testUpdatePublicMemberDetails() throws UnauthorizedMemberAccessExcep | |
Mockito.verify(memberService).updateMemberData(Mockito.any(MemberUpdateData.class), Mockito.eq("salesforceId")); | ||
} | ||
|
||
@Test | ||
public void testUpdatePublicMemberDetailsWithBillingAddress() throws UnauthorizedMemberAccessException { | ||
Mockito.when(memberService.updateMemberData(Mockito.any(MemberUpdateData.class), Mockito.eq("salesforceId"))).thenReturn(Boolean.TRUE); | ||
MemberUpdateData memberUpdateData = getPublicMemberDetailsWithBillingAddress(); | ||
ResponseEntity<Boolean> response = memberResource.updatePublicMemberDetails(memberUpdateData, "salesforceId"); | ||
assertEquals(200, response.getStatusCodeValue()); | ||
Mockito.verify(memberService).updateMemberData(Mockito.any(MemberUpdateData.class), Mockito.eq("salesforceId")); | ||
} | ||
|
||
@Test | ||
public void testUpdatePublicMemberDetailsWithBillingAddressAndNullCountry() throws UnauthorizedMemberAccessException { | ||
Mockito.when(memberService.updateMemberData(Mockito.any(MemberUpdateData.class), Mockito.eq("salesforceId"))).thenReturn(Boolean.TRUE); | ||
MemberUpdateData memberUpdateData = getPublicMemberDetailsWithBillingAddressAndNullCountry(); | ||
ResponseEntity<Boolean> response = memberResource.updatePublicMemberDetails(memberUpdateData, "salesforceId"); | ||
assertEquals(400, response.getStatusCodeValue()); | ||
Mockito.verify(memberService, Mockito.never()).updateMemberData(Mockito.any(MemberUpdateData.class), Mockito.eq("salesforceId")); | ||
} | ||
|
||
@Test | ||
public void testUpdatePublicMemberDetails_unauthorised() throws UnauthorizedMemberAccessException { | ||
Mockito.when(memberService.updateMemberData(Mockito.any(MemberUpdateData.class), Mockito.eq("salesforceId"))).thenThrow(new UnauthorizedMemberAccessException("blah", "blah")); | ||
|
@@ -301,6 +312,35 @@ private MemberUpdateData getPublicMemberDetails() { | |
return memberUpdateData; | ||
} | ||
|
||
private MemberUpdateData getPublicMemberDetailsWithBillingAddress() { | ||
MemberUpdateData memberUpdateData = new MemberUpdateData(); | ||
memberUpdateData.setPublicName("test member details"); | ||
memberUpdateData.setWebsite("https://website.com"); | ||
memberUpdateData.setOrgName("orgName"); | ||
memberUpdateData.setDescription("test"); | ||
memberUpdateData.setEmail("[email protected]"); | ||
|
||
BillingAddress billingAddress = new BillingAddress(); | ||
billingAddress.setCity("new york"); | ||
billingAddress.setCountry("USA"); | ||
memberUpdateData.setBillingAddress(billingAddress); | ||
return memberUpdateData; | ||
} | ||
|
||
private MemberUpdateData getPublicMemberDetailsWithBillingAddressAndNullCountry() { | ||
MemberUpdateData memberUpdateData = new MemberUpdateData(); | ||
memberUpdateData.setPublicName("test member details"); | ||
memberUpdateData.setWebsite("https://website.com"); | ||
memberUpdateData.setOrgName("orgName"); | ||
memberUpdateData.setDescription("test"); | ||
memberUpdateData.setEmail("[email protected]"); | ||
|
||
BillingAddress billingAddress = new BillingAddress(); | ||
billingAddress.setCity("new york"); | ||
memberUpdateData.setBillingAddress(billingAddress); | ||
return memberUpdateData; | ||
} | ||
|
||
private MemberContacts getMemberContacts() { | ||
MemberContacts memberContacts = new MemberContacts(); | ||
|
||
|