Skip to content

Commit b10aac2

Browse files
author
pbaid
committed
Add test coverage ProxyConfig and Scope
1 parent 1187c6f commit b10aac2

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2017 Intuit
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*******************************************************************************/
16+
package com.intuit.oauth2.config;
17+
18+
import org.testng.annotations.Test;
19+
20+
import static org.testng.Assert.assertEquals;
21+
import static org.testng.Assert.assertNotNull;
22+
23+
/**
24+
* Config class to hold the proxy properties
25+
*
26+
* @author dderose
27+
*/
28+
public class ProxyConfigTest {
29+
30+
private ProxyConfig.ProxyConfigBuilder initProxyConfigBuilder()
31+
{
32+
ProxyConfig.ProxyConfigBuilder proxyConfigBuilder = new ProxyConfig.ProxyConfigBuilder("oauth.platform.intuit.com","8080");
33+
proxyConfigBuilder.username("myusername");
34+
proxyConfigBuilder.password("mypassword");
35+
proxyConfigBuilder.domain("mydomain");
36+
return proxyConfigBuilder;
37+
}
38+
39+
40+
@Test
41+
public void testProxyConfigBuilder()
42+
{
43+
ProxyConfig.ProxyConfigBuilder proxyConfigBuilder = initProxyConfigBuilder();
44+
ProxyConfig proxyConfig = proxyConfigBuilder.buildConfig();
45+
assertNotNull(proxyConfigBuilder);
46+
assertNotNull(proxyConfig);
47+
assertEquals("oauth.platform.intuit.com", proxyConfig.getHost());
48+
assertEquals("8080", proxyConfig.getPort());
49+
assertEquals("myusername", proxyConfig.getUsername());
50+
assertEquals("mypassword", proxyConfig.getPassword());
51+
assertEquals("mydomain", proxyConfig.getDomain());
52+
}
53+
54+
55+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2017 Intuit
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*******************************************************************************/
16+
package com.intuit.oauth2.config;
17+
18+
import com.intuit.oauth2.exception.InvalidRequestException;
19+
import org.testng.annotations.DataProvider;
20+
import org.testng.annotations.Test;
21+
22+
import java.util.HashSet;
23+
import java.util.Iterator;
24+
import java.util.Set;
25+
26+
import static org.testng.Assert.*;
27+
28+
/**
29+
* Config class to hold the proxy properties
30+
*
31+
* @author dderose
32+
*/
33+
public class ScopeTest {
34+
35+
@Test(expectedExceptions = IllegalArgumentException.class)
36+
public void testfromValueforIllegalArgument()
37+
{
38+
String badenum ="I am bad value";
39+
Scope.fromValue(badenum);
40+
fail(badenum + " is not present in the Scope enum");
41+
}
42+
43+
44+
@DataProvider(parallel = true, name = "validScopeValuesdp")
45+
public Iterator<Object[]> validScopeValuesdp() {
46+
47+
Set<Object[]> dataToBeReturned = new HashSet<>();
48+
49+
for (Scope scope : Scope.values()) {
50+
dataToBeReturned.add(new Object[]{scope.name(), scope.value()});
51+
}
52+
return dataToBeReturned.iterator();
53+
}
54+
55+
56+
@Test(dataProvider = "validScopeValuesdp")
57+
public void testfromValueforInvalidArgument(String name, String value)
58+
{
59+
try{
60+
Scope returnedScope = Scope.fromValue(value);
61+
assertNotNull(returnedScope);
62+
assertTrue(returnedScope.name().equals(name));
63+
} catch (Exception e)
64+
{
65+
fail(value + "is a valid Scope enumvalue.");
66+
}
67+
}
68+
69+
70+
}

0 commit comments

Comments
 (0)