Skip to content
This repository has been archived by the owner on Apr 28, 2020. It is now read-only.

Commit

Permalink
Added jUnit test to improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
sachin-handiekar committed Feb 1, 2016
1 parent 0e5272e commit ef470d9
Show file tree
Hide file tree
Showing 11 changed files with 1,707 additions and 1 deletion.
Expand Up @@ -41,7 +41,6 @@ public static SubscriptionResponseObject[] getSubscriptionResponseData(String js
* @return VerificationResult a class that represent result of the signature verification
* @throws InstagramException
*/

public static VerificationResult verifySubscriptionPostRequestSignature(String clientSecret, byte[] rawJsonData,
String xHubSignature) throws InstagramException {
SecretKeySpec keySpec;
Expand Down
123 changes: 123 additions & 0 deletions src/test/java/org/jinstagram/auth/InstagramApiTest.java
@@ -0,0 +1,123 @@
package org.jinstagram.auth;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import org.jinstagram.auth.model.OAuthConfig;
import org.jinstagram.auth.oauth.InstagramService;
import org.jinstagram.http.Verbs;
import org.junit.Test;

/**
* The class <code>InstagramApiTest</code> contains tests for the class
* <code>{@link InstagramApi}</code>.
*
*/
public class InstagramApiTest {
/**
* Run the InstagramService createService(OAuthConfig) method test.
*
* @throws Exception
*
*
*/
@Test
public void testCreateService_1() throws Exception {
InstagramApi fixture = new InstagramApi();
OAuthConfig config = new OAuthConfig("", "");

InstagramService result = fixture.createService(config);

// add additional test code here
assertNotNull(result);
assertEquals("1.0", result.getVersion());
}

/**
* Run the String getAccessTokenEndpoint() method test.
*
* @throws Exception
*
*
*/
@Test
public void testGetAccessTokenEndpoint_1() throws Exception {
InstagramApi fixture = new InstagramApi();

String result = fixture.getAccessTokenEndpoint();

// add additional test code here
assertEquals("https://api.instagram.com/oauth/access_token", result);
}

/**
* Run the AccessTokenExtractor getAccessTokenExtractor() method test.
*
* @throws Exception
*
*
*/
@Test
public void testGetAccessTokenExtractor_1() throws Exception {
InstagramApi fixture = new InstagramApi();

AccessTokenExtractor result = fixture.getAccessTokenExtractor();

// add additional test code here
assertNotNull(result);
}

/**
* Run the Verbs getAccessTokenVerb() method test.
*
* @throws Exception
*
*
*/
@Test
public void testGetAccessTokenVerb_1() throws Exception {
InstagramApi fixture = new InstagramApi();

Verbs result = fixture.getAccessTokenVerb();

// add additional test code here
assertNotNull(result);
assertEquals("POST", result.name());
assertEquals("POST", result.toString());
assertEquals(1, result.ordinal());
}

/**
* Run the String getAuthorizationUrl(OAuthConfig) method test.
*
* @throws Exception
*
*
*/
@Test(expected = IllegalArgumentException.class)
public void testGetAuthorizationUrl_1() throws Exception {
InstagramApi fixture = new InstagramApi();
OAuthConfig config = new OAuthConfig("", "", "", "", "");

String result = fixture.getAuthorizationUrl(config);

assertNotNull(result);
}

/**
* Run the String getAuthorizationUrl(OAuthConfig) method test.
*
* @throws Exception
*
*
*/
@Test(expected = IllegalArgumentException.class)
public void testGetAuthorizationUrl_2() throws Exception {
InstagramApi fixture = new InstagramApi();
OAuthConfig config = new OAuthConfig("", "", "", "", "");

String result = fixture.getAuthorizationUrl(config);
assertNotNull(result);
}

}
221 changes: 221 additions & 0 deletions src/test/java/org/jinstagram/auth/InstagramAuthServiceTest.java
@@ -0,0 +1,221 @@
package org.jinstagram.auth;

import static org.junit.Assert.assertNotNull;

import java.net.InetSocketAddress;
import java.net.Proxy;

import org.jinstagram.auth.oauth.InstagramService;
import org.junit.Test;

/**
* The class <code>InstagramAuthServiceTest</code> contains tests for the class
* <code>{@link InstagramAuthService}</code>.
*
*/
public class InstagramAuthServiceTest {
/**
* Run the InstagramAuthService() constructor test.
*
* @throws Exception
*
*
*/
@Test
public void testInstagramAuthService() throws Exception {

InstagramAuthService result = new InstagramAuthService();

// add additional test code here
assertNotNull(result);
}

/**
* Run the InstagramAuthService apiKey(String) method test.
*
* @throws Exception
*
*
*/
@Test(expected = IllegalArgumentException.class)
public void testApiKey() throws Exception {
InstagramAuthService fixture = new InstagramAuthService();
fixture.apiSecret("");
fixture.callback("");
fixture.scope("");
fixture.proxy(new Proxy(java.net.Proxy.Type.DIRECT, new InetSocketAddress(1)));
fixture.apiKey("");
fixture.display("");
String apiKey = "";

InstagramAuthService result = fixture.apiKey(apiKey);
assertNotNull(result);
}

/**
* Run the InstagramAuthService apiSecret(String) method test.
*
* @throws Exception
*
*
*/
@Test(expected = IllegalArgumentException.class)
public void testApiSecret() throws Exception {
InstagramAuthService fixture = new InstagramAuthService();
fixture.apiSecret("");
fixture.callback("");
fixture.scope("");
fixture.proxy(new Proxy(java.net.Proxy.Type.DIRECT, new InetSocketAddress(1)));
fixture.apiKey("");
fixture.display("");
String apiSecret = "";

InstagramAuthService result = fixture.apiSecret(apiSecret);

// add additional test code here
// An unexpected exception was thrown in user code while executing this
// test:
// java.lang.IllegalArgumentException: Invalid Api secret
// at org.jinstagram.utils.Preconditions.check(Preconditions.java:116)
// at
// org.jinstagram.utils.Preconditions.checkEmptyString(Preconditions.java:48)
// at
// org.jinstagram.auth.InstagramAuthService.apiSecret(InstagramAuthService.java:67)
assertNotNull(result);
}

/**
* Run the InstagramService build() method test.
*
* @throws Exception
*
*
*/
@Test(expected = IllegalArgumentException.class)
public void testBuild() throws Exception {
InstagramAuthService fixture = new InstagramAuthService();
fixture.apiSecret("");
fixture.callback("");
fixture.scope("");
fixture.proxy(new Proxy(java.net.Proxy.Type.DIRECT, new InetSocketAddress(1)));
fixture.apiKey("");
fixture.display("");

InstagramService result = fixture.build();

assertNotNull(result);
}

/**
* Run the InstagramService build() method test.
*
* @throws Exception
*
*
*/
@Test(expected = IllegalArgumentException.class)
public void testBuild_2() throws Exception {
InstagramAuthService fixture = new InstagramAuthService();
fixture.apiSecret("");
fixture.callback("");
fixture.scope("");
fixture.proxy((Proxy) null);
fixture.apiKey("");
fixture.display("");

InstagramService result = fixture.build();
assertNotNull(result);
}

/**
* Run the InstagramAuthService callback(String) method test.
*
* @throws Exception
*
*
*/
@Test(expected = IllegalArgumentException.class)
public void testCallback() throws Exception {
InstagramAuthService fixture = new InstagramAuthService();
fixture.apiSecret("");
fixture.callback("");
fixture.scope("");
fixture.proxy(new Proxy(java.net.Proxy.Type.DIRECT, new InetSocketAddress(1)));
fixture.apiKey("");
fixture.display("");
String callback = "";

InstagramAuthService result = fixture.callback(callback);
assertNotNull(result);
}

/**
* Run the InstagramAuthService display(String) method test.
*
* @throws Exception
*
*
*/
@Test(expected = IllegalArgumentException.class)
public void testDisplay() throws Exception {
InstagramAuthService fixture = new InstagramAuthService();
fixture.apiSecret("");
fixture.callback("");
fixture.scope("");
fixture.proxy(new Proxy(java.net.Proxy.Type.DIRECT, new InetSocketAddress(1)));
fixture.apiKey("");
fixture.display("");
String display = "";

InstagramAuthService result = fixture.display(display);

assertNotNull(result);
}

/**
* Run the InstagramAuthService proxy(Proxy) method test.
*
* @throws Exception
*
*
*/
@Test(expected = IllegalArgumentException.class)
public void testProxy() throws Exception {
InstagramAuthService fixture = new InstagramAuthService();
fixture.apiSecret("");
fixture.callback("");
fixture.scope("");
fixture.proxy(new Proxy(java.net.Proxy.Type.DIRECT, new InetSocketAddress(1)));
fixture.apiKey("");
fixture.display("");
Proxy requestProxy = new Proxy(java.net.Proxy.Type.DIRECT, new InetSocketAddress(1));

InstagramAuthService result = fixture.proxy(requestProxy);

assertNotNull(result);
}

/**
* Run the InstagramAuthService scope(String) method test.
*
* @throws Exception
*
*
*/
@Test(expected = IllegalArgumentException.class)
public void testScope() throws Exception {
InstagramAuthService fixture = new InstagramAuthService();
fixture.apiSecret("");
fixture.callback("");
fixture.scope("");
fixture.proxy(new Proxy(java.net.Proxy.Type.DIRECT, new InetSocketAddress(1)));
fixture.apiKey("");
fixture.display("");
String scope = "";

InstagramAuthService result = fixture.scope(scope);

assertNotNull(result);
}

}

0 comments on commit ef470d9

Please sign in to comment.