Skip to content

Commit 4b10c44

Browse files
committed
Renaming enum cases
1 parent 3aebaa9 commit 4b10c44

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/Storage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private ReadableResult readAndProcess(Function<byte[], ProcessResult> processing
104104
ReadableResult result = readableFile.readAndProcess(processing);
105105
switch (result) {
106106
case SUCCEEDED:
107-
case PROCESSING_FAILED:
107+
case TRY_LATER:
108108
return result;
109109
default:
110110
// Retry with new file

disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/files/ReadableFile.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ public synchronized ReadableResult readAndProcess(Function<byte[], ProcessResult
111111
return ReadableResult.SUCCEEDED;
112112
case TRY_LATER:
113113
unconsumedResult = read;
114-
return ReadableResult.PROCESSING_FAILED;
114+
return ReadableResult.TRY_LATER;
115115
case CONTENT_INVALID:
116116
cleanUp();
117-
return ReadableResult.PROCESSING_FAILED;
117+
return ReadableResult.FAILED;
118118
}
119119
return ReadableResult.FAILED;
120120
}

disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/responses/ReadableResult.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
public enum ReadableResult {
99
SUCCEEDED,
1010
FAILED,
11-
PROCESSING_FAILED
11+
TRY_LATER
1212
}

disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/storage/StorageTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
package io.opentelemetry.contrib.disk.buffering.internal.storage;
77

8-
import static io.opentelemetry.contrib.disk.buffering.internal.storage.responses.ReadableResult.PROCESSING_FAILED;
8+
import static io.opentelemetry.contrib.disk.buffering.internal.storage.responses.ReadableResult.TRY_LATER;
99
import static org.junit.jupiter.api.Assertions.assertEquals;
1010
import static org.junit.jupiter.api.Assertions.assertFalse;
1111
import static org.mockito.ArgumentMatchers.any;
@@ -53,11 +53,11 @@ void whenReadingAndProcessingSuccessfully_returnSuccess() throws IOException {
5353
}
5454

5555
@Test
56-
void whenReadableFileProcessingFails_returnFailed() throws IOException {
56+
void whenReadableFileProcessingFails_returnTryLater() throws IOException {
5757
when(folderManager.getReadableFile()).thenReturn(readableFile);
58-
when(readableFile.readAndProcess(processing)).thenReturn(PROCESSING_FAILED);
58+
when(readableFile.readAndProcess(processing)).thenReturn(TRY_LATER);
5959

60-
assertEquals(PROCESSING_FAILED, storage.readAndProcess(processing));
60+
assertEquals(TRY_LATER, storage.readAndProcess(processing));
6161

6262
verify(readableFile).readAndProcess(processing);
6363
}

disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/storage/files/ReadableFileTest.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ void whenProcessingSucceeds_returnSuccessStatus() throws IOException {
138138
}
139139

140140
@Test
141-
void whenProcessingFails_returnProcessFailedStatus() throws IOException {
141+
void whenProcessingFails_returnTryLaterStatus() throws IOException {
142142
assertEquals(
143-
ReadableResult.PROCESSING_FAILED,
143+
ReadableResult.TRY_LATER,
144144
readableFile.readAndProcess(bytes -> ProcessResult.TRY_LATER));
145145
}
146146

@@ -180,6 +180,15 @@ void whenReadingLastLine_deleteOriginalFile_and_close() throws IOException {
180180
assertTrue(readableFile.isClosed());
181181
}
182182

183+
@Test
184+
void whenTheFileContentIsInvalid_deleteOriginalFile_and_close() throws IOException {
185+
assertEquals(
186+
ReadableResult.FAILED, readableFile.readAndProcess(bytes -> ProcessResult.CONTENT_INVALID));
187+
188+
assertFalse(source.exists());
189+
assertTrue(readableFile.isClosed());
190+
}
191+
183192
@Test
184193
void whenNoMoreLinesAvailableToRead_deleteOriginalFile_close_and_returnNoContentStatus()
185194
throws IOException {

0 commit comments

Comments
 (0)