fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From al...@apache.org
Subject [fineract] 01/02: Move all SDK client tests into integrationtests (FINERACT-1209)
Date Sat, 07 Nov 2020 21:30:55 GMT
This is an automated email from the ASF dual-hosted git repository.

aleks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git

commit 73e330a58e1f1697ee8915bc25e5beb25ad913d8
Author: Michael Vorburger <mike@vorburger.ch>
AuthorDate: Fri Nov 6 23:47:05 2020 +0100

    Move all SDK client tests into integrationtests (FINERACT-1209)
    
    And run the against localhost instead of https://fineract.dev
---
 fineract-client/build.gradle                       |   6 +-
 .../fineract/client/util/FineractClient.java       |   3 +-
 ...tTest.java => FineractClientTechnicalTest.java} |  34 +------
 .../organisation/staff/api/StaffApiResource.java   |  21 ++---
 .../staff/api/StaffApiResourceSwagger.java         |  14 +--
 integration-tests/dependencies.gradle              |   1 +
 .../integrationtests/StaffImageApiTest.java        | 102 ---------------------
 .../fineract/integrationtests/StaffTest.java       |   2 +-
 .../integrationtests/client}/CallSubject.java      |   2 +-
 .../integrationtests/client}/ClientTest.java       |  14 +--
 .../integrationtests/client}/DocumentTest.java     |   7 +-
 .../integrationtests/client}/ImageTest.java        |  34 +++----
 .../integrationtests/client}/IntegrationTest.java  |   9 +-
 .../integrationtests/client}/OfficeTest.java       |  15 ++-
 .../integrationtests/client/StaffTest.java         |  67 ++++++++++++++
 .../integrationtests/common/ImageHelper.java       |  81 ----------------
 .../test/resources/michael.vorburger-crepes.jpg    | Bin
 17 files changed, 134 insertions(+), 278 deletions(-)

diff --git a/fineract-client/build.gradle b/fineract-client/build.gradle
index b11b028..4bcbe9e 100644
--- a/fineract-client/build.gradle
+++ b/fineract-client/build.gradle
@@ -103,7 +103,11 @@ compileJava {
 }
 
 tasks.withType(JavaCompile) {
-    // the generated code contains some warnings in build/generated/java/src/main/java/org/apache/fineract/client/auth/OAuthOkHttpClient.java#L71
that won't pass
+    // the generated code in build/generated/java/src/main/java/org/apache/fineract/client/auth/OAuthOkHttpClient.java#L71
currently uses deprecated RequestBody.create(MediaType,String)
+    // TODO FINERACT-1247 why does this not work:
+    //   options.compilerArgs -= ["-Xlint:deprecation"]
+    //   options.compilerArgs += ["-Xlint:-deprecation"]
+    // So we just have to use:
     options.compilerArgs -= ["-Werror"]
 }
 
diff --git a/fineract-client/src/main/java/org/apache/fineract/client/util/FineractClient.java
b/fineract-client/src/main/java/org/apache/fineract/client/util/FineractClient.java
index ab12819..e6a4a64 100644
--- a/fineract-client/src/main/java/org/apache/fineract/client/util/FineractClient.java
+++ b/fineract-client/src/main/java/org/apache/fineract/client/util/FineractClient.java
@@ -453,7 +453,8 @@ public final class FineractClient {
                         }
                     };
 
-                    SSLContext sslContext = SSLContext.getInstance("SSL"); // TODO "SSL"
or "TLS" as in hooks.processor.ProcessorHelper?
+                    // TODO "SSL" or "TLS" as in hooks.processor.ProcessorHelper?
+                    SSLContext sslContext = SSLContext.getInstance("SSL");
                     sslContext.init(null, new TrustManager[] { insecureX509TrustManager },
new SecureRandom());
                     SSLSocketFactory insecureSslSocketFactory = sslContext.getSocketFactory();
 
diff --git a/fineract-client/src/test/java/org/apache/fineract/client/test/FineractClientTest.java
b/fineract-client/src/test/java/org/apache/fineract/client/test/FineractClientTechnicalTest.java
similarity index 54%
rename from fineract-client/src/test/java/org/apache/fineract/client/test/FineractClientTest.java
rename to fineract-client/src/test/java/org/apache/fineract/client/test/FineractClientTechnicalTest.java
index 9afb89a..63bb567 100644
--- a/fineract-client/src/test/java/org/apache/fineract/client/test/FineractClientTest.java
+++ b/fineract-client/src/test/java/org/apache/fineract/client/test/FineractClientTechnicalTest.java
@@ -18,48 +18,18 @@
  */
 package org.apache.fineract.client.test;
 
-import static com.google.common.truth.Truth.assertThat;
-import static org.apache.fineract.client.util.Calls.ok;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 
-import okhttp3.logging.HttpLoggingInterceptor.Level;
 import org.apache.fineract.client.util.FineractClient;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
 
 /**
- * Illustrates use of Fineract SDK REST Client.
+ * Tests a few technical aspect of the Fineract SDK REST Client.
  *
  * @author Michael Vorburger.ch
  */
-public class FineractClientTest {
-
-    void checkClients(FineractClient fineract) {
-        assertThat(ok(fineract.clients.retrieveAll20(null, null, null, null, null, null,
null, null, 0, 100, null, null, null))
-                .getTotalFilteredRecords()).isAtLeast(3);
-    }
-
-    @Test
-    void testRetrieveAllClientsFromFineractDev() {
-        FineractClient fineract = FineractClient.builder().baseURL("https://demo.fineract.dev/fineract-provider/api/v1/").tenant("default")
-                .basicAuth("mifos", "password").logging(Level.BODY).build();
-        checkClients(fineract);
-    }
-
-    @Test
-    @Disabled // TODO remove Disabled once https://issues.apache.org/jira/browse/FINERACT-1209
is fixed
-    void testRetrieveAllClientsFromLocalhostWithInsecureSelfSignedCert() {
-        FineractClient fineract = FineractClient.builder().baseURL("https://localhost:8443/fineract-provider/api/v1/").tenant("default")
-                .basicAuth("mifos", "password").insecure(true).build();
-        checkClients(fineract);
-    }
-
-    @Test // FINERACT-1220
-    void testOfficesDateFormat() {
-        FineractClient fineract = FineractClient.builder().baseURL("https://demo.fineract.dev/fineract-provider/api/v1/").tenant("default")
-                .basicAuth("mifos", "password").insecure(true).logging(Level.BODY).build();
-        ok(fineract.offices.retrieveOffices(true, null, null));
-    }
+public class FineractClientTechnicalTest {
 
     @Test
     @Disabled // TODO remove Ignore once https://issues.apache.org/jira/browse/FINERACT-1221
is fixed
diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/api/StaffApiResource.java
b/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/api/StaffApiResource.java
index 6a0f0ea..81e653f 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/api/StaffApiResource.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/api/StaffApiResource.java
@@ -115,9 +115,8 @@ public class StaffApiResource {
             + "and for status=ALL, it Returns both ACTIVE and INACTIVE Staff.\n" + "\n" +
"Example Requests:\n" + "\n"
             + "staff?status=active")
     @ApiResponses({
-            @ApiResponse(responseCode = "200", description = "OK", content = @Content(array
= @ArraySchema(schema = @Schema(implementation = StaffApiResourceSwagger.GetStaffResponse.class)))),
-            @ApiResponse(responseCode = "200", description = "GET https://DomainName/api/v1/staff?status={ACTIVE|INACTIVE|ALL}",
content = @Content(schema = @Schema(implementation = StaffApiResourceSwagger.GetStaffResponse.class)))
})
-    public String retrieveStaff(@Context final UriInfo uriInfo,
+            @ApiResponse(responseCode = "200", description = "OK", content = @Content(array
= @ArraySchema(schema = @Schema(implementation = StaffApiResourceSwagger.RetrieveOneResponse.class))))
})
+    public String retrieveAll(@Context final UriInfo uriInfo,
             @QueryParam("officeId") @Parameter(description = "officeId") final Long officeId,
             @DefaultValue("false") @QueryParam("staffInOfficeHierarchy") @Parameter(description
= "staffInOfficeHierarchy") final boolean staffInOfficeHierarchy,
             @DefaultValue("false") @QueryParam("loanOfficersOnly") @Parameter(description
= "loanOfficersOnly") final boolean loanOfficersOnly,
@@ -143,8 +142,8 @@ public class StaffApiResource {
             + "officeId, firstname, lastname\n" + "\n" + "Optional Fields: \n" + "isLoanOfficer,
isActive")
     @RequestBody(required = true, content = @Content(schema = @Schema(implementation = StaffApiResourceSwagger.PostStaffRequest.class)))
     @ApiResponses({
-            @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema
= @Schema(implementation = StaffApiResourceSwagger.PostStaffResponse.class))) })
-    public String createStaff(@Parameter(hidden = true) final String apiRequestBodyAsJson)
{
+            @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema
= @Schema(implementation = StaffApiResourceSwagger.CreateStaffResponse.class))) })
+    public String create(@Parameter(hidden = true) final String apiRequestBodyAsJson) {
 
         final CommandWrapper commandRequest = new CommandWrapperBuilder().createStaff().withJson(apiRequestBodyAsJson).build();
 
@@ -160,8 +159,8 @@ public class StaffApiResource {
     @Operation(summary = "Retrieve a Staff Member", description = "Returns the details of
a Staff Member.\n" + "\n" + "Example Requests:\n"
             + "\n" + "staff/1")
     @ApiResponses({
-            @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema
= @Schema(implementation = StaffApiResourceSwagger.GetStaffResponse.class))) })
-    public String retreiveStaff(@PathParam("staffId") @Parameter(description = "staffId")
final Long staffId,
+            @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema
= @Schema(implementation = StaffApiResourceSwagger.RetrieveOneResponse.class))) })
+    public String retrieveOne(@PathParam("staffId") @Parameter(description = "staffId") final
Long staffId,
             @Context final UriInfo uriInfo) {
 
         this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
@@ -183,8 +182,8 @@ public class StaffApiResource {
     @Operation(summary = "Update a Staff Member", description = "Updates the details of a
staff member.")
     @RequestBody(required = true, content = @Content(schema = @Schema(implementation = StaffApiResourceSwagger.PutStaffRequest.class)))
     @ApiResponses({
-            @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema
= @Schema(implementation = StaffApiResourceSwagger.PutStaffResponse.class))) })
-    public String updateStaff(@PathParam("staffId") @Parameter(description = "staffId") final
Long staffId,
+            @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema
= @Schema(implementation = StaffApiResourceSwagger.UpdateStaffResponse.class))) })
+    public String update(@PathParam("staffId") @Parameter(description = "staffId") final
Long staffId,
             @Parameter(hidden = true) final String apiRequestBodyAsJson) {
 
         final CommandWrapper commandRequest = new CommandWrapperBuilder().updateStaff(staffId).withJson(apiRequestBodyAsJson).build();
@@ -197,14 +196,14 @@ public class StaffApiResource {
     @GET
     @Path("downloadtemplate")
     @Produces("application/vnd.ms-excel")
-    public Response getStaffTemplate(@QueryParam("officeId") final Long officeId, @QueryParam("dateFormat")
final String dateFormat) {
+    public Response getTemplate(@QueryParam("officeId") final Long officeId, @QueryParam("dateFormat")
final String dateFormat) {
         return bulkImportWorkbookPopulatorService.getTemplate(GlobalEntityType.STAFF.toString(),
officeId, null, dateFormat);
     }
 
     @POST
     @Path("uploadtemplate")
     @Consumes(MediaType.MULTIPART_FORM_DATA)
-    public String postStaffTemplate(@FormDataParam("file") InputStream uploadedInputStream,
+    public String postTemplate(@FormDataParam("file") InputStream uploadedInputStream,
             @FormDataParam("file") FormDataContentDisposition fileDetail, @FormDataParam("locale")
final String locale,
             @FormDataParam("dateFormat") final String dateFormat) {
         final Long importDocumentId = this.bulkImportWorkbookService.importWorkbook(GlobalEntityType.STAFF.toString(),
uploadedInputStream,
diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/api/StaffApiResourceSwagger.java
b/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/api/StaffApiResourceSwagger.java
index 289a968..95e5e55 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/api/StaffApiResourceSwagger.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/api/StaffApiResourceSwagger.java
@@ -39,7 +39,7 @@ final class StaffApiResourceSwagger {
         }
 
         @Schema(example = "1")
-        public Long id;
+        public Long officeId;
         @Schema(example = "John")
         public String firstname;
         @Schema(example = "Doe")
@@ -62,9 +62,9 @@ final class StaffApiResourceSwagger {
     }
 
     @Schema(description = "PostStaffResponse")
-    public static final class PostStaffResponse {
+    public static final class CreateStaffResponse {
 
-        private PostStaffResponse() {
+        private CreateStaffResponse() {
 
         }
 
@@ -75,9 +75,9 @@ final class StaffApiResourceSwagger {
     }
 
     @Schema(description = "GetStaffResponse")
-    public static final class GetStaffResponse {
+    public static final class RetrieveOneResponse {
 
-        private GetStaffResponse() {
+        private RetrieveOneResponse() {
 
         }
 
@@ -119,9 +119,9 @@ final class StaffApiResourceSwagger {
     }
 
     @Schema(description = "PutStaffResponse")
-    public static final class PutStaffResponse {
+    public static final class UpdateStaffResponse {
 
-        private PutStaffResponse() {
+        private UpdateStaffResponse() {
 
         }
 
diff --git a/integration-tests/dependencies.gradle b/integration-tests/dependencies.gradle
index be1b2b8..ec47d59 100644
--- a/integration-tests/dependencies.gradle
+++ b/integration-tests/dependencies.gradle
@@ -23,6 +23,7 @@ dependencies {
     tomcat 'org.apache.tomcat:tomcat:9.0.39@zip'
     testImplementation( files("$rootDir/fineract-provider/build/classes/java/main/"),
             project(path: ':fineract-provider', configuration: 'runtimeElements'),
+            project(path: ':fineract-client', configuration: 'runtimeElements'),
             'org.junit.jupiter:junit-jupiter-api:5.7.0',
             'com.google.truth:truth:1.0.1',
             'com.google.truth.extensions:truth-java8-extension:1.0.1',
diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/StaffImageApiTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/StaffImageApiTest.java
deleted file mode 100644
index 54f7d59..0000000
--- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/StaffImageApiTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.fineract.integrationtests;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import io.restassured.builder.RequestSpecBuilder;
-import io.restassured.builder.ResponseSpecBuilder;
-import io.restassured.http.ContentType;
-import io.restassured.specification.RequestSpecification;
-import io.restassured.specification.ResponseSpecification;
-import org.apache.fineract.integrationtests.common.ImageHelper;
-import org.apache.fineract.integrationtests.common.Utils;
-import org.apache.fineract.integrationtests.common.organisation.StaffHelper;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-@Deprecated // replaced by new ImageTest, can be deleted as FINERACT-1209 is fully implemented
-public class StaffImageApiTest {
-
-    private RequestSpecification requestSpec;
-    private ResponseSpecification responseSpec;
-    private ResponseSpecification responseSpec404;
-
-    @BeforeEach
-    public void setup() {
-        Utils.initializeRESTAssured();
-        this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
-        this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
-        this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
-        this.responseSpec404 = new ResponseSpecBuilder().expectStatusCode(404).build();
-    }
-
-    @Test
-    public void createStaffImage() {
-        Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
-        Integer imageId = ImageHelper.createImageForStaff(this.requestSpec, this.responseSpec,
staffId);
-        assertNotNull(imageId, "Image id should not be null");
-    }
-
-    @Test
-    public void getStaffImage() {
-        Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
-        Integer imageId = ImageHelper.createImageForStaff(this.requestSpec, this.responseSpec,
staffId);
-        assertNotNull(imageId, "Image id should not be null");
-
-        String imageAsText = ImageHelper.getStaffImageAsText(this.requestSpec, this.responseSpec,
staffId);
-        assertNotNull("Image id should not be null", imageAsText);
-        assertEquals(ImageHelper.generateImageAsText(), imageAsText);
-    }
-
-    @Test
-    public void getStaffImageAsBinary() {
-        Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
-        Integer imageId = ImageHelper.createImageForStaff(this.requestSpec, this.responseSpec,
staffId);
-        assertNotNull(imageId, "Image id should not be null");
-
-        byte[] imageAsBytes = ImageHelper.getStaffImageAsBinary(this.requestSpec, this.responseSpec,
staffId);
-        assertNotNull(imageAsBytes, "Image content should not be null");
-        assertEquals(251, imageAsBytes.length);
-    }
-
-    @Test
-    public void updateImage() {
-        Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
-        Integer imageId = ImageHelper.createImageForStaff(this.requestSpec, this.responseSpec,
staffId);
-        assertNotNull(imageId, "Image id should not be null");
-
-        imageId = ImageHelper.updateImageForStaff(this.requestSpec, this.responseSpec, staffId);
-        assertNotNull(imageId, "Image id should not be null");
-    }
-
-    @Test
-    public void deleteStaffImage() {
-        Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
-        Integer imageId = ImageHelper.createImageForStaff(this.requestSpec, this.responseSpec,
staffId);
-        assertNotNull(imageId, "Image id should not be null");
-
-        imageId = ImageHelper.deleteStaffImage(this.requestSpec, this.responseSpec, staffId);
-        assertNotNull(imageId, "Image id should not be null");
-
-        ImageHelper.getStaffImageAsBinary(this.requestSpec, this.responseSpec404, staffId);
-        // No additional Assertion required, the point is the responseSpec404
-    }
-}
diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/StaffTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/StaffTest.java
index c18ee3f..016f758 100644
--- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/StaffTest.java
+++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/StaffTest.java
@@ -33,6 +33,7 @@ import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+@Deprecated // TODO move this into new org.apache.fineract.integrationtests.client.StaffTest
 public class StaffTest {
 
     private RequestSpecification requestSpec;
@@ -61,7 +62,6 @@ public class StaffTest {
 
     @Test
     public void testStaffCreateValidationError() {
-
         final String noOfficeJson = StaffHelper.createStaffWithJSONFields("firstname", "lastname");
         final String noFirstnameJson = StaffHelper.createStaffWithJSONFields("officeId",
"lastname");
         final String noLastnameJson = StaffHelper.createStaffWithJSONFields("officeId", "firstname");
diff --git a/fineract-client/src/test/java/org/apache/fineract/client/testutil/CallSubject.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/CallSubject.java
similarity index 97%
rename from fineract-client/src/test/java/org/apache/fineract/client/testutil/CallSubject.java
rename to integration-tests/src/test/java/org/apache/fineract/integrationtests/client/CallSubject.java
index f2e6c7b..38e26c6 100644
--- a/fineract-client/src/test/java/org/apache/fineract/client/testutil/CallSubject.java
+++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/CallSubject.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.fineract.client.testutil;
+package org.apache.fineract.integrationtests.client;
 
 import com.google.common.truth.FailureMetadata;
 import com.google.common.truth.Subject;
diff --git a/fineract-client/src/test/java/org/apache/fineract/integrationtests/newstyle/ClientTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/ClientTest.java
similarity index 86%
rename from fineract-client/src/test/java/org/apache/fineract/integrationtests/newstyle/ClientTest.java
rename to integration-tests/src/test/java/org/apache/fineract/integrationtests/client/ClientTest.java
index af6b66c..5d44ff0 100644
--- a/fineract-client/src/test/java/org/apache/fineract/integrationtests/newstyle/ClientTest.java
+++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/ClientTest.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.fineract.integrationtests.newstyle;
+package org.apache.fineract.integrationtests.client;
 
 import java.util.Optional;
 import org.apache.fineract.client.models.GetClientsResponse;
@@ -39,14 +39,14 @@ public class ClientTest extends IntegrationTest {
 
     @Test
     @Order(2)
-    void retrieveOneExisting() {
-        assertThat(retrieveOne()).isPresent();
+    void retrieveAnyExisting() {
+        assertThat(retrieveFirst()).isPresent();
     }
 
     // The following are not tests, but helpful utilities for other tests
 
     public Long getClientId() {
-        return retrieveOne().orElseGet(this::create);
+        return retrieveFirst().orElseGet(this::create);
     }
 
     Long create() {
@@ -56,13 +56,13 @@ public class ClientTest extends IntegrationTest {
         // TODO why dateFormat and locale required even when no activationDate?!
         // https://issues.apache.org/jira/browse/FINERACT-1233
         return (long) ok(fineract().clients
-                .create5(new PostClientsRequest().officeId(1).fullname("TestClient").dateFormat(dateFormat()).locale("en_US")))
+                .create6(new PostClientsRequest().officeId(1).fullname("TestClient").dateFormat(dateFormat()).locale("en_US")))
                         .getClientId();
     }
 
-    Optional<Long> retrieveOne() {
+    Optional<Long> retrieveFirst() {
         GetClientsResponse clients = ok(
-                fineract().clients.retrieveAll20(null, null, null, null, null, null, null,
null, 0, 1, null, null, false));
+                fineract().clients.retrieveAll21(null, null, null, null, null, null, null,
null, 0, 1, null, null, false));
         if (clients.getTotalFilteredRecords() > 0) {
             // TODO rm long cast, see https://issues.apache.org/jira/browse/FINERACT-1230
             return Optional.of((long) clients.getPageItems().get(0).getId());
diff --git a/fineract-client/src/test/java/org/apache/fineract/integrationtests/newstyle/DocumentTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/DocumentTest.java
similarity index 91%
rename from fineract-client/src/test/java/org/apache/fineract/integrationtests/newstyle/DocumentTest.java
rename to integration-tests/src/test/java/org/apache/fineract/integrationtests/client/DocumentTest.java
index fed52b8..1d7d49b 100644
--- a/fineract-client/src/test/java/org/apache/fineract/integrationtests/newstyle/DocumentTest.java
+++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/DocumentTest.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.fineract.integrationtests.newstyle;
+package org.apache.fineract.integrationtests.client;
 
 import java.io.File;
 import java.io.IOException;
@@ -24,7 +24,6 @@ import okhttp3.MediaType;
 import okhttp3.MultipartBody.Part;
 import okhttp3.ResponseBody;
 import org.apache.fineract.client.models.GetEntityTypeEntityIdDocumentsResponse;
-import org.apache.fineract.client.models.PostEntityTypeEntityIdDocumentsResponse;
 import org.apache.fineract.client.util.Parts;
 import org.junit.jupiter.api.Order;
 import org.junit.jupiter.api.Test;
@@ -54,9 +53,7 @@ public class DocumentTest extends IntegrationTest {
         String name = "Test";
         Part part = Parts.fromFile(testFile);
         String description = null;
-        // TODO used var in tests when moved from fineract-client (Java 8 only) to new module
-        PostEntityTypeEntityIdDocumentsResponse response = ok(
-                fineract().documents.createDocument("clients", clientId, part, name, description));
+        var response = ok(fineract().documents.createDocument("clients", clientId, part,
name, description));
         assertThat(response.getResourceId()).isNotNull();
         assertThat(response.getResourceIdentifier()).isNotEmpty();
         documentId = response.getResourceId();
diff --git a/fineract-client/src/test/java/org/apache/fineract/integrationtests/newstyle/ImageTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/ImageTest.java
similarity index 80%
rename from fineract-client/src/test/java/org/apache/fineract/integrationtests/newstyle/ImageTest.java
rename to integration-tests/src/test/java/org/apache/fineract/integrationtests/client/ImageTest.java
index 56b951e..8bf466b 100644
--- a/fineract-client/src/test/java/org/apache/fineract/integrationtests/newstyle/ImageTest.java
+++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/ImageTest.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.fineract.integrationtests.newstyle;
+package org.apache.fineract.integrationtests.client;
 
 import java.io.File;
 import java.io.IOException;
@@ -24,7 +24,6 @@ import okhttp3.MediaType;
 import okhttp3.ResponseBody;
 import org.apache.fineract.client.services.ImagesApi;
 import org.apache.fineract.client.util.Parts;
-import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Order;
 import org.junit.jupiter.api.Test;
 import retrofit2.Call;
@@ -37,28 +36,24 @@ import retrofit2.http.Headers;
  *
  * @author Michael Vorburger.ch
  */
-@Disabled // TODO FINERACT-1247
 public class ImageTest extends IntegrationTest {
 
-    // TODO This "new style" test is equivalent to the old StaffImageApiTest, so we could
delete that (after
-    // FINERACT-1209)
-
     final File testImage = new File(getClass().getResource("/michael.vorburger-crepes.jpg").getFile());
 
     Long clientId = new ClientTest().getClientId();
-    // staffId is hard-coded to 1L below, because that always exists
+    Long staffId = new StaffTest().getStaffId();
 
     @Test
     @Order(1)
     void create() {
-        ok(fineract().images.create("staff", 1L, Parts.fromFile(testImage)));
+        ok(fineract().images.create("staff", staffId, Parts.fromFile(testImage)));
         ok(fineract().images.create("clients", clientId, Parts.fromFile(testImage)));
     }
 
     @Test
     @Order(2)
     void getOriginalSize() throws IOException {
-        ResponseBody r = ok(fineract().images.get("staff", 1L, 3505, 1972, null));
+        ResponseBody r = ok(fineract().images.get("staff", staffId, 3505, 1972, null));
         assertThat(r.contentType()).isEqualTo(MediaType.get("text/plain"));
         String encodedImage = r.string();
         assertThat(encodedImage).startsWith("data:image/jpeg;base64,");
@@ -69,14 +64,14 @@ public class ImageTest extends IntegrationTest {
     @Test
     @Order(3)
     void getSmallerSize() throws IOException {
-        ResponseBody r = ok(fineract().images.get("staff", 1L, 128, 128, null));
+        ResponseBody r = ok(fineract().images.get("staff", staffId, 128, 128, null));
         assertThat(r.string()).hasLength(6591);
     }
 
     @Test
     @Order(4)
     void getBiggerSize() throws IOException {
-        ResponseBody r = ok(fineract().images.get("staff", 1L, 9000, 6000, null));
+        ResponseBody r = ok(fineract().images.get("staff", staffId, 9000, 6000, null));
         assertThat(r.string()).hasLength(2846549);
     }
 
@@ -84,21 +79,22 @@ public class ImageTest extends IntegrationTest {
     @Order(5)
     void getInlineOctetOutput() throws IOException {
         // 3505x1972 is the exact original size of testFile
-        Response<ResponseBody> r = okR(fineract().images.get("staff", 1L, 3505, 1972,
"inline_octet"));
+        Response<ResponseBody> r = okR(fineract().images.get("staff", staffId, 3505,
1972, "inline_octet"));
         try (ResponseBody body = r.body()) {
             assertThat(body.contentType()).isEqualTo(MediaType.get("image/jpeg"));
             assertThat(body.bytes().length).isEqualTo(testImage.length());
             assertThat(body.contentLength()).isEqualTo(testImage.length());
         }
 
-        String expectedFileName = "test, testJPEG"; // without dot!
+        var staff = ok(fineract().staff.retrieveOne8(staffId));
+        String expectedFileName = staff.getDisplayName() + "JPEG"; // without dot!
         assertThat(Parts.fileName(r)).hasValue(expectedFileName);
     }
 
     @Test
     @Order(6)
     void getOctetOutput() throws IOException {
-        ResponseBody r = ok(fineract().images.get("staff", 1L, 3505, 1972, "octet"));
+        ResponseBody r = ok(fineract().images.get("staff", staffId, 3505, 1972, "octet"));
         assertThat(r.contentType()).isEqualTo(MediaType.get("image/jpeg"));
         assertThat(r.bytes().length).isEqualTo(testImage.length());
         assertThat(r.contentLength()).isEqualTo(testImage.length());
@@ -107,7 +103,7 @@ public class ImageTest extends IntegrationTest {
     @Test
     @Order(7)
     void getAnotherOutput() throws IOException {
-        ResponseBody r = ok(fineract().images.get("staff", 1L, 3505, 1972, "abcd"));
+        ResponseBody r = ok(fineract().images.get("staff", staffId, 3505, 1972, "abcd"));
         assertThat(r.contentType()).isEqualTo(MediaType.get("text/plain"));
         assertThat(r.string()).startsWith("data:image/jpeg;base64,");
     }
@@ -115,7 +111,7 @@ public class ImageTest extends IntegrationTest {
     @Test
     @Order(8)
     void getText() throws IOException {
-        ResponseBody r = ok(fineract().createService(ImagesApiWithHeadersForTest.class).getText("staff",
1L, 3505, 1972, null));
+        ResponseBody r = ok(fineract().createService(ImagesApiWithHeadersForTest.class).getText("staff",
staffId, 3505, 1972, null));
         assertThat(r.contentType()).isEqualTo(MediaType.get("text/plain"));
         assertThat(r.string()).startsWith("data:image/jpeg;base64,");
     }
@@ -123,7 +119,7 @@ public class ImageTest extends IntegrationTest {
     @Test
     @Order(9)
     void getBytes() throws IOException {
-        ResponseBody r = ok(fineract().createService(ImagesApiWithHeadersForTest.class).getBytes("staff",
1L, 3505, 1972, null));
+        ResponseBody r = ok(fineract().createService(ImagesApiWithHeadersForTest.class).getBytes("staff",
staffId, 3505, 1972, null));
         assertThat(r.contentType()).isEqualTo(MediaType.get("image/jpeg"));
         assertThat(r.bytes().length).isEqualTo(testImage.length());
     }
@@ -131,13 +127,13 @@ public class ImageTest extends IntegrationTest {
     @Test
     @Order(50)
     void update() {
-        ok(fineract().images.update("staff", 1L, Parts.fromFile(testImage)));
+        ok(fineract().images.update("staff", staffId, Parts.fromFile(testImage)));
     }
 
     @Test
     @Order(99)
     void delete() {
-        ok(fineract().images.delete("staff", 1L));
+        ok(fineract().images.delete("staff", staffId));
         ok(fineract().images.delete("clients", clientId));
     }
 
diff --git a/fineract-client/src/test/java/org/apache/fineract/integrationtests/newstyle/IntegrationTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/IntegrationTest.java
similarity index 91%
rename from fineract-client/src/test/java/org/apache/fineract/integrationtests/newstyle/IntegrationTest.java
rename to integration-tests/src/test/java/org/apache/fineract/integrationtests/client/IntegrationTest.java
index 523d409..1319326 100644
--- a/fineract-client/src/test/java/org/apache/fineract/integrationtests/newstyle/IntegrationTest.java
+++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/IntegrationTest.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.fineract.integrationtests.newstyle;
+package org.apache.fineract.integrationtests.client;
 
 import com.google.common.truth.BigDecimalSubject;
 import com.google.common.truth.BooleanSubject;
@@ -35,7 +35,6 @@ import java.math.BigDecimal;
 import java.util.Optional;
 import java.util.Random;
 import okhttp3.logging.HttpLoggingInterceptor.Level;
-import org.apache.fineract.client.testutil.CallSubject;
 import org.apache.fineract.client.util.Calls;
 import org.apache.fineract.client.util.FineractClient;
 import org.junit.jupiter.api.MethodOrderer;
@@ -62,9 +61,9 @@ public abstract class IntegrationTest {
 
     protected FineractClient fineract() {
         if (fineract == null) {
-            // TODO change from Fineract.dev to https://localhost:8443/fineract-provider/api/v1/
after FINERACT-1209
-            String url = System.getProperty("fineract.it.url", "https://demo.fineract.dev/fineract-provider/api/v1/");
-            fineract = FineractClient.builder().baseURL(url).tenant("default").basicAuth("mifos",
"password").insecure(true)
+            String url = System.getProperty("fineract.it.url", "https://localhost:8443/fineract-provider/api/v1/");
+            // insecure(true) should *ONLY* ever be used for https://localhost:8443, NOT
in real clients!!
+            fineract = FineractClient.builder().insecure(true).baseURL(url).tenant("default").basicAuth("mifos",
"password")
                     .logging(Level.NONE).build();
         }
         return fineract;
diff --git a/fineract-client/src/test/java/org/apache/fineract/integrationtests/newstyle/OfficeTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/OfficeTest.java
similarity index 68%
rename from fineract-client/src/test/java/org/apache/fineract/integrationtests/newstyle/OfficeTest.java
rename to integration-tests/src/test/java/org/apache/fineract/integrationtests/client/OfficeTest.java
index ddfe5db..13ecb93 100644
--- a/fineract-client/src/test/java/org/apache/fineract/integrationtests/newstyle/OfficeTest.java
+++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/OfficeTest.java
@@ -16,9 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.fineract.integrationtests.newstyle;
+package org.apache.fineract.integrationtests.client;
 
 import java.time.LocalDate;
+import java.time.ZoneId;
+import java.util.List;
+import org.apache.fineract.client.models.GetOfficesResponse;
 import org.apache.fineract.client.models.PostOfficesRequest;
 import org.junit.jupiter.api.Order;
 import org.junit.jupiter.api.Test;
@@ -36,13 +39,15 @@ public class OfficeTest extends IntegrationTest {
         // NB parentId(1) always exists (Head Office)
         // NB name random() because Office Names have to be unique
         // TODO requiring dateFormat(..).locale(..) is dumb :( see https://issues.apache.org/jira/browse/FINERACT-1233
-        assertThat(ok(fineract().offices.createOffice(new PostOfficesRequest().name("TestOffice-"
+ random()).parentId(1L)
-                .openingDate(LocalDate.now()).dateFormat(dateFormat()).locale("en_US"))).getOfficeId()).isGreaterThan(0);
+        assertThat(ok(fineract().offices.createOffice(new PostOfficesRequest().name("TestOffice_"
+ random()).parentId(1L)
+                .openingDate(LocalDate.now(ZoneId.of("UTC"))).dateFormat(dateFormat()).locale("en_US"))).getOfficeId()).isGreaterThan(0);
     }
 
     @Test
     @Order(2)
-    void retrieveOneExisting() {
-        assertThat(ok(fineract().offices.retrieveOffices(true, null, null)).size()).isAtLeast(2);
+    void retrieveOneExistingInclDateFormat() { // see FINERACT-1220 re. what this tests re.
Date Format
+        List<GetOfficesResponse> response = ok(fineract().offices.retrieveOffices(true,
null, null));
+        assertThat(response.size()).isAtLeast(1);
+        assertThat(response.get(0).getOpeningDate()).isNotNull();
     }
 }
diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/StaffTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/StaffTest.java
new file mode 100644
index 0000000..29a0f8b
--- /dev/null
+++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/StaffTest.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.integrationtests.client;
+
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.util.Optional;
+import org.apache.fineract.client.models.PostStaffRequest;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Integration Test for /staff API.
+ *
+ * @author Michael Vorburger.ch
+ */
+public class StaffTest extends IntegrationTest {
+
+    @Test
+    @Order(1)
+    void createOne() {
+        assertThat(create()).isGreaterThan(0);
+    }
+
+    @Test
+    @Order(2)
+    void retrieveAnyExisting() {
+        assertThat(retrieveFirst()).isPresent();
+    }
+
+    // The following are not tests, but helpful utilities for other tests
+
+    public Long getStaffId() {
+        return retrieveFirst().orElseGet(this::create);
+    }
+
+    Long create() {
+        return ok(fineract().staff
+                .create3(new PostStaffRequest().officeId(1L).firstname("StaffTest " + random()).lastname("Staffer
" + random())
+                        .externalId(random()).joiningDate(LocalDate.now(ZoneId.of("UTC"))).dateFormat(dateFormat()).locale("en_US")))
+                                .getResourceId();
+    }
+
+    Optional<Long> retrieveFirst() {
+        var staff = ok(fineract().staff.retrieveAll16(1L, true, false, "ACTIVE"));
+        if (staff.size() > 0) {
+            return Optional.of((long) staff.get(0).getId());
+        }
+        return Optional.empty();
+    }
+}
diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/ImageHelper.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/ImageHelper.java
deleted file mode 100644
index 4a2f0b9..0000000
--- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/ImageHelper.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.fineract.integrationtests.common;
-
-import io.restassured.specification.RequestSpecification;
-import io.restassured.specification.ResponseSpecification;
-import org.apache.http.HttpHeaders;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated // replaced by new ImageTest, can be deleted as FINERACT-1209 is fully implemented
-public final class ImageHelper {
-
-    private ImageHelper() {
-
-    }
-
-    private static final Logger LOG = LoggerFactory.getLogger(ImageHelper.class);
-    private static final String STAFF_IMAGE_URL = "/fineract-provider/api/v1/staff/";
-    private static final String IMAGES_URI = "/images";
-
-    public static Integer createImageForStaff(final RequestSpecification requestSpec, final
ResponseSpecification responseSpec,
-            Integer staffId) {
-        LOG.info("---------------------------------CREATING AN IMAGE FOR STAFF---------------------------------------------");
-        final String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER;
-        return Utils.performServerPost(requestSpec, responseSpec, URL, generateImageAsText(),
"resourceId");
-    }
-
-    public static Integer updateImageForStaff(final RequestSpecification requestSpec, final
ResponseSpecification responseSpec,
-            Integer staffId) {
-        LOG.info("---------------------------------UPDATING AN IMAGE FOR STAFF---------------------------------------------");
-        final String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER;
-        return Utils.performServerPut(requestSpec, responseSpec, URL, generateImageAsText(),
"resourceId");
-    }
-
-    public static String getStaffImageAsText(final RequestSpecification requestSpec, final
ResponseSpecification responseSpec,
-            Integer staffId) {
-        LOG.info("---------------------------------RETRIEVING STAFF IMAGE---------------------------------------------");
-        final String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER;
-        requestSpec.header(HttpHeaders.ACCEPT, "text/plain");
-        return Utils.performGetTextResponse(requestSpec, responseSpec, URL);
-    }
-
-    public static byte[] getStaffImageAsBinary(final RequestSpecification requestSpec, final
ResponseSpecification responseSpec,
-            Integer staffId) {
-        LOG.info("---------------------------------RETRIEVING STAFF IMAGE---------------------------------------------");
-        final String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER;
-        requestSpec.header(HttpHeaders.ACCEPT, "application/octet-stream");
-        return Utils.performGetBinaryResponse(requestSpec, responseSpec, URL);
-    }
-
-    public static Integer deleteStaffImage(final RequestSpecification requestSpec, final
ResponseSpecification responseSpec,
-            Integer staffId) {
-        LOG.info("---------------------------------RETRIEVING STAFF IMAGE---------------------------------------------");
-        final String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER;
-        return Utils.performServerDelete(requestSpec, responseSpec, URL, "resourceId");
-    }
-
-    public static String generateImageAsText() {
-        return "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJ\r\n"
-                + "bWFnZVJlYWR5ccllPAAAAJ1JREFUeNpi+P//PwMIA4E9EG8E4idQDGLbw+WhiiqA+D8OXAFVAzbp\r\n"
-                + "DxBvB2JLIGaGYkuoGEjOhhFIHAbij0BdPgxYACMj42ogJQpifwBiXSDeC8JIbt4LxSC5DyxQjTeB\r\n"
-                + "+BeaYb+Q5EBOAVutCzMJHUNNPADzzDokiYdAfAmJvwLkGeTgWQfyKZICS6hYBTwc0QL8ORSjBDhA\r\n"
+ "gAEAOg13B6R/SAgAAAAASUVORK5CYII=";
-    }
-}
diff --git a/fineract-client/src/test/resources/michael.vorburger-crepes.jpg b/integration-tests/src/test/resources/michael.vorburger-crepes.jpg
similarity index 100%
rename from fineract-client/src/test/resources/michael.vorburger-crepes.jpg
rename to integration-tests/src/test/resources/michael.vorburger-crepes.jpg


Mime
View raw message