From 62d4d04ff472505f2ce54d43abb59d96306f5c6f Mon Sep 17 00:00:00 2001 From: Barry Zou Date: Thu, 3 Jul 2025 13:48:43 -0700 Subject: [PATCH] Test --- build.gradle | 7 ++- .../com/squareup/square/core/FileStream.java | 6 +-- .../square/core/InputStreamRequestBody.java | 3 +- .../square/core/SquareApiException.java | 12 ++--- .../square/integration/LaborTest.java | 53 ++++++++++--------- 5 files changed, 40 insertions(+), 41 deletions(-) diff --git a/build.gradle b/build.gradle index defa40c1..2cb814bb 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ plugins { id 'java-library' id 'maven-publish' - id 'com.diffplug.spotless' version '6.11.0' + id 'com.diffplug.spotless' version '6.25.0' id 'signing' id 'cl.franciscosolis.sonatype-central-upload' version '1.0.3' } @@ -33,7 +33,10 @@ tasks.withType(Javadoc) { spotless { java { - palantirJavaFormat() + importOrder() + removeUnusedImports() + palantirJavaFormat('2.40.0') + formatAnnotations() } } diff --git a/src/main/java/com/squareup/square/core/FileStream.java b/src/main/java/com/squareup/square/core/FileStream.java index bf60e64f..ec2d373c 100644 --- a/src/main/java/com/squareup/square/core/FileStream.java +++ b/src/main/java/com/squareup/square/core/FileStream.java @@ -39,13 +39,11 @@ public InputStream getInputStream() { return inputStream; } - @Nullable - public String getFileName() { + @Nullable public String getFileName() { return fileName; } - @Nullable - public MediaType getContentType() { + @Nullable public MediaType getContentType() { return contentType; } diff --git a/src/main/java/com/squareup/square/core/InputStreamRequestBody.java b/src/main/java/com/squareup/square/core/InputStreamRequestBody.java index 1d6a770b..b2798376 100644 --- a/src/main/java/com/squareup/square/core/InputStreamRequestBody.java +++ b/src/main/java/com/squareup/square/core/InputStreamRequestBody.java @@ -40,8 +40,7 @@ public InputStreamRequestBody(@Nullable MediaType contentType, InputStream input * * @return the MediaType of the content, or null if not specified */ - @Nullable - @Override + @Nullable @Override public MediaType contentType() { return contentType; } diff --git a/src/main/java/com/squareup/square/core/SquareApiException.java b/src/main/java/com/squareup/square/core/SquareApiException.java index ace2a61a..a729c690 100644 --- a/src/main/java/com/squareup/square/core/SquareApiException.java +++ b/src/main/java/com/squareup/square/core/SquareApiException.java @@ -3,18 +3,16 @@ */ package com.squareup.square.core; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; - import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.squareup.square.types.Error; import com.squareup.square.types.ErrorCategory; import com.squareup.square.types.ErrorCode; - +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; import okhttp3.Response; /** diff --git a/src/test/java/com/squareup/square/integration/LaborTest.java b/src/test/java/com/squareup/square/integration/LaborTest.java index 4c06704a..67266016 100644 --- a/src/test/java/com/squareup/square/integration/LaborTest.java +++ b/src/test/java/com/squareup/square/integration/LaborTest.java @@ -12,11 +12,6 @@ import com.squareup.square.labor.types.SearchShiftsRequest; import com.squareup.square.labor.types.UpdateBreakTypeRequest; import com.squareup.square.labor.types.UpdateShiftRequest; -import com.squareup.square.types.Location; -import com.squareup.square.types.SearchTeamMembersRequest; -import com.squareup.square.types.SearchTeamMembersQuery; -import com.squareup.square.types.SearchTeamMembersFilter; -import com.squareup.square.types.TeamMemberStatus; import com.squareup.square.types.BreakType; import com.squareup.square.types.CreateBreakTypeResponse; import com.squareup.square.types.CreateShiftResponse; @@ -24,14 +19,18 @@ import com.squareup.square.types.DeleteShiftResponse; import com.squareup.square.types.GetBreakTypeResponse; import com.squareup.square.types.GetShiftResponse; +import com.squareup.square.types.Location; import com.squareup.square.types.SearchShiftsResponse; +import com.squareup.square.types.SearchTeamMembersFilter; +import com.squareup.square.types.SearchTeamMembersQuery; +import com.squareup.square.types.SearchTeamMembersRequest; import com.squareup.square.types.Shift; import com.squareup.square.types.ShiftWage; import com.squareup.square.types.TeamMember; +import com.squareup.square.types.TeamMemberStatus; import com.squareup.square.types.UpdateBreakTypeResponse; import com.squareup.square.types.UpdateShiftResponse; import com.squareup.square.types.WorkweekConfig; - import java.time.OffsetDateTime; import java.time.format.DateTimeFormatter; import java.util.Collections; @@ -53,28 +52,30 @@ public class LaborTest { @BeforeEach public void before() { client = TestClientFactory.create(); - + // Get first available location - List locations = client.locations().list().getLocations() - .orElseThrow(() -> new RuntimeException("No locations available")); + List locations = client.locations() + .list() + .getLocations() + .orElseThrow(() -> new RuntimeException("No locations available")); if (locations.isEmpty()) { throw new RuntimeException("No locations available for testing"); } locationId = locations.get(0).getId().orElseThrow(() -> new RuntimeException("Location ID not present")); - + // Get first available team member at this location - List teamMembers = client.teamMembers().search( - SearchTeamMembersRequest.builder() - .query(SearchTeamMembersQuery.builder() - .filter(SearchTeamMembersFilter.builder() - .locationIds(Collections.singletonList(locationId)) - .status(TeamMemberStatus.ACTIVE) + List teamMembers = client.teamMembers() + .search(SearchTeamMembersRequest.builder() + .query(SearchTeamMembersQuery.builder() + .filter(SearchTeamMembersFilter.builder() + .locationIds(Collections.singletonList(locationId)) + .status(TeamMemberStatus.ACTIVE) + .build()) + .build()) .build()) - .build()) - .build() - ).getTeamMembers() - .orElseThrow(() -> new RuntimeException("Failed to get team members")); - + .getTeamMembers() + .orElseThrow(() -> new RuntimeException("Failed to get team members")); + if (teamMembers.isEmpty()) { throw new RuntimeException("No team members available at location " + locationId); } @@ -238,9 +239,7 @@ public void testDeleteShift() throws Exception { .limit(100) .build(); - SearchShiftsResponse existingShifts = client.labor() - .shifts() - .search(searchRequest); + SearchShiftsResponse existingShifts = client.labor().shifts().search(searchRequest); // Delete any existing shifts if (existingShifts.getShifts().isPresent()) { @@ -248,7 +247,9 @@ public void testDeleteShift() throws Exception { if (existingShift.getId().isPresent()) { client.labor() .shifts() - .delete(DeleteShiftsRequest.builder().id(existingShift.getId().get()).build()); + .delete(DeleteShiftsRequest.builder() + .id(existingShift.getId().get()) + .build()); } } } @@ -336,4 +337,4 @@ public void testListWorkweekConfigs() { .list(ListWorkweekConfigsRequest.builder().build()); Assertions.assertFalse(response.getItems().isEmpty()); } -} \ No newline at end of file +}