Skip to content

Commit 4eff28c

Browse files
authored
Merge pull request #108 from EnzoZafra/oauth2-platform-tests
Oauth2 platform tests
2 parents 5e5ce63 + 2a2e32e commit 4eff28c

File tree

2 files changed

+144
-0
lines changed

2 files changed

+144
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package com.intuit.oauth2.data;
2+
3+
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
4+
import org.testng.Assert;
5+
import org.testng.annotations.BeforeMethod;
6+
import org.testng.annotations.BeforeTest;
7+
import org.testng.annotations.Test;
8+
9+
/**
10+
* @author enzozafra
11+
*/
12+
public class AddressTest {
13+
private Address address;
14+
15+
private String streetAddress;
16+
private String locality;
17+
private String region;
18+
private String postalCode;
19+
private String country;
20+
21+
@BeforeTest
22+
public void init() {
23+
streetAddress = "123 Test Street";
24+
locality = "locality";
25+
region = "region";
26+
country = "country";
27+
postalCode = "12345";
28+
}
29+
30+
@BeforeMethod
31+
public void setUp() {
32+
address = new Address();
33+
address.setStreetAddress(streetAddress);
34+
address.setLocality(locality);
35+
address.setRegion(region);
36+
address.setCountry(country);
37+
address.setPostalCode(postalCode);
38+
}
39+
40+
@Test
41+
public void testAllGetters() {
42+
Assert.assertEquals(address.getStreetAddress(), streetAddress);
43+
Assert.assertEquals(address.getLocality(), locality);
44+
Assert.assertEquals(address.getRegion(), region);
45+
Assert.assertEquals(address.getCountry(), country);
46+
Assert.assertEquals(address.getPostalCode(), postalCode);
47+
}
48+
49+
@Test
50+
public void testAllSetters() {
51+
String newStreetAddress = "321 New Street Address";
52+
String newLocality = "New Locality";
53+
String newRegion = "New Region";
54+
String newCountry = "New Country";
55+
String newPostalCode = "54321";
56+
57+
address.setStreetAddress(newStreetAddress);
58+
address.setLocality(newLocality);
59+
address.setRegion(newRegion);
60+
address.setCountry(newCountry);
61+
address.setPostalCode(newPostalCode);
62+
63+
Assert.assertEquals(address.getStreetAddress(), newStreetAddress);
64+
Assert.assertEquals(address.getLocality(), newLocality);
65+
Assert.assertEquals(address.getRegion(), newRegion);
66+
Assert.assertEquals(address.getCountry(), newCountry);
67+
Assert.assertEquals(address.getPostalCode(), newPostalCode);
68+
}
69+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package com.intuit.oauth2.data;
2+
3+
import org.testng.Assert;
4+
import org.testng.annotations.BeforeMethod;
5+
import org.testng.annotations.BeforeTest;
6+
import org.testng.annotations.Test;
7+
8+
/**
9+
* @author enzozafra
10+
*/
11+
public class DiscoveryAPIResponseTest {
12+
private DiscoveryAPIResponse discoveryAPIResponse;
13+
14+
private String issuer;
15+
private String authorizationEndpoint;
16+
private String tokenEndpoint;
17+
private String userinfoEndpoint;
18+
private String revocationEndpoint;
19+
private String jwksUri;
20+
21+
@BeforeTest
22+
public void init() {
23+
issuer = "issuer";
24+
authorizationEndpoint = "authorizationEndpoint";
25+
tokenEndpoint = "tokenEndpoint";
26+
revocationEndpoint = "revocationEndpoint";
27+
userinfoEndpoint = "userinfoEndpoint";
28+
jwksUri = "jwksUri";
29+
}
30+
31+
@BeforeMethod
32+
public void setUp() {
33+
discoveryAPIResponse = new DiscoveryAPIResponse();
34+
discoveryAPIResponse.setIssuer(issuer);
35+
discoveryAPIResponse.setAuthorizationEndpoint(authorizationEndpoint);
36+
discoveryAPIResponse.setTokenEndpoint(tokenEndpoint);
37+
discoveryAPIResponse.setRevocationEndpoint(revocationEndpoint);
38+
discoveryAPIResponse.setUserinfoEndpoint(userinfoEndpoint);
39+
discoveryAPIResponse.setJwksUri(jwksUri);
40+
}
41+
42+
@Test
43+
public void testAllGetters() {
44+
Assert.assertEquals(discoveryAPIResponse.getIssuer(), issuer);
45+
Assert.assertEquals(discoveryAPIResponse.getAuthorizationEndpoint(), authorizationEndpoint);
46+
Assert.assertEquals(discoveryAPIResponse.getTokenEndpoint(), tokenEndpoint);
47+
Assert.assertEquals(discoveryAPIResponse.getRevocationEndpoint(), revocationEndpoint);
48+
Assert.assertEquals(discoveryAPIResponse.getUserinfoEndpoint(), userinfoEndpoint);
49+
Assert.assertEquals(discoveryAPIResponse.getJwksUri(), jwksUri);
50+
}
51+
52+
@Test
53+
public void testAllSetters() {
54+
String newIssuer = "321 New Street Address";
55+
String newAuthorizationEndpoint = "New authorizationEndpoint";
56+
String newTokenEndpoint = "New TokenEndpoint";
57+
String newRevocationEndpoint = "New RevocationEndpoint";
58+
String newUserInfoEndpoint = "New UserinfoEndpoint";
59+
String newJwksUri = "new JwksUri";
60+
61+
discoveryAPIResponse.setIssuer(newIssuer);
62+
discoveryAPIResponse.setAuthorizationEndpoint(newAuthorizationEndpoint);
63+
discoveryAPIResponse.setTokenEndpoint(newTokenEndpoint);
64+
discoveryAPIResponse.setRevocationEndpoint(newRevocationEndpoint);
65+
discoveryAPIResponse.setUserinfoEndpoint(newUserInfoEndpoint);
66+
discoveryAPIResponse.setJwksUri(newJwksUri);
67+
68+
Assert.assertEquals(discoveryAPIResponse.getIssuer(), newIssuer);
69+
Assert.assertEquals(discoveryAPIResponse.getAuthorizationEndpoint(), newAuthorizationEndpoint);
70+
Assert.assertEquals(discoveryAPIResponse.getTokenEndpoint(), newTokenEndpoint);
71+
Assert.assertEquals(discoveryAPIResponse.getRevocationEndpoint(), newRevocationEndpoint);
72+
Assert.assertEquals(discoveryAPIResponse.getUserinfoEndpoint(), newUserInfoEndpoint);
73+
Assert.assertEquals(discoveryAPIResponse.getJwksUri(), newJwksUri);
74+
}
75+
}

0 commit comments

Comments
 (0)