Skip to content

Unit Test and Enhancements #297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Jun 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
40f7d9b
Implemented Parcelable in IntresestType in commom and SearchEntityin …
therajanmaurya Jun 18, 2016
16a3221
search query result json added
therajanmaurya Jun 18, 2016
fcfbe7d
ClientSearchFragmentTest Done !
therajanmaurya Jun 18, 2016
d8ac4df
center.json added
therajanmaurya Jun 18, 2016
cab1f71
MifosBaseProgressBar Added dynamically clientListfragment enhance
therajanmaurya Jun 19, 2016
fcb9258
ClientListFragment Enhance and ClientListPresenterTest Passing
therajanmaurya Jun 19, 2016
e9ce213
CenterListFragment ListView -> RecyclerView
therajanmaurya Jun 19, 2016
a1ed97d
Pagination Added in Center API and LoadMore implemented and SwipeRefr…
therajanmaurya Jun 19, 2016
1907912
Center Load failed error handled !
therajanmaurya Jun 19, 2016
c535c17
Documentation of the CenterListFragment
therajanmaurya Jun 19, 2016
b055c77
Center, Status, TimeLine implemeted Parcelable
therajanmaurya Jun 19, 2016
ba15d43
FakeData Setup done
therajanmaurya Jun 19, 2016
ae011a5
CenterListPresenterTest Done !
therajanmaurya Jun 19, 2016
ea3a3b6
All check Passing
therajanmaurya Jun 19, 2016
b3f86bf
ClientChargeFragment and LoanChargeFragment Clean up and Enhancements
therajanmaurya Jun 20, 2016
309a2f0
removed unused code
therajanmaurya Jun 20, 2016
508a704
ClientChargesPresenter Unit Test Done !
therajanmaurya Jun 20, 2016
c79e788
ClientChargesPresenter Test and json
therajanmaurya Jun 20, 2016
53da84f
LoanChargePresenterTest done !
therajanmaurya Jun 20, 2016
ba94f33
DocumentListFragments Enhancements done !
therajanmaurya Jun 21, 2016
ffeb5de
DocumentsListPresenterTest done and Enhancements
therajanmaurya Jun 21, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@
public class FakeJsonName {

public static final String CLIENTS_JSON = "clients.json";
public static final String SEARCHED_ENTITY_JSON = "searchedEntity.json";
public static final String CENTERS_JSON = "centers.json";
public static final String CENTER_WITH_ASSOCIATIONS_JSON = "centerWithAssociations.json";
public static final String CHARGES_JSON = "charges.json";
public static final String LOAN_CHARGES_JSON = "loancharges.json";
public static final String DOCUMENTS_JSON = "documents.json";
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package com.mifos.mifosxdroid;

import com.mifos.objects.client.Client;
import com.google.gson.reflect.TypeToken;
import com.mifos.objects.SearchedEntity;
import com.mifos.objects.client.Charges;
import com.mifos.objects.client.Page;
import com.mifos.objects.group.Center;
import com.mifos.objects.group.CenterWithAssociations;
import com.mifos.objects.noncore.Document;

import java.util.List;

/**
* Created by Rajan Maurya on 18/6/16.
Expand All @@ -11,8 +18,38 @@ public class FakeRemoteDataSource {
private static TestDataFactory mTestDataFactory = new TestDataFactory();


public static Page<Client> getClientList() {
public static Page getClientList() {
return mTestDataFactory.getObjectTypePojo(Page.class, FakeJsonName.CLIENTS_JSON);
}

public static List<SearchedEntity> getSearchedEntity() {
return mTestDataFactory.getListTypePojo(new TypeToken<List<SearchedEntity>>() {
}, FakeJsonName.SEARCHED_ENTITY_JSON);
}

public static Page<Center> getCenters() {
return mTestDataFactory.getListTypePojo(new TypeToken<Page<Center>>() {
}, FakeJsonName.CENTERS_JSON);
}

public static CenterWithAssociations getCentersGroupAndMeeting() {
return mTestDataFactory.getObjectTypePojo(CenterWithAssociations.class,
FakeJsonName.CENTER_WITH_ASSOCIATIONS_JSON);
}

public static Page<Charges> getClientCharges() {
return mTestDataFactory.getListTypePojo(new TypeToken<Page<Charges>>() {
}, FakeJsonName.CHARGES_JSON);
}

public static List<Charges> getLoanCharges() {
return mTestDataFactory.getListTypePojo(new TypeToken<List<Charges>>() {
}, FakeJsonName.LOAN_CHARGES_JSON);
}

public static List<Document> getDouments() {
return mTestDataFactory.getListTypePojo(new TypeToken<List<Document>>() {
}, FakeJsonName.DOCUMENTS_JSON);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,19 @@ public class TestDataFactory {


/**
*
* Note : This Generic Method DeSerialize Only Json Object in POJO
*
* <p/>
* Note : Do Not use Array [] in POJO classes for of any element initialization,
* Use Instead ArrayList.
* Use Instead ArrayList.
*
* @param model Class of the Model of the Pojo
* @param model Class of the Model of the Pojo
* @param jsonName Name of Json file in test/resource
* @param <T> Return type
* @param <T> Return type
* @return Return the Object Type model by Deserializing the Json of resources
*
* @Example Of Deserializing Object Type Json
*
* <p/>
* Object object = mTestDataFactory.getListTypePojo(
* new TypeToken<Object>(){}, "Object.json")
*
* new TypeToken<Object>(){}, "Object.json")
*/
public <T> T getObjectTypePojo(Class<T> model, String jsonName) {

Expand All @@ -43,30 +40,25 @@ public <T> T getObjectTypePojo(Class<T> model, String jsonName) {


/**
*
* Note : This Generic Method DeSerialize Both Object and List Type Json in POJO
*
* <p/>
* Note : Do Not use Array [] in POJO classes for of any element initialization,
* Use Instead ArrayList.
* Use Instead ArrayList.
*
* @param listModel Class of the List Model
* @param jsonName Name of the Json in resources
* @param <T> return type
* @param jsonName Name of the Json in resources
* @param <T> return type
* @return Return the List of the listModel by Deserializing the Json of resources
*
* @Example of Deserializing List Type Json
*
* @Example of Deserializing List Type Json
* <p/>
* TestDataFactory mTestDataFactory = new TestDataFactory();
*
* <p/>
* List<Object> listObject = mTestDataFactory.getListTypePojo(
* new TypeToken<List<Object>>(){}, "ListObject.json")
*
* new TypeToken<List<Object>>(){}, "ListObject.json")
* @Example Of Deserializing Object Type Json
*
* <p/>
* Object object = mTestDataFactory.getListTypePojo(
* new TypeToken<Object>(){}, "Object.json")
*
*
* new TypeToken<Object>(){}, "Object.json")
*/
public <T> T getListTypePojo(TypeToken<T> listModel, String jsonName) {

Expand Down
12 changes: 6 additions & 6 deletions mifosng-android/src/main/java/com/mifos/api/DataManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ public Observable<User> login(String username, String password) {
/**
* Center API
*/
//Return Centers List
public Observable<List<Center>> getCenters() {
return mBaseApiManager.getCenterApi().getAllCenters();
//Return Centers List according to offset and limit parameter
public Observable<Page<Center>> getCenters(boolean b, int offset, int limit) {
return mBaseApiManager.getCenterApi().getCenters(b, offset, limit);
}

//Return Center With Association
Expand Down Expand Up @@ -137,8 +137,8 @@ public Observable<List<OfflineCenter>> getCenterList(
/**
* Charges API
*/
public Observable<Page<Charges>> getClientCharges(int id) {
return mBaseApiManager.getChargeApi().getListOfCharges(id);
public Observable<Page<Charges>> getClientCharges(int clientId, int offset, int limit) {
return mBaseApiManager.getChargeApi().getListOfCharges(clientId, offset, limit);
}

public Observable<ResponseBody> getAllChargesV2(int clientId) {
Expand Down Expand Up @@ -359,7 +359,7 @@ public Observable<GenericResponse> dispurseLoan(int loanId,
return mBaseApiManager.getLoanApi().disburseLoan(loanId, loanDisbursement);
}

public Observable<Page<Charges>> getListOfLoanCharges(int loanId) {
public Observable<List<Charges>> getListOfLoanCharges(int loanId) {
return mBaseApiManager.getLoanApi().getListOfLoanCharges(loanId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.mifos.api.model.CollectionSheetPayload;
import com.mifos.api.model.Payload;
import com.mifos.api.model.SaveResponse;
import com.mifos.objects.client.Page;
import com.mifos.objects.db.CollectionSheet;
import com.mifos.objects.db.OfflineCenter;
import com.mifos.objects.group.Center;
Expand All @@ -32,7 +33,9 @@ public interface CenterService {


@GET(APIEndPoint.CENTERS)
Observable<List<Center>> getAllCenters();
Observable<Page<Center>> getCenters(@Query("paged") boolean b,
@Query("offset") int offset,
@Query("limit") int limit);

@GET(APIEndPoint.CENTERS + "/{centerId}?associations=groupMembers,collectionMeetingCalendar")
Observable<CenterWithAssociations> getCenterWithGroupMembersAndCollectionMeetingCalendar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;
import rx.Observable;

/**
Expand All @@ -31,7 +32,9 @@ public interface ChargeService {
Observable<ResponseBody> getAllChargev3(@Path("loanId") int loanId);

@GET(APIEndPoint.CLIENTS + "/{clientId}/charges")
Observable<Page<Charges>> getListOfCharges(@Path("clientId") int clientId);
Observable<Page<Charges>> getListOfCharges(@Path("clientId") int clientId,
@Query("offset") int offset,
@Query("limit") int limit);

@POST(APIEndPoint.CLIENTS + "/{clientId}/charges")
Observable<Charges> createCharges(@Path("clientId") int clientId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Observable<ResponseBody> getGroupLoansAccountTemplate(@Query("groupId") int grou
@Query("productId") int productId);

@GET(APIEndPoint.LOANS + "/{loanId}/" + APIEndPoint.CHARGES)
Observable<Page<Charges>> getListOfLoanCharges(@Path("loanId") int loanId);
Observable<List<Charges>> getListOfLoanCharges(@Path("loanId") int loanId);


@GET(APIEndPoint.CLIENTS + "/{clientId}/" + APIEndPoint.CHARGES)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@

import android.content.Context;
import android.content.res.Resources;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.mifos.mifosxdroid.R;
import com.mifos.objects.group.Center;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
* Created by ishankhanna on 11/03/14.
*/
public class CentersListAdapter extends BaseAdapter {
public class CentersListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

private LayoutInflater layoutInflater;
private List<Center> centers;
Expand All @@ -35,64 +38,74 @@ public CentersListAdapter(Context context, List<Center> centers) {

}

@Override
public int getCount() {
return this.centers.size();
}

@Override
public Center getItem(int i) {
return this.centers.get(i);
}

@Override
public long getItemId(int i) {
return 0;
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
RecyclerView.ViewHolder vh;
View v = LayoutInflater.from(parent.getContext()).inflate(
R.layout.row_center_list_item, parent, false);
vh = new ViewHolder(v);
return vh;
}

@Override
public View getView(int i, View view, ViewGroup viewGroup) {
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder instanceof ViewHolder) {

ViewHolder viewHolder;
((ViewHolder) holder).tv_center_id.setText(resources
.getString(R.string.center_id) + centers.get(position).getId());

if (view == null) {
view = layoutInflater.inflate(R.layout.row_center_list_item, viewGroup, false);
viewHolder = new ViewHolder();
view.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) view.getTag();
}
((ViewHolder) holder).tv_center_name.setText(centers.get(position).getName());

viewHolder.tv_center_id = (TextView) view.findViewById(R.id.tv_center_id);
viewHolder.tv_center_name = (TextView) view.findViewById(R.id.tv_center_name);
viewHolder.tv_staff_id = (TextView) view.findViewById(R.id.tv_staff_id);
viewHolder.tv_staff_name = (TextView) view.findViewById(R.id.tv_staff_name);
viewHolder.tv_office_id = (TextView) view.findViewById(R.id.tv_office_id);
viewHolder.tv_office_name = (TextView) view.findViewById(R.id.tv_office_name);
((ViewHolder) holder).tv_staff_id.setText(
resources.getString(R.string.staff_id) + centers.get(position).getStaffId());

viewHolder.tv_center_id.setText(resources.getString(R.string.center_id) + centers.get(i)
.getId());
viewHolder.tv_center_name.setText(centers.get(i).getName());
((ViewHolder) holder).tv_staff_name.setText(centers.get(position).getStaffName());

viewHolder.tv_staff_id.setText(resources.getString(R.string.staff_id) + centers.get(i)
.getStaffId());
viewHolder.tv_staff_name.setText(centers.get(i).getStaffName());
((ViewHolder) holder).tv_office_id.setText(
resources.getString(R.string.office_id) + centers.get(position).getOfficeId());

viewHolder.tv_office_id.setText(resources.getString(R.string.office_id) + centers.get(i)
.getOfficeId());
viewHolder.tv_office_name.setText(centers.get(i).getOfficeName());
((ViewHolder) holder).tv_office_name.setText(centers.get(position).getOfficeName());
}
}

return view;
@Override
public long getItemId(int i) {
return 0;
}

@Override
public int getItemCount() {
return centers.size();
}

public static class ViewHolder {

public static class ViewHolder extends RecyclerView.ViewHolder {

@BindView(R.id.tv_center_name)
TextView tv_center_name;

@BindView(R.id.tv_center_id)
TextView tv_center_id;

@BindView(R.id.tv_staff_name)
TextView tv_staff_name;

@BindView(R.id.tv_staff_id)
TextView tv_staff_id;

@BindView(R.id.tv_office_name)
TextView tv_office_name;

@BindView(R.id.tv_office_id)
TextView tv_office_id;

public ViewHolder(View v) {
super(v);
ButterKnife.bind(this, v);
}
}
}
Loading