Closed ankitjain10 closed 7 years ago
Please provide a failing test case.
void getTotalPayableCappingAmount(final boolean isRemoveClicked, final boolean isAddClicked) {
mIsRemoveClicked = isRemoveClicked;
mIsAddClicked = isAddClicked;
// AlertUtils.showProgressDialog(CartActivity.this, null, "", false);
String inputJsonForCapping = jsonHelper1.createJsonforCapping(cartHelper.getDiscount());
final Call
if (!mIsLoading) {
mIsLoading = true;
amountPayableProgress.setVisibility(View.VISIBLE);
placeOrderButton.setBackgroundColor(getResources().getColor(R.color.colorPrimarywithOpacity));
placeOrderButton.setText("Calculating basket...");
placeOrderButton.setClickable(false);
totalTextView.setVisibility(View.GONE);
cappedAmountCall.enqueue(new Callback<String>() {
@Override
public void onResponse(Call<String> call, Response<String> response) {
mIsLoading = false;
if (!isRemoveClicked) {
mIsRemoveClicked = true;
}
if (!isAddClicked) {
mIsAddClicked = true;
}
if (mIsAddClicked && mIsRemoveClicked) {
if (!response.isSuccessful()) {
ToastUtils.showShortToastSafe(CartActivity.this, "on success fail");
return;
}
if (response.body() != null) {
ToastUtils.showShortToastSafe(CartActivity.this, "on success body");
double totalAmountFromResponse = jsonHelper1.getTotalCappedFromResponse(response.body());
amountPayableProgress.setVisibility(View.GONE);
totalTextView.setVisibility(View.VISIBLE);
totalTextView.setText("₹ " + (int) totalAmountFromResponse);
cartHelper.setUserAmountPayable(totalAmountFromResponse);
placeOrderButton.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
placeOrderButton.setClickable(true);
placeOrderButton.setText("Confirm Order");
totalStaticTextView.setText("Total :");
CartHelper2 cartHelper2 = new CartHelper2();
checkMinOrderAmount(cartHelper2.getCustomerPayableCappedwithoutDisAndDeliveryCharges());
taxesAndCapping.setText("₹ " + String.format("%.2f", cartHelper.getTaxesfromRevalue()));
taxesAndCapping.setVisibility(View.VISIBLE);
taxesAndAdjustmentTextView.setVisibility(View.VISIBLE);
Log.d("subTotal", "getTaxesfromRevalue" + cartHelper.getTaxesfromRevalue());
} else {
ToastUtils.showShortToastSafe(CartActivity.this, "on success body null");
}
}
}
@Override
public void onFailure(Call<String> call, Throwable t) {
if (call.isCanceled()) {
ToastUtils.showShortToastSafe(CartActivity.this, "on cancel request");
getTotalPayableCappingAmount(isRemoveClicked, isAddClicked);
} else {
ToastUtils.showShortToastSafe(CartActivity.this, "on fail");
mIsLoading = false;
mIsRemoveClicked = true;
mIsAddClicked = true;
amountPayableProgress.setVisibility(View.GONE);
totalTextView.setVisibility(View.VISIBLE);
placeOrderButton.setClickable(true);
placeOrderButton.setText("Confirm Order");
placeOrderButton.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
totalTextView.setText("₹ " + (cartHelper.getTotalCustomerPayable() - cartHelper.getDiscount()));
cartHelper.setUserAmountPayable((int) (cartHelper.getTotalCustomerPayable() - cartHelper.getDiscount()));
totalStaticTextView.setText("Total :");
checkMinOrderAmount(cartHelper.getTotalCustomerPayable() + cartHelper.getDiscount());
taxesAndCapping.setVisibility(View.INVISIBLE);
taxesAndAdjustmentTextView.setVisibility(View.INVISIBLE);
}
}
});
} else {
if (cappedAmountCall != null && !cappedAmountCall.isExecuted()) {
mIsLoading = false;
cappedAmountCall.cancel();
}
}
}
What kind of issue is this?
[ ] Question. This issue tracker is not the place for questions. If you want to ask how to do something, or to understand why something isn't working the way you expect it to, use Stack Overflow. https://stackoverflow.com/questions/tagged/retrofit
[ ] Bug report. If you’ve found a bug, spend the time to write a failing test. Bugs with tests get fixed. Here’s an example: https://gist.github.com/swankjesse/6608b4713ad80988cdc9
[ ] Feature Request. Start by telling us what problem you’re trying to solve. Often a solution already exists! Don’t send pull requests to implement new features without first getting our support. Sometimes we leave features out on purpose to keep the project small.