Skip to content

Commit 033d686

Browse files
committed
- fix merge conflicts
2 parents dd7df20 + 9977b09 commit 033d686

File tree

8 files changed

+519
-54
lines changed

8 files changed

+519
-54
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.flutterwave.raveandroid.validators;
2+
3+
import com.flutterwave.raveandroid.RaveConstants;
4+
5+
import javax.inject.Inject;
6+
7+
public class NetworkValidator {
8+
9+
@Inject
10+
public NetworkValidator() {
11+
}
12+
13+
public boolean isNetworkValid(String network) {
14+
return network != null && network.equalsIgnoreCase(RaveConstants.mtn) && !network.isEmpty();
15+
}
16+
}

raveandroid/src/main/java/com/flutterwave/raveandroid/zmmobilemoney/ZmMobileMoneyFragment.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ public class ZmMobileMoneyFragment extends Fragment implements ZmMobileMoneyCont
5353
private TextInputLayout amountTil;
5454
private TextInputEditText phoneEt;
5555
private TextInputEditText amountEt;
56-
private TextInputLayout voucherTil;
57-
private TextInputEditText voucherEt;
5856
private ProgressDialog progressDialog;
5957
private ProgressDialog pollingProgressDialog;
6058

@@ -105,8 +103,6 @@ private void setListeners() {
105103
private void initializeViews() {
106104
networkSpinner = v.findViewById(R.id.rave_networkSpinner);
107105
instructionsTv = v.findViewById(R.id.instructionsTv);
108-
voucherTil = v.findViewById(R.id.rave_voucherTil);
109-
voucherEt = v.findViewById(R.id.rave_voucherEt);
110106
payButton = v.findViewById(R.id.rave_payButton);
111107
amountTil = v.findViewById(R.id.rave_amountTil);
112108
phoneTil = v.findViewById(R.id.rave_phoneTil);
@@ -134,13 +130,6 @@ public void onItemSelected(AdapterView<?> parent, View view, int position, long
134130
if (network.equalsIgnoreCase(RaveConstants.mtn)) {
135131
validateInstructions = getResources().getString(R.string.mtn_validate_instructions);
136132
showInstructionsAndVoucher(false);
137-
} else if (network.equalsIgnoreCase(RaveConstants.tigo)) {
138-
validateInstructions = getResources().getString(R.string.tigo_validate_instructions);
139-
showInstructionsAndVoucher(false);
140-
} else if (network.equalsIgnoreCase(RaveConstants.vodafone)) {
141-
validateInstructions = getResources().getString(R.string.checkStatus);
142-
showInstructionsAndVoucher(true);
143-
instructionsTv.setText(Html.fromHtml(getResources().getString(R.string.vodafone_msg)));
144133
}
145134
}
146135
}
@@ -164,7 +153,6 @@ public void onClick(View view) {
164153
private void clearErrors() {
165154
amountTil.setError(null);
166155
phoneTil.setError(null);
167-
voucherTil.setError(null);
168156
}
169157

170158
private void collectData() {
@@ -175,10 +163,6 @@ private void collectData() {
175163
dataHashMap.put(RaveConstants.fieldPhone, new ViewObject(phoneTil.getId(), phoneEt.getText().toString(), TextInputLayout.class));
176164
dataHashMap.put(RaveConstants.fieldNetwork, new ViewObject(networkSpinner.getId(), String.valueOf(networkSpinner.getSelectedItem()), Spinner.class));
177165

178-
if (voucherTil.getVisibility() == View.VISIBLE) {
179-
dataHashMap.put(RaveConstants.fieldVoucher, new ViewObject(voucherTil.getId(), voucherEt.getText().toString(), TextInputLayout.class));
180-
}
181-
182166
presenter.onDataCollected(dataHashMap);
183167
}
184168

@@ -205,10 +189,8 @@ public void onAmountValidationSuccessful(String amountToPay) {
205189
private void showInstructionsAndVoucher(boolean show) {
206190

207191
if (show) {
208-
voucherTil.setVisibility(View.VISIBLE);
209192
instructionsTv.setVisibility(View.VISIBLE);
210193
} else {
211-
voucherTil.setVisibility(View.GONE);
212194
instructionsTv.setVisibility(View.GONE);
213195
}
214196
}

raveandroid/src/main/java/com/flutterwave/raveandroid/zmmobilemoney/ZmMobileMoneyPresenter.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.flutterwave.raveandroid.responses.MobileMoneyChargeResponse;
2020
import com.flutterwave.raveandroid.responses.RequeryResponse;
2121
import com.flutterwave.raveandroid.validators.AmountValidator;
22+
import com.flutterwave.raveandroid.validators.NetworkValidator;
2223
import com.flutterwave.raveandroid.validators.PhoneValidator;
2324

2425
import java.util.HashMap;
@@ -35,7 +36,6 @@
3536
import static com.flutterwave.raveandroid.RaveConstants.validAmountPrompt;
3637
import static com.flutterwave.raveandroid.RaveConstants.validNetworkPrompt;
3738
import static com.flutterwave.raveandroid.RaveConstants.validPhonePrompt;
38-
import static com.flutterwave.raveandroid.RaveConstants.validVoucherPrompt;
3939

4040
/**
4141
* Created by hfetuga on 28/06/2018.
@@ -49,6 +49,8 @@ public class ZmMobileMoneyPresenter implements ZmMobileMoneyContract.UserActions
4949
@Inject
5050
PhoneValidator phoneValidator;
5151
@Inject
52+
NetworkValidator networkValidator;
53+
@Inject
5254
DeviceIdGetter deviceIdGetter;
5355
private Context context;
5456
private ZmMobileMoneyContract.View mView;
@@ -217,24 +219,11 @@ public void onDataCollected(HashMap<String, ViewObject> dataHashMap) {
217219
String phone = dataHashMap.get(fieldPhone).getData();
218220
Class phoneViewType = dataHashMap.get(fieldPhone).getViewType();
219221

220-
ViewObject voucherViewObject = dataHashMap.get(fieldVoucher);
221-
222-
if (voucherViewObject != null) {
223-
int voucherID = dataHashMap.get(fieldVoucher).getViewId();
224-
String voucher = dataHashMap.get(fieldVoucher).getData();
225-
Class voucherViewType = dataHashMap.get(fieldVoucher).getViewType();
226-
227-
if (voucher.isEmpty()) {
228-
valid = false;
229-
mView.showFieldError(voucherID, validVoucherPrompt, voucherViewType);
230-
}
231-
232-
}
233-
234222
String network = dataHashMap.get(fieldNetwork).getData();
235223

236224
boolean isAmountValidated = amountValidator.isAmountValid(amount);
237225
boolean isPhoneValid = phoneValidator.isPhoneValid(phone);
226+
boolean isNetworkValid = networkValidator.isNetworkValid(network);
238227

239228
if (!isAmountValidated) {
240229
valid = false;
@@ -246,7 +235,7 @@ public void onDataCollected(HashMap<String, ViewObject> dataHashMap) {
246235
mView.showFieldError(phoneID, validPhonePrompt, phoneViewType);
247236
}
248237

249-
if (network.equals(RaveConstants.selectNetwork)) {
238+
if (!isNetworkValid) {
250239
valid = false;
251240
mView.showToast(validNetworkPrompt);
252241
}

raveandroid/src/main/res/layout/fragment_zm_mobile_money.xml

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
android:descendantFocusability="beforeDescendants"
77
android:focusableInTouchMode="true"
88
android:orientation="vertical"
9-
tools:context="com.flutterwave.raveandroid.zmmobilemoney.ZmMobileMoneyFragment">
9+
tools:context="com.flutterwave.raveandroid.ghmobilemoney.GhMobileMoneyFragment">
1010

1111
<ScrollView
1212
android:layout_width="match_parent"
@@ -63,33 +63,16 @@
6363

6464
</android.support.design.widget.TextInputLayout>
6565

66-
<android.support.design.widget.TextInputLayout
67-
android:id="@+id/rave_voucherTil"
68-
android:layout_width="match_parent"
69-
android:layout_height="wrap_content"
70-
android:layout_marginBottom="20dp">
71-
72-
<android.support.design.widget.TextInputEditText
73-
android:id="@+id/rave_voucherEt"
74-
android:layout_width="match_parent"
75-
android:layout_height="wrap_content"
76-
android:layout_below="@+id/rave_card1"
77-
android:hint="Voucher"
78-
android:inputType="text" />
79-
80-
</android.support.design.widget.TextInputLayout>
81-
82-
8366
<android.support.design.widget.TextInputLayout
8467
android:id="@+id/rave_amountTil"
8568
android:layout_width="match_parent"
8669
android:layout_height="wrap_content"
8770
android:layout_marginBottom="10dp">
8871

8972
<android.support.design.widget.TextInputEditText
90-
android:id="@+id/rave_amountTV"
9173
android:layout_width="match_parent"
9274
android:layout_height="wrap_content"
75+
android:id="@+id/rave_amountTV"
9376
android:layout_below="@+id/rave_card1"
9477
android:hint="@string/amount"
9578
android:inputType="numberDecimal" />

raveandroid/src/test/java/com/flutterwave/raveandroid/di/TestAndroidModule.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.flutterwave.raveandroid.validators.CvvValidator;
2121
import com.flutterwave.raveandroid.validators.DateOfBirthValidator;
2222
import com.flutterwave.raveandroid.validators.EmailValidator;
23+
import com.flutterwave.raveandroid.validators.NetworkValidator;
2324
import com.flutterwave.raveandroid.validators.PhoneValidator;
2425
import com.flutterwave.raveandroid.validators.UrlValidator;
2526

@@ -63,13 +64,18 @@ public EmailValidator providesEmailValidator() {
6364
return Mockito.mock(EmailValidator.class);
6465
}
6566

66-
6767
@Provides
6868
@Singleton
6969
public PhoneValidator providesPhoneValidator() {
7070
return Mockito.mock(PhoneValidator.class);
7171
}
7272

73+
@Provides
74+
@Singleton
75+
public NetworkValidator providesNetworkValidator() {
76+
return Mockito.mock(NetworkValidator.class);
77+
}
78+
7379

7480
@Provides
7581
@Singleton

raveandroid/src/test/java/com/flutterwave/raveandroid/di/TestAppComponent.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import com.flutterwave.raveandroid.rwfmobilemoney.RwfMobileMoneyPresenterTest;
1919
import com.flutterwave.raveandroid.ugmobilemoney.UgMobileMoneyPresenter;
2020
import com.flutterwave.raveandroid.ugmobilemoney.UgMobileMoneyPresenterTest;
21+
import com.flutterwave.raveandroid.zmmobilemoney.ZmMobileMoneyPresenter;
22+
import com.flutterwave.raveandroid.zmmobilemoney.ZmMobileMoneyPresenterTest;
2123

2224
import javax.inject.Singleton;
2325

@@ -41,6 +43,8 @@ public interface TestAppComponent extends AppComponent {
4143

4244
void inject(RwfMobileMoneyPresenterTest rwfMobileMoneyPresenterTest);
4345

46+
void inject(ZmMobileMoneyPresenterTest zmMobileMoneyPresenterTest);
47+
4448
void inject(TransactionStatusCheckerTest transactionStatusCheckerTest);
4549

4650
void inject(AchPresenterTest achPresenterTest);
@@ -61,4 +65,6 @@ public interface TestAppComponent extends AppComponent {
6165

6266
void inject(RwfMobileMoneyPresenter rwfMobileMoneyPresenter);
6367

68+
void inject(ZmMobileMoneyPresenter zmMobileMoneyPresenter);
69+
6470
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.flutterwave.raveandroid.validators;
2+
3+
import org.junit.Before;
4+
import org.junit.Test;
5+
6+
import static org.hamcrest.CoreMatchers.is;
7+
import static org.junit.Assert.assertThat;
8+
9+
public class NetworkValidatorTest {
10+
11+
NetworkValidator SUT;
12+
13+
@Before
14+
public void setUp() throws Exception {
15+
SUT = new NetworkValidator();
16+
}
17+
18+
@Test
19+
public void isNetworkValid_isCorrectNetworkPassed_returnTrue() {
20+
String network = "mtn";
21+
boolean isNetworkValid = SUT.isNetworkValid(network);
22+
assertThat(true, is(isNetworkValid));
23+
}
24+
25+
@Test
26+
public void isNetworkInValid_isEmptyPassed_returnFalse() {
27+
String network = "";
28+
boolean isNetworkValid = SUT.isNetworkValid(network);
29+
assertThat(false, is(isNetworkValid));
30+
}
31+
32+
@Test
33+
public void isNetworkInValid_isNoNetworkPassed_returnFalse() {
34+
String network = "Select network";
35+
boolean isNetworkValid = SUT.isNetworkValid(network);
36+
assertThat(false, is(isNetworkValid));
37+
}
38+
39+
}

0 commit comments

Comments
 (0)