Skip to content

Commit

Permalink
Merge pull request #132 from eileenzhuang1/master
Browse files Browse the repository at this point in the history
Fixed 404 NotFound failures
  • Loading branch information
Bob Hewett committed Jun 2, 2015
2 parents f3ba801 + 23ab631 commit 710aa8a
Show file tree
Hide file tree
Showing 130 changed files with 8,427 additions and 8,270 deletions.
7 changes: 5 additions & 2 deletions mozu-java-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ jar {
}

task wrapper(type: Wrapper) {
gradleVersion = '1.11'
gradleVersion = '1.12'
}

repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/groups/staging/"
}
mavenLocal()
}

Expand Down Expand Up @@ -63,7 +66,7 @@ dependencies {
compile ('log4j:log4j:1.2.17')


testCompile group: 'junit', name: 'junit', version: '4.+'
testCompile group: 'junit', name: 'junit', version: '4.12'
}

test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public MozuApiTestBase()
ApiContext apiContext = new MozuApiContext();
AppAuthenticator.initialize(appAuthInfo, null);
try {
testBaseTenant = TenantFactory.getTenant(apiContext, tenantId, HttpStatus.SC_OK, HttpStatus.SC_OK);
testBaseTenant = TenantFactory.getTenant(apiContext, tenantId, HttpStatus.SC_OK);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ public class TestException extends Exception {
private static final long serialVersionUID = 1L;
private Logger logger = LoggerFactory.getLogger(TestException.class);

protected int expectedReturnCode;
protected String expectedReturnCode;
protected String message ;
protected String clientMethodName;

public int actualReturnCode;
protected String actualReturnCode;

protected TestException(int actualCode, String methodName, int expectedCode, String msg) {
protected TestException(String actualCode, String methodName, String expectedCode, String msg) {
expectedReturnCode = expectedCode;
actualReturnCode = actualCode;
message = msg;
Expand Down Expand Up @@ -46,7 +45,12 @@ protected TestException(String methodName, String msg)
@Override
public String toString()
{
return String.format("[%s:expected %s] but the actual return code is %s. %s", clientMethodName, expectedReturnCode, actualReturnCode, message);
return String.format("[%s: expected %s] but the actual return code is %s. %s", clientMethodName, expectedReturnCode, actualReturnCode, message);
}

public String getActualReturnCode()
{
return actualReturnCode;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ public class TestFailException extends TestException {
private static final long serialVersionUID = 1L;
private Logger logger = LoggerFactory.getLogger(TestFailException.class);

public TestFailException(int actualCode, String methodName, int expectedCode, String msg) {
public TestFailException(String actualCode, String methodName, String expectedCode, String msg) {
super(actualCode, methodName, expectedCode, msg);
}

@Override
public String toString()
{
String msg = super.toString();
if(super.actualReturnCode == 403)
if(super.actualReturnCode.equals("403"))
{
return msg += String.format("\nYou may need to add the proper behavior for %s", super.clientMethodName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import java.util.List;
import java.util.ArrayList;
import org.apache.http.HttpStatus;
import com.mozu.api.ApiException;
import com.mozu.api.ApiContext;
import com.mozu.test.framework.core.TestFailException;
Expand All @@ -20,12 +21,12 @@
public class AddressValidationRequestFactory
{

public static com.mozu.api.contracts.customer.AddressValidationResponse validateAddress(ApiContext apiContext, com.mozu.api.contracts.customer.AddressValidationRequest addressValidationRequest, int expectedCode, int successCode) throws Exception
public static com.mozu.api.contracts.customer.AddressValidationResponse validateAddress(ApiContext apiContext, com.mozu.api.contracts.customer.AddressValidationRequest addressValidationRequest, int expectedCode) throws Exception
{
return validateAddress(apiContext, addressValidationRequest, null, expectedCode, successCode );
return validateAddress(apiContext, addressValidationRequest, null, expectedCode);
}

public static com.mozu.api.contracts.customer.AddressValidationResponse validateAddress(ApiContext apiContext, com.mozu.api.contracts.customer.AddressValidationRequest addressValidationRequest, String responseFields, int expectedCode, int successCode) throws Exception
public static com.mozu.api.contracts.customer.AddressValidationResponse validateAddress(ApiContext apiContext, com.mozu.api.contracts.customer.AddressValidationRequest addressValidationRequest, String responseFields, int expectedCode) throws Exception
{
com.mozu.api.contracts.customer.AddressValidationResponse returnObj = new com.mozu.api.contracts.customer.AddressValidationResponse();
AddressValidationRequestResource resource = new AddressValidationRequestResource(apiContext);
Expand All @@ -36,12 +37,12 @@ public static com.mozu.api.contracts.customer.AddressValidationResponse validate
catch (ApiException e)
{
if(e.getHttpStatusCode() != expectedCode)
throw new TestFailException(e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), expectedCode, "");
throw new TestFailException("" + e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, "");
else
return null;
}
if(expectedCode != successCode)
throw new TestFailException(successCode, Thread.currentThread().getStackTrace()[2].getMethodName(), expectedCode, "");
if(expectedCode != 304 && !(expectedCode >= 200 && expectedCode <= 300) && !(expectedCode == HttpStatus.SC_NOT_FOUND && returnObj == null))
throw new TestFailException("304 or between 200 and 300", Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, "");
return returnObj;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import java.util.List;
import java.util.ArrayList;
import org.apache.http.HttpStatus;
import com.mozu.api.ApiException;
import com.mozu.api.ApiContext;
import com.mozu.test.framework.core.TestFailException;
Expand All @@ -20,12 +21,12 @@
public class AdjustmentFactory
{

public static com.mozu.api.contracts.commerceruntime.orders.Order applyShippingAdjustment(ApiContext apiContext, com.mozu.api.contracts.commerceruntime.commerce.Adjustment adjustment, String orderId, int expectedCode, int successCode) throws Exception
public static com.mozu.api.contracts.commerceruntime.orders.Order applyShippingAdjustment(ApiContext apiContext, com.mozu.api.contracts.commerceruntime.commerce.Adjustment adjustment, String orderId, int expectedCode) throws Exception
{
return applyShippingAdjustment(apiContext, adjustment, orderId, null, null, null, expectedCode, successCode );
return applyShippingAdjustment(apiContext, adjustment, orderId, null, null, null, expectedCode);
}

public static com.mozu.api.contracts.commerceruntime.orders.Order applyShippingAdjustment(ApiContext apiContext, com.mozu.api.contracts.commerceruntime.commerce.Adjustment adjustment, String orderId, String updateMode, String version, String responseFields, int expectedCode, int successCode) throws Exception
public static com.mozu.api.contracts.commerceruntime.orders.Order applyShippingAdjustment(ApiContext apiContext, com.mozu.api.contracts.commerceruntime.commerce.Adjustment adjustment, String orderId, String updateMode, String version, String responseFields, int expectedCode) throws Exception
{
com.mozu.api.contracts.commerceruntime.orders.Order returnObj = new com.mozu.api.contracts.commerceruntime.orders.Order();
AdjustmentResource resource = new AdjustmentResource(apiContext);
Expand All @@ -36,21 +37,21 @@ public static com.mozu.api.contracts.commerceruntime.orders.Order applyShippingA
catch (ApiException e)
{
if(e.getHttpStatusCode() != expectedCode)
throw new TestFailException(e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), expectedCode, "");
throw new TestFailException("" + e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, "");
else
return null;
}
if(expectedCode != successCode)
throw new TestFailException(successCode, Thread.currentThread().getStackTrace()[2].getMethodName(), expectedCode, "");
if(expectedCode != 304 && !(expectedCode >= 200 && expectedCode <= 300) && !(expectedCode == HttpStatus.SC_NOT_FOUND && returnObj == null))
throw new TestFailException("304 or between 200 and 300", Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, "");
return returnObj;
}

public static com.mozu.api.contracts.commerceruntime.orders.Order applyAdjustment(ApiContext apiContext, com.mozu.api.contracts.commerceruntime.commerce.Adjustment adjustment, String orderId, int expectedCode, int successCode) throws Exception
public static com.mozu.api.contracts.commerceruntime.orders.Order applyAdjustment(ApiContext apiContext, com.mozu.api.contracts.commerceruntime.commerce.Adjustment adjustment, String orderId, int expectedCode) throws Exception
{
return applyAdjustment(apiContext, adjustment, orderId, null, null, null, expectedCode, successCode );
return applyAdjustment(apiContext, adjustment, orderId, null, null, null, expectedCode);
}

public static com.mozu.api.contracts.commerceruntime.orders.Order applyAdjustment(ApiContext apiContext, com.mozu.api.contracts.commerceruntime.commerce.Adjustment adjustment, String orderId, String updateMode, String version, String responseFields, int expectedCode, int successCode) throws Exception
public static com.mozu.api.contracts.commerceruntime.orders.Order applyAdjustment(ApiContext apiContext, com.mozu.api.contracts.commerceruntime.commerce.Adjustment adjustment, String orderId, String updateMode, String version, String responseFields, int expectedCode) throws Exception
{
com.mozu.api.contracts.commerceruntime.orders.Order returnObj = new com.mozu.api.contracts.commerceruntime.orders.Order();
AdjustmentResource resource = new AdjustmentResource(apiContext);
Expand All @@ -61,21 +62,21 @@ public static com.mozu.api.contracts.commerceruntime.orders.Order applyAdjustmen
catch (ApiException e)
{
if(e.getHttpStatusCode() != expectedCode)
throw new TestFailException(e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), expectedCode, "");
throw new TestFailException("" + e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, "");
else
return null;
}
if(expectedCode != successCode)
throw new TestFailException(successCode, Thread.currentThread().getStackTrace()[2].getMethodName(), expectedCode, "");
if(expectedCode != 304 && !(expectedCode >= 200 && expectedCode <= 300) && !(expectedCode == HttpStatus.SC_NOT_FOUND && returnObj == null))
throw new TestFailException("304 or between 200 and 300", Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, "");
return returnObj;
}

public static com.mozu.api.contracts.commerceruntime.orders.Order removeShippingAdjustment(ApiContext apiContext, String orderId, int expectedCode, int successCode) throws Exception
public static com.mozu.api.contracts.commerceruntime.orders.Order removeShippingAdjustment(ApiContext apiContext, String orderId, int expectedCode) throws Exception
{
return removeShippingAdjustment(apiContext, orderId, null, null, expectedCode, successCode );
return removeShippingAdjustment(apiContext, orderId, null, null, expectedCode);
}

public static com.mozu.api.contracts.commerceruntime.orders.Order removeShippingAdjustment(ApiContext apiContext, String orderId, String updateMode, String version, int expectedCode, int successCode) throws Exception
public static com.mozu.api.contracts.commerceruntime.orders.Order removeShippingAdjustment(ApiContext apiContext, String orderId, String updateMode, String version, int expectedCode) throws Exception
{
com.mozu.api.contracts.commerceruntime.orders.Order returnObj = new com.mozu.api.contracts.commerceruntime.orders.Order();
AdjustmentResource resource = new AdjustmentResource(apiContext);
Expand All @@ -86,21 +87,21 @@ public static com.mozu.api.contracts.commerceruntime.orders.Order removeShipping
catch (ApiException e)
{
if(e.getHttpStatusCode() != expectedCode)
throw new TestFailException(e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), expectedCode, "");
throw new TestFailException("" + e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, "");
else
return null;
}
if(expectedCode != successCode)
throw new TestFailException(successCode, Thread.currentThread().getStackTrace()[2].getMethodName(), expectedCode, "");
if(expectedCode != 304 && !(expectedCode >= 200 && expectedCode <= 300) && !(expectedCode == HttpStatus.SC_NOT_FOUND && returnObj == null))
throw new TestFailException("304 or between 200 and 300", Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, "");
return returnObj;
}

public static com.mozu.api.contracts.commerceruntime.orders.Order removeAdjustment(ApiContext apiContext, String orderId, int expectedCode, int successCode) throws Exception
public static com.mozu.api.contracts.commerceruntime.orders.Order removeAdjustment(ApiContext apiContext, String orderId, int expectedCode) throws Exception
{
return removeAdjustment(apiContext, orderId, null, null, expectedCode, successCode );
return removeAdjustment(apiContext, orderId, null, null, expectedCode);
}

public static com.mozu.api.contracts.commerceruntime.orders.Order removeAdjustment(ApiContext apiContext, String orderId, String updateMode, String version, int expectedCode, int successCode) throws Exception
public static com.mozu.api.contracts.commerceruntime.orders.Order removeAdjustment(ApiContext apiContext, String orderId, String updateMode, String version, int expectedCode) throws Exception
{
com.mozu.api.contracts.commerceruntime.orders.Order returnObj = new com.mozu.api.contracts.commerceruntime.orders.Order();
AdjustmentResource resource = new AdjustmentResource(apiContext);
Expand All @@ -111,12 +112,12 @@ public static com.mozu.api.contracts.commerceruntime.orders.Order removeAdjustme
catch (ApiException e)
{
if(e.getHttpStatusCode() != expectedCode)
throw new TestFailException(e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), expectedCode, "");
throw new TestFailException("" + e.getHttpStatusCode(), Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, "");
else
return null;
}
if(expectedCode != successCode)
throw new TestFailException(successCode, Thread.currentThread().getStackTrace()[2].getMethodName(), expectedCode, "");
if(expectedCode != 304 && !(expectedCode >= 200 && expectedCode <= 300) && !(expectedCode == HttpStatus.SC_NOT_FOUND && returnObj == null))
throw new TestFailException("304 or between 200 and 300", Thread.currentThread().getStackTrace()[2].getMethodName(), "" + expectedCode, "");
return returnObj;
}

Expand Down
Loading

0 comments on commit 710aa8a

Please sign in to comment.