|
1 | 1 | /*
|
2 |
| - * Copyright 2006-2023 the original author or authors. |
| 2 | + * Copyright 2006-2024 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
15 | 15 | */
|
16 | 16 | package org.springframework.batch.core;
|
17 | 17 |
|
| 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 | + |
18 | 27 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
| 28 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
19 | 29 | import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
20 | 30 | import static org.junit.jupiter.api.Assertions.assertNotSame;
|
21 | 31 | import static org.junit.jupiter.api.Assertions.assertTrue;
|
22 | 32 |
|
23 |
| -import org.junit.jupiter.api.Test; |
24 |
| -import org.springframework.util.SerializationUtils; |
25 |
| - |
26 | 33 | /**
|
27 | 34 | * @author Dave Syer
|
28 | 35 | * @author Mahmoud Ben Hassine
|
@@ -186,4 +193,29 @@ void testSerializable() {
|
186 | 193 | assertEquals(status.getExitCode(), clone.getExitCode());
|
187 | 194 | }
|
188 | 195 |
|
| 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 | + |
189 | 221 | }
|
0 commit comments