Skip to content

Commit e86bd65

Browse files
xeounxzxufmbenhassine
authored andcommitted
Add test coverage of isNonDefaultExitStatus in ExitStatusTests
Issue #4690 Signed-off-by: Mahmoud Ben Hassine <[email protected]>
1 parent 39c593e commit e86bd65

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

spring-batch-core/src/test/java/org/springframework/batch/core/ExitStatusTests.java

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2023 the original author or authors.
2+
* Copyright 2006-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,14 +15,21 @@
1515
*/
1616
package org.springframework.batch.core;
1717

18+
import java.util.stream.Stream;
19+
20+
import org.junit.jupiter.api.Test;
21+
import org.junit.jupiter.params.ParameterizedTest;
22+
import org.junit.jupiter.params.provider.Arguments;
23+
import org.junit.jupiter.params.provider.MethodSource;
24+
25+
import org.springframework.util.SerializationUtils;
26+
1827
import static org.junit.jupiter.api.Assertions.assertEquals;
28+
import static org.junit.jupiter.api.Assertions.assertFalse;
1929
import static org.junit.jupiter.api.Assertions.assertNotEquals;
2030
import static org.junit.jupiter.api.Assertions.assertNotSame;
2131
import static org.junit.jupiter.api.Assertions.assertTrue;
2232

23-
import org.junit.jupiter.api.Test;
24-
import org.springframework.util.SerializationUtils;
25-
2633
/**
2734
* @author Dave Syer
2835
* @author Mahmoud Ben Hassine
@@ -186,4 +193,29 @@ void testSerializable() {
186193
assertEquals(status.getExitCode(), clone.getExitCode());
187194
}
188195

196+
@ParameterizedTest
197+
@MethodSource("provideKnownExitStatuses")
198+
public void testIsNonDefaultExitStatusShouldReturnTrue(ExitStatus status) {
199+
boolean result = ExitStatus.isNonDefaultExitStatus(status);
200+
assertTrue(result);
201+
}
202+
203+
@ParameterizedTest
204+
@MethodSource("provideCustomExitStatuses")
205+
public void testIsNonDefaultExitStatusShouldReturnFalse(ExitStatus status) {
206+
boolean result = ExitStatus.isNonDefaultExitStatus(status);
207+
assertFalse(result);
208+
}
209+
210+
private static Stream<Arguments> provideKnownExitStatuses() {
211+
return Stream.of(Arguments.of((ExitStatus) null), Arguments.of(new ExitStatus(null)),
212+
Arguments.of(ExitStatus.COMPLETED), Arguments.of(ExitStatus.EXECUTING), Arguments.of(ExitStatus.FAILED),
213+
Arguments.of(ExitStatus.NOOP), Arguments.of(ExitStatus.STOPPED), Arguments.of(ExitStatus.UNKNOWN));
214+
}
215+
216+
private static Stream<Arguments> provideCustomExitStatuses() {
217+
return Stream.of(Arguments.of(new ExitStatus("CUSTOM")), Arguments.of(new ExitStatus("SUCCESS")),
218+
Arguments.of(new ExitStatus("DONE")));
219+
}
220+
189221
}

0 commit comments

Comments
 (0)