Skip to content

Commit 28c02f6

Browse files
committed
lint
1 parent 4f808af commit 28c02f6

9 files changed

Lines changed: 51 additions & 58 deletions

src/main/java/com/coveo/pushapiclient/CatalogStreamUploadHandler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ public HttpResponse<String> uploadAndPush(StreamUpdate stream)
2626

2727
// Step 2: Upload content to container
2828
String batchUpdateJson = new Gson().toJson(stream.marshal());
29-
logger.debug(
30-
"Uploading stream content to file container: {}", container.fileId);
29+
logger.debug("Uploading stream content to file container: {}", container.fileId);
3130
platformClient.uploadContentToFileContainer(container, batchUpdateJson);
3231

3332
// Step 3: Push container to stream source

src/main/java/com/coveo/pushapiclient/StreamDocumentUploadQueue.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public boolean isEmpty() {
9090

9191
/**
9292
* Returns the HTTP response from the last flush operation.
93+
*
9394
* @return The last response, or null if no flush has occurred or queue was empty.
9495
*/
9596
HttpResponse<String> getLastResponse() {

src/main/java/com/coveo/pushapiclient/StreamUploadHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Functional interface for stream upload operations with a three-step workflow contract.
88
*
99
* <p>Implementations of this interface handle the complete stream upload workflow:
10+
*
1011
* <ol>
1112
* <li>Create a file container via {@code platformClient.createFileContainer()}
1213
* <li>Upload content to the container via {@code platformClient.uploadContentToFileContainer()}

src/main/java/com/coveo/pushapiclient/UpdateStreamService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ public class UpdateStreamService {
1111
private final PlatformClient platformClient;
1212
private final UpdateStreamServiceInternal updateStreamServiceInternal;
1313

14-
1514
/**
1615
* Creates a service to stream your documents to the provided source by interacting with the
1716
* Stream API. This provides the ability to incrementally add, update, or delete documents via a

src/main/java/com/coveo/pushapiclient/UpdateStreamServiceInternal.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ public UpdateStreamServiceInternal(
1717
this.queue = queue;
1818
}
1919

20-
public void addOrUpdate(DocumentBuilder document)
21-
throws IOException, InterruptedException {
20+
public void addOrUpdate(DocumentBuilder document) throws IOException, InterruptedException {
2221
queue.add(document);
2322
}
2423

src/test/java/com/coveo/pushapiclient/CatalogStreamUploadHandlerTest.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
package com.coveo.pushapiclient;
22

3-
import static org.junit.Assert.*;
4-
import static org.mockito.ArgumentMatchers.*;
5-
import static org.mockito.Mockito.*;
3+
import static org.junit.Assert.assertEquals;
4+
import static org.junit.Assert.assertSame;
5+
import static org.mockito.ArgumentMatchers.any;
6+
import static org.mockito.ArgumentMatchers.anyString;
7+
import static org.mockito.ArgumentMatchers.eq;
8+
import static org.mockito.Mockito.inOrder;
9+
import static org.mockito.Mockito.when;
610

711
import com.google.gson.JsonObject;
812
import java.io.IOException;
@@ -42,8 +46,7 @@ public void uploadAndPushShouldExecute3StepWorkflowInOrder()
4246
when(mockContainerResponse.body()).thenReturn("{\"fileId\":\"test-container-id\"}");
4347
when(mockPlatformClient.createFileContainer()).thenReturn(mockContainerResponse);
4448
StreamUpdateRecord mockRecord =
45-
new StreamUpdateRecord(
46-
new JsonObject[] {}, new JsonObject[] {}, new JsonObject[] {});
49+
new StreamUpdateRecord(new JsonObject[] {}, new JsonObject[] {}, new JsonObject[] {});
4750
when(mockStreamUpdate.marshal()).thenReturn(mockRecord);
4851
when(mockPlatformClient.pushFileContainerContentToStreamSource(
4952
anyString(), any(FileContainer.class)))
@@ -53,21 +56,21 @@ public void uploadAndPushShouldExecute3StepWorkflowInOrder()
5356

5457
InOrder inOrder = inOrder(mockPlatformClient);
5558
inOrder.verify(mockPlatformClient).createFileContainer();
56-
inOrder.verify(mockPlatformClient)
59+
inOrder
60+
.verify(mockPlatformClient)
5761
.uploadContentToFileContainer(any(FileContainer.class), anyString());
58-
inOrder.verify(mockPlatformClient)
62+
inOrder
63+
.verify(mockPlatformClient)
5964
.pushFileContainerContentToStreamSource(eq("test-source-id"), any(FileContainer.class));
6065
assertEquals(mockPushResponse, result);
6166
}
6267

6368
@Test
64-
public void uploadAndPushShouldReturnPushResponse()
65-
throws IOException, InterruptedException {
69+
public void uploadAndPushShouldReturnPushResponse() throws IOException, InterruptedException {
6670
when(mockContainerResponse.body()).thenReturn("{\"fileId\":\"test-id\"}");
6771
when(mockPlatformClient.createFileContainer()).thenReturn(mockContainerResponse);
6872
StreamUpdateRecord mockRecord =
69-
new StreamUpdateRecord(
70-
new JsonObject[] {}, new JsonObject[] {}, new JsonObject[] {});
73+
new StreamUpdateRecord(new JsonObject[] {}, new JsonObject[] {}, new JsonObject[] {});
7174
when(mockStreamUpdate.marshal()).thenReturn(mockRecord);
7275
when(mockPlatformClient.pushFileContainerContentToStreamSource(
7376
anyString(), any(FileContainer.class)))
@@ -81,7 +84,8 @@ public void uploadAndPushShouldReturnPushResponse()
8184
@Test(expected = IOException.class)
8285
public void uploadAndPushShouldPropagateIOExceptionFromCreateFileContainer()
8386
throws IOException, InterruptedException {
84-
when(mockPlatformClient.createFileContainer()).thenThrow(new IOException("Container creation failed"));
87+
when(mockPlatformClient.createFileContainer())
88+
.thenThrow(new IOException("Container creation failed"));
8589

8690
handler.uploadAndPush(mockStreamUpdate);
8791
}
@@ -92,11 +96,9 @@ public void uploadAndPushShouldPropagateIOExceptionFromUploadContent()
9296
when(mockContainerResponse.body()).thenReturn("{\"fileId\":\"test-id\"}");
9397
when(mockPlatformClient.createFileContainer()).thenReturn(mockContainerResponse);
9498
StreamUpdateRecord mockRecord =
95-
new StreamUpdateRecord(
96-
new JsonObject[] {}, new JsonObject[] {}, new JsonObject[] {});
99+
new StreamUpdateRecord(new JsonObject[] {}, new JsonObject[] {}, new JsonObject[] {});
97100
when(mockStreamUpdate.marshal()).thenReturn(mockRecord);
98-
when(mockPlatformClient.uploadContentToFileContainer(
99-
any(FileContainer.class), anyString()))
101+
when(mockPlatformClient.uploadContentToFileContainer(any(FileContainer.class), anyString()))
100102
.thenThrow(new IOException("Upload failed"));
101103

102104
handler.uploadAndPush(mockStreamUpdate);
@@ -108,8 +110,7 @@ public void uploadAndPushShouldPropagateIOExceptionFromPush()
108110
when(mockContainerResponse.body()).thenReturn("{\"fileId\":\"test-id\"}");
109111
when(mockPlatformClient.createFileContainer()).thenReturn(mockContainerResponse);
110112
StreamUpdateRecord mockRecord =
111-
new StreamUpdateRecord(
112-
new JsonObject[] {}, new JsonObject[] {}, new JsonObject[] {});
113+
new StreamUpdateRecord(new JsonObject[] {}, new JsonObject[] {}, new JsonObject[] {});
113114
when(mockStreamUpdate.marshal()).thenReturn(mockRecord);
114115
when(mockPlatformClient.pushFileContainerContentToStreamSource(
115116
anyString(), any(FileContainer.class)))

src/test/java/com/coveo/pushapiclient/FileContainerRotationIntegrationTest.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,7 @@ public void shouldNeverPushMultipleBatchesToSameContainer() throws Exception {
198198
}
199199

200200
private UpdateStreamServiceInternal createServiceWithSmallBatchSize() {
201-
CatalogStreamUploadHandler handler =
202-
new CatalogStreamUploadHandler(source, platformClient);
201+
CatalogStreamUploadHandler handler = new CatalogStreamUploadHandler(source, platformClient);
203202
StreamDocumentUploadQueue queue = new StreamDocumentUploadQueue(handler, SMALL_BATCH_SIZE);
204203
org.apache.logging.log4j.Logger logger =
205204
org.apache.logging.log4j.LogManager.getLogger(getClass());
@@ -231,12 +230,12 @@ private String generateData(int size) {
231230
private HttpResponse<String> createContainerResponse() {
232231
HttpResponse<String> response = mock(HttpResponse.class);
233232
int id = containerCounter.incrementAndGet();
234-
doReturn(
235-
String.format(
236-
"{\"uploadUri\": \"https://upload.uri/container-%d\", \"fileId\": \"container-%d\"}",
237-
id, id))
238-
.when(response)
239-
.body();
233+
String responseBody =
234+
String.format(
235+
"{\"uploadUri\": \"https://upload.uri/container-%d\", "
236+
+ "\"fileId\": \"container-%d\"}",
237+
id, id);
238+
doReturn(responseBody).when(response).body();
240239
return response;
241240
}
242241

src/test/java/com/coveo/pushapiclient/StreamDocumentUploadQueueTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public void testShouldAutomaticallyFlushAccumulatedDocuments()
162162
}
163163
});
164164

165-
// Adding 3 documents of 2MB to the queue. After adding the first 2 documents,
165+
// Adding 3 documents of 2MB to the queue. After adding the first 2 documents,
166166
// the queue size will reach 6MB, which exceeds the maximum queue size
167167
// limit by 1MB. Therefore, the 2 first added documents will automatically be
168168
// uploaded to the source.
@@ -236,7 +236,7 @@ public void testAddingEmptyDocument() throws IOException, InterruptedException {
236236

237237
queue.add(nullDocument);
238238
queue.flush();
239-
239+
240240
verify(mockHandler, times(0)).uploadAndPush(any(StreamUpdate.class));
241241
}
242242

src/test/java/com/coveo/pushapiclient/UpdateStreamServiceInternalTest.java

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.coveo.pushapiclient;
22

33
import static org.junit.Assert.assertEquals;
4-
import static org.mockito.ArgumentMatchers.any;
5-
import static org.mockito.ArgumentMatchers.eq;
64
import static org.mockito.Mockito.times;
75
import static org.mockito.Mockito.verify;
86
import static org.mockito.Mockito.when;
@@ -21,19 +19,13 @@
2119
public class UpdateStreamServiceInternalTest {
2220

2321
private static final String SOURCE_ID = "my-source-id";
24-
@Mock
25-
private StreamEnabledSource source;
26-
@Mock
27-
private PlatformClient platformClient;
28-
@Mock
29-
private StreamDocumentUploadQueue queue;
30-
@Mock
31-
private HttpResponse<String> httpResponse;
32-
@Mock
33-
private Logger logger;
34-
35-
@InjectMocks
36-
private UpdateStreamServiceInternal service;
22+
@Mock private StreamEnabledSource source;
23+
@Mock private PlatformClient platformClient;
24+
@Mock private StreamDocumentUploadQueue queue;
25+
@Mock private HttpResponse<String> httpResponse;
26+
@Mock private Logger logger;
27+
28+
@InjectMocks private UpdateStreamServiceInternal service;
3729

3830
private DocumentBuilder documentA;
3931
private DocumentBuilder documentB;
@@ -50,16 +42,18 @@ public void setUp() throws Exception {
5042
documentB = new DocumentBuilder("https://my.document.uri?ref=2", "My second document title");
5143
deleteDocumentA = new DeleteDocument("https://my.document.uri?ref=3");
5244
deleteDocumentB = new DeleteDocument("https://my.document.uri?ref=4");
53-
partialUpdateDocumentA = new PartialUpdateDocument(
54-
"https://my.document.uri?ref=5",
55-
PartialUpdateOperator.FIELDVALUEREPLACE,
56-
"fieldA",
57-
"valueA");
58-
partialUpdateDocumentB = new PartialUpdateDocument(
59-
"https://my.document.uri?ref=6",
60-
PartialUpdateOperator.FIELDVALUEREPLACE,
61-
"fieldB",
62-
"valueB");
45+
partialUpdateDocumentA =
46+
new PartialUpdateDocument(
47+
"https://my.document.uri?ref=5",
48+
PartialUpdateOperator.FIELDVALUEREPLACE,
49+
"fieldA",
50+
"valueA");
51+
partialUpdateDocumentB =
52+
new PartialUpdateDocument(
53+
"https://my.document.uri?ref=6",
54+
PartialUpdateOperator.FIELDVALUEREPLACE,
55+
"fieldB",
56+
"valueB");
6357

6458
closeable = MockitoAnnotations.openMocks(this);
6559

0 commit comments

Comments
 (0)