From 279660e21b0c1a2cfa366f00b890c433aae5621c Mon Sep 17 00:00:00 2001 From: varunVNnayar Date: Wed, 10 Dec 2014 00:00:26 +0530 Subject: [PATCH 1/3] Office Suite Creation of Office Suite, OfficeIntegrationTests.java , OfficeHelper.java, OfficeResourceHandler.java . --- .../integrationtests/OfficeIntegrationsTest | 37 +++++++++++++++++++ .../integrationtests/common/OfficeHelper.java | 3 +- .../common/office/OfficeHelper | 23 ++++++++++++ .../common/office/OfficeResourceHandler | 28 ++++++++++++++ 4 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/OfficeIntegrationsTest create mode 100644 mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/office/OfficeHelper create mode 100644 mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/office/OfficeResourceHandler diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/OfficeIntegrationsTest b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/OfficeIntegrationsTest new file mode 100644 index 000000000..118e6d854 --- /dev/null +++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/OfficeIntegrationsTest @@ -0,0 +1,37 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.mifosplatform.integrationtests; + +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.assertEquals; + +import com.google.gson.Gson; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mifosplatform.integrationtests.common.Utils; + +import com.jayway.restassured.builder.RequestSpecBuilder; +import com.jayway.restassured.builder.ResponseSpecBuilder; +import com.jayway.restassured.http.ContentType; +import com.jayway.restassured.specification.RequestSpecification; +import com.jayway.restassured.specification.ResponseSpecification; + +import java.util.*; +public class OfficeIntegrationsTest { + + private ResponseSpecification statusOkResponseSpec; + private RequestSpecification requestSpec; + + @Before + public void setup() { + Utils.initializeRESTAssured(); + this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); + this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); + this.statusOkResponseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); + } +} + diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/OfficeHelper.java b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/OfficeHelper.java index 31562c2c5..1045343f7 100755 --- a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/OfficeHelper.java +++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/OfficeHelper.java @@ -3,7 +3,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -package org.mifosplatform.integrationtests.common; +package org.mifosplatform.integrationtests.common.office; + import java.util.HashMap; diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/office/OfficeHelper b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/office/OfficeHelper new file mode 100644 index 000000000..84a470474 --- /dev/null +++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/office/OfficeHelper @@ -0,0 +1,23 @@ +package org.mifosplatform.integrationtests.common.office; + +import com.google.gson.Gson; + +public class OfficeHelper { + + public static class Builder { + + private String name; + private String externalId; + + private Builder(final String name) { + this.name = name; + } + + public Builder externalId(final String externalId) { + this.externalId = externalId; + return this; + } + + + } +} diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/office/OfficeResourceHandler b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/office/OfficeResourceHandler new file mode 100644 index 000000000..bc79caf88 --- /dev/null +++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/office/OfficeResourceHandler @@ -0,0 +1,28 @@ +package org.mifosplatform.integrationtests.common.office; + +import com.google.common.reflect.TypeToken; +import com.google.gson.Gson; +import com.jayway.restassured.specification.RequestSpecification; +import com.jayway.restassured.specification.ResponseSpecification; +import org.mifosplatform.integrationtests.common.Utils; + +import java.util.HashMap; +import java.util.List; + +public class OfficeResourceHandler { + + private static final String OFFICES_URL = "/mifosng-provider/api/v1/offices"; + private static final String CREATE_OFFICES_URL = OFFICES_URL + "?" + Utils.TENANT_IDENTIFIER; + + public static Integer createFund(final String fundJSON, + final RequestSpecification requestSpec, + final ResponseSpecification responseSpec) { + return Utils.performServerPost(requestSpec, responseSpec, CREATE_FUNDS_URL, fundJSON, "resourceId"); + } + + public Integer createOffice(final String openingDate) { + String json = getAsJSON(openingDate); + return Utils.performServerPost(this.requestSpec, this.responseSpec, OFFICE_URL + "?" + Utils.TENANT_IDENTIFIER, json, + CommonConstants.RESPONSE_RESOURCE_ID); + } +} From 2478851790e39c44a6a851ea8b8256d4c870f692 Mon Sep 17 00:00:00 2001 From: varunVNnayar Date: Wed, 10 Dec 2014 16:46:58 +0530 Subject: [PATCH 2/3] Upate Office Helper! --- .../common/office/OfficeHelper | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/office/OfficeHelper b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/office/OfficeHelper index 84a470474..1e7707a6c 100644 --- a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/office/OfficeHelper +++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/office/OfficeHelper @@ -8,6 +8,11 @@ public class OfficeHelper { private String name; private String externalId; + private Long id; + private String nameDecorated; + private int openingDate[] = new int[3]; + private String hierarchy; + private Builder(final String name) { this.name = name; @@ -18,6 +23,86 @@ public class OfficeHelper { return this; } + public Builder id(final long id) { + this.id = id; + } + + public Builder nameDecorated(final String nameDecorated) { + this.nameDecorated = nameDecorated; + } + + public Builder openingDate(final int[] openingDate) { + this.openingDate = openingDate; + } + + public Builder hierarchy(final String hierarchy) { + this.hierarchy = hierarchy; + } + public OfficeHelper build() { + return new OfficeHelper(this.name, this.externalId, this.id, this.nameDecorated, this.openingDate, this.hierarchy); + } } + + + + private String name; + private String externalId; + private Long id; + private String nameDecorated; + + + OfficeHelper() { + super(); + } + + private OfficeHelper(final String name, + final String externalId, final String nameDecorated, final String hierarchy, final int[] openingDate, final Long id) { + super(); + this.name = name; + this.externalId = externalId; + this.nameDecorated = nameDecorated; + this.hierarchy = hierarchy; + this.openingDate = openingDate; + this.id = id; + } + + + } + + public String toJSON() { + return new Gson().toJson(this); + } + + public static OfficeHelper fromJSON(final String jsonData) { + return new Gson().fromJson(jsonData, OfficeHelper.class); + } + + public String getName() { + return this.name; + } + + public Long getId() { + return this.id; + } + + public String getNameDecorated() + { return this.nameDecorated; } + + public String getHierarchy() + { return this.hierarchy; } + + + public String getExternalId() { + return this.externalId; + } + + public int openingDate() { + return this.openingDate; + } + + + } + + From 6b171c5a3fb50c792a0bd6eebddcf5d96e2b4a94 Mon Sep 17 00:00:00 2001 From: varunVNnayar Date: Wed, 10 Dec 2014 17:09:20 +0530 Subject: [PATCH 3/3] OfficeHelper. --- .../integrationtests/common/office/OfficeHelper | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/office/OfficeHelper b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/office/OfficeHelper index 1e7707a6c..02368d7ea 100644 --- a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/office/OfficeHelper +++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/office/OfficeHelper @@ -23,9 +23,6 @@ public class OfficeHelper { return this; } - public Builder id(final long id) { - this.id = id; - } public Builder nameDecorated(final String nameDecorated) { this.nameDecorated = nameDecorated; @@ -56,15 +53,13 @@ public class OfficeHelper { super(); } - private OfficeHelper(final String name, - final String externalId, final String nameDecorated, final String hierarchy, final int[] openingDate, final Long id) { + private OfficeHelper(final String name, final String externalId, final String nameDecorated, final String hierarchy, final int[] openingDate) { super(); this.name = name; this.externalId = externalId; this.nameDecorated = nameDecorated; this.hierarchy = hierarchy; this.openingDate = openingDate; - this.id = id; }