Skip to content

Commit

Permalink
Add missing realmId, realmSyncStartDate, end date and status
Browse files Browse the repository at this point in the history
  • Loading branch information
arturdm committed May 26, 2020
1 parent dd8f6ee commit 7d8a260
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,31 @@ object MenigaSyncApiTest : Spek({
it("should return a proper object") {
val sync = task.result
assertThat(sync.numNewTransactions).isEqualTo(230)
val realmSyncResponse = sync.realmSyncResponses!![0]
assertThat(realmSyncResponse.accountSyncStatuses).hasSize(1)
realmSyncResponse.accountSyncStatuses[0].run {
assertThat(accountId).isEqualTo(15567)
assertThat(balance).isEqualTo(MenigaDecimal(50000))
assertThat(limit).isEqualTo(MenigaDecimal(2000))
assertThat(transactionsProcessed).isEqualTo(230)
assertThat(totalTransactions).isEqualTo(5180)
assertThat(startDate).isEqualTo(DateTime.parse("2017-07-27T12:23:34.000Z"))
assertThat(endDate).isEqualTo(DateTime.parse("2017-07-27T12:23:34.000Z"))
assertThat(accountStatus).isEqualTo("Success")
assertThat(status).isEqualTo(AccountSyncResult.SUCCESS)
sync.realmSyncResponses!![0].run {
assertThat(realmCredentialsId).isEqualTo(1550004040444)
assertThat(realmCredentialsDisplayName).isEqualTo("string")
assertThat(organizationId).isEqualTo(144)
assertThat(organizationName).isEqualTo("ExampleBank")
assertThat(organizationBankCode).isEqualTo("EB")
assertThat(accountSyncStatuses).hasSize(1)
accountSyncStatuses[0].run {
assertThat(accountId).isEqualTo(15567)
assertThat(balance).isEqualTo(MenigaDecimal(50000))
assertThat(limit).isEqualTo(MenigaDecimal(2000))
assertThat(transactionsProcessed).isEqualTo(230)
assertThat(totalTransactions).isEqualTo(5180)
assertThat(startDate).isEqualTo(DateTime.parse("2017-07-27T12:23:34.000Z"))
assertThat(endDate).isEqualTo(DateTime.parse("2017-07-27T12:23:34.000Z"))
assertThat(accountStatus).isEqualTo("Success")
assertThat(status).isEqualTo(AccountSyncResult.SUCCESS)
}
assertThat(authenticationChallenge.contentType).isEqualTo(ChallengeContentType.TEXT)
assertThat(isSyncDone).isTrue()
assertThat(realmId).isEqualTo(4)
assertThat(realmSyncStartDate).isEqualTo(DateTime.parse("2020-03-12T15:17:51.000Z"))
assertThat(realmSyncEndDate).isEqualTo(DateTime.parse("2020-03-13T15:17:51.000Z"))
assertThat(status).isEqualTo(RealmSyncResult.SUCCESS)
}
assertThat(realmSyncResponse.authenticationChallenge.contentType).isEqualTo(ChallengeContentType.TEXT)
assertThat(realmSyncResponse.isSyncDone).isTrue()
assertThat(realmSyncResponse.organizationBankCode).isEqualTo("EB")
assertThat(realmSyncResponse.organizationId).isEqualTo(144)
assertThat(realmSyncResponse.organizationName).isEqualTo("ExampleBank")
assertThat(realmSyncResponse.realmCredentialsDisplayName).isEqualTo("string")
}

it("should validate against the spec") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,22 @@ import com.google.gson.annotations.SerializedName
enum class AccountSyncResult {
@SerializedName("Success")
SUCCESS,

@SerializedName("ConsentNotFound")
CONSENT_NOT_FOUND,

@SerializedName("AccountNotFound")
ACCOUNT_NOT_FOUND,

@SerializedName("TooManyRequests")
TOO_MANY_REQUESTS,

@SerializedName("ProviderNotFound")
PROVIDER_NOT_FOUND,

@SerializedName("ProviderDisabled")
PROVIDER_DISABLED,

@SerializedName("SyncFailed")
SYNC_FAILED,
}
98 changes: 67 additions & 31 deletions sdk/src/main/java/com/meniga/sdk/models/sync/RealmSyncResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import com.meniga.sdk.models.user.AuthenticationChallenge;

import org.joda.time.DateTime;

import java.io.Serializable;
import java.util.List;

Expand All @@ -19,9 +21,13 @@ public class RealmSyncResponse implements Serializable, Parcelable {
protected long organizationId;
protected String organizationName;
protected String organizationBankCode;
protected boolean isSyncDone;
protected List<AccountSyncStatus> accountSyncStatuses;
protected AuthenticationChallenge authenticationChallenge;
protected boolean isSyncDone;
protected long realmId;
protected DateTime realmSyncStartDate;
protected DateTime realmSyncEndDate;
protected RealmSyncResult status;

protected RealmSyncResponse() {
}
Expand All @@ -32,9 +38,14 @@ protected RealmSyncResponse(Parcel in) {
this.organizationId = in.readLong();
this.organizationName = in.readString();
this.organizationBankCode = in.readString();
this.isSyncDone = in.readByte() != 0;
this.accountSyncStatuses = in.createTypedArrayList(AccountSyncStatus.CREATOR);
this.authenticationChallenge = in.readParcelable(AuthenticationChallenge.class.getClassLoader());
this.isSyncDone = in.readByte() != 0;
this.realmId = in.readLong();
this.realmSyncStartDate = (DateTime) in.readSerializable();
this.realmSyncEndDate = (DateTime) in.readSerializable();
int tmpStatus = in.readInt();
this.status = tmpStatus == -1 ? null : RealmSyncResult.values()[tmpStatus];
}

@Override
Expand All @@ -49,12 +60,17 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(this.organizationId);
dest.writeString(this.organizationName);
dest.writeString(this.organizationBankCode);
dest.writeByte(this.isSyncDone ? (byte) 1 : (byte) 0);
dest.writeTypedList(this.accountSyncStatuses);
dest.writeParcelable(this.authenticationChallenge, flags);
dest.writeByte(this.isSyncDone ? (byte) 1 : (byte) 0);
dest.writeLong(this.realmId);
dest.writeSerializable(this.realmSyncStartDate);
dest.writeSerializable(this.realmSyncEndDate);
dest.writeInt(this.status == null ? -1 : this.status.ordinal());
}

public static final Parcelable.Creator<RealmSyncResponse> CREATOR = new Parcelable.Creator<RealmSyncResponse>() {

public static final Creator<RealmSyncResponse> CREATOR = new Creator<RealmSyncResponse>() {
@Override
public RealmSyncResponse createFromParcel(Parcel source) {
return new RealmSyncResponse(source);
Expand Down Expand Up @@ -98,39 +114,55 @@ public AuthenticationChallenge getAuthenticationChallenge() {
return authenticationChallenge;
}

/**
* @return Id of the Realm
*/
public long getRealmId() {
return realmId;
}

/**
* @return The start time of the synchronization
*/
public DateTime getRealmSyncStartDate() {
return realmSyncStartDate;
}

/**
* @return The end time of the synchronization
*/
public DateTime getRealmSyncEndDate() {
return realmSyncEndDate;
}

/**
* @return The status of the synchronization
*/
public RealmSyncResult getStatus() {
return status;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

RealmSyncResponse that = (RealmSyncResponse) o;

if (realmCredentialsId != that.realmCredentialsId) {
return false;
}
if (organizationId != that.organizationId) {
return false;
}
if (isSyncDone != that.isSyncDone) {
return false;
}
if (realmCredentialsDisplayName != null ? !realmCredentialsDisplayName.equals(that.realmCredentialsDisplayName) : that.realmCredentialsDisplayName != null) {
if (realmCredentialsId != that.realmCredentialsId) return false;
if (organizationId != that.organizationId) return false;
if (isSyncDone != that.isSyncDone) return false;
if (realmId != that.realmId) return false;
if (realmCredentialsDisplayName != null ? !realmCredentialsDisplayName.equals(that.realmCredentialsDisplayName) : that.realmCredentialsDisplayName != null)
return false;
}
if (organizationName != null ? !organizationName.equals(that.organizationName) : that.organizationName != null) {
return false;
}
if (organizationBankCode != null ? !organizationBankCode.equals(that.organizationBankCode) : that.organizationBankCode != null) {
return false;
}
if (accountSyncStatuses != null ? !accountSyncStatuses.equals(that.accountSyncStatuses) : that.accountSyncStatuses != null) {
if (organizationName != null ? !organizationName.equals(that.organizationName) : that.organizationName != null) return false;
if (organizationBankCode != null ? !organizationBankCode.equals(that.organizationBankCode) : that.organizationBankCode != null) return false;
if (accountSyncStatuses != null ? !accountSyncStatuses.equals(that.accountSyncStatuses) : that.accountSyncStatuses != null) return false;
if (authenticationChallenge != null ? !authenticationChallenge.equals(that.authenticationChallenge) : that.authenticationChallenge != null)
return false;
}
return authenticationChallenge != null ? authenticationChallenge.equals(that.authenticationChallenge) : that.authenticationChallenge == null;
if (realmSyncStartDate != null ? !realmSyncStartDate.equals(that.realmSyncStartDate) : that.realmSyncStartDate != null) return false;
if (realmSyncEndDate != null ? !realmSyncEndDate.equals(that.realmSyncEndDate) : that.realmSyncEndDate != null) return false;
return status == that.status;
}

@Override
Expand All @@ -140,9 +172,13 @@ public int hashCode() {
result = 31 * result + (int) (organizationId ^ (organizationId >>> 32));
result = 31 * result + (organizationName != null ? organizationName.hashCode() : 0);
result = 31 * result + (organizationBankCode != null ? organizationBankCode.hashCode() : 0);
result = 31 * result + (isSyncDone ? 1 : 0);
result = 31 * result + (accountSyncStatuses != null ? accountSyncStatuses.hashCode() : 0);
result = 31 * result + (authenticationChallenge != null ? authenticationChallenge.hashCode() : 0);
result = 31 * result + (isSyncDone ? 1 : 0);
result = 31 * result + (int) (realmId ^ (realmId >>> 32));
result = 31 * result + (realmSyncStartDate != null ? realmSyncStartDate.hashCode() : 0);
result = 31 * result + (realmSyncEndDate != null ? realmSyncEndDate.hashCode() : 0);
result = 31 * result + (status != null ? status.hashCode() : 0);
return result;
}
}
11 changes: 11 additions & 0 deletions sdk/src/main/java/com/meniga/sdk/models/sync/RealmSyncResult.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.meniga.sdk.models.sync

import com.google.gson.annotations.SerializedName

enum class RealmSyncResult {
@SerializedName("Success")
SUCCESS,

@SerializedName("SyncFailed")
SYNC_FAILED,
}
8 changes: 6 additions & 2 deletions sdk/src/test/resources/raw/syncresponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"organizationId": 144,
"organizationName": "ExampleBank",
"organizationBankCode": "EB",
"isSyncDone": true,
"accountSyncStatuses": [
{
"accountId": 15567,
Expand Down Expand Up @@ -49,7 +48,12 @@
"userIdentifier": null,
"canSave": false,
"loginHelp": "Please enter input"
}
},
"isSyncDone": true,
"realmId": 4,
"realmSyncStartDate": "2020-03-12T15:17:51.280Z",
"realmSyncEndDate": "2020-03-13T15:17:51.280Z",
"status": "Success"
}
]
}
Expand Down
6 changes: 5 additions & 1 deletion sdk/src/test/resources/raw/syncstatus.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@
"loginHelp": "string",
"realmUserPersonEmail": "string"
},
"isSyncDone": true
"isSyncDone": true,
"realmId": 4,
"realmSyncStartDate": "2020-03-12T15:17:51.280Z",
"realmSyncEndDate": "2020-03-13T15:17:51.280Z",
"status": "Success"
}
]
},
Expand Down

0 comments on commit 7d8a260

Please sign in to comment.