From 279660e21b0c1a2cfa366f00b890c433aae5621c Mon Sep 17 00:00:00 2001 From: varunVNnayar Date: Wed, 10 Dec 2014 00:00:26 +0530 Subject: [PATCH] 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); + } +}