Test case 1 for Office creation.
This commit is contained in:
+30
-1
@@ -13,6 +13,8 @@ import org.junit.Assert;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mifosplatform.integrationtests.common.Utils;
|
import org.mifosplatform.integrationtests.common.Utils;
|
||||||
|
import org.mifosplatform.integrationtests.common.office.OfficeHelper;
|
||||||
|
import org.mifosplatform.integrationtests.common.office.OfficeResourceHandler;
|
||||||
|
|
||||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||||
import com.jayway.restassured.builder.ResponseSpecBuilder;
|
import com.jayway.restassured.builder.ResponseSpecBuilder;
|
||||||
@@ -33,5 +35,32 @@ public class OfficeIntegrationsTest {
|
|||||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||||
this.statusOkResponseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
this.statusOkResponseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateOffice()
|
||||||
|
{
|
||||||
|
int random_array = {1997, 26, 12};
|
||||||
|
OfficeHelper oh = OfficeHelper // oh ---> Office Helper
|
||||||
|
.create(Utils.randomNameGenerator("", 5))
|
||||||
|
.externalId(Utils.randomNameGenerator("offices-", 7))
|
||||||
|
.nameDecorated(Utils.randomNameGenerator("", 8))
|
||||||
|
.openingDate(random_array)
|
||||||
|
.hierarchy(".")
|
||||||
|
.build();
|
||||||
|
String JsonData = oh.toJSON();
|
||||||
|
final Long officeID = createOfficeID(JsonData, this.requestSpec, this.statusOkResponseSpec);
|
||||||
|
Assert.assertNotNull(officeID);
|
||||||
|
|
||||||
|
}
|
||||||
|
private Long createOffice(final String officeJSON,
|
||||||
|
final RequestSpecification requestSpec,
|
||||||
|
final ResponseSpecification responseSpec) {
|
||||||
|
String officeId = String.valueOf(OfficeResourceHandler.createOffice(officeJSON, requestSpec, responseSpec));
|
||||||
|
if (officeId.equals("null")) {
|
||||||
|
// Invalid JSON data parameters
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Long(officeId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+5
-1
@@ -36,7 +36,7 @@ public class OfficeHelper {
|
|||||||
this.hierarchy = hierarchy;
|
this.hierarchy = hierarchy;
|
||||||
}
|
}
|
||||||
public OfficeHelper build() {
|
public OfficeHelper build() {
|
||||||
return new OfficeHelper(this.name, this.externalId, this.id, this.nameDecorated, this.openingDate, this.hierarchy);
|
return new OfficeHelper(this.name, this.externalId, this.nameDecorated, this.openingDate, this.hierarchy);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -96,6 +96,10 @@ public class OfficeHelper {
|
|||||||
return this.openingDate;
|
return this.openingDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Builder create(final String name) {
|
||||||
|
return new Builder(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -14,10 +14,10 @@ public class OfficeResourceHandler {
|
|||||||
private static final String OFFICES_URL = "/mifosng-provider/api/v1/offices";
|
private static final String OFFICES_URL = "/mifosng-provider/api/v1/offices";
|
||||||
private static final String CREATE_OFFICES_URL = OFFICES_URL + "?" + Utils.TENANT_IDENTIFIER;
|
private static final String CREATE_OFFICES_URL = OFFICES_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||||
|
|
||||||
public static Integer createFund(final String fundJSON,
|
public static Integer createOffice(final String officeJSON,
|
||||||
final RequestSpecification requestSpec,
|
final RequestSpecification requestSpec,
|
||||||
final ResponseSpecification responseSpec) {
|
final ResponseSpecification responseSpec) {
|
||||||
return Utils.performServerPost(requestSpec, responseSpec, CREATE_FUNDS_URL, fundJSON, "resourceId");
|
return Utils.performServerPost(requestSpec, responseSpec, CREATE_OFFICES_URL, officeJSON, "resourceId");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer createOffice(final String openingDate) {
|
public Integer createOffice(final String openingDate) {
|
||||||
|
|||||||
Reference in New Issue
Block a user