Skip to content

Commit

Permalink
Add test coverage of isNonDefaultExitStatus in ExitStatusTests
Browse files Browse the repository at this point in the history
Issue #4690

Signed-off-by: Mahmoud Ben Hassine <[email protected]>
  • Loading branch information
xeounxzxu authored and fmbenhassine committed Dec 6, 2024
1 parent 39c593e commit e86bd65
Showing 1 changed file with 36 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2023 the original author or authors.
* Copyright 2006-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,14 +15,21 @@
*/
package org.springframework.batch.core;

import java.util.stream.Stream;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

import org.springframework.util.SerializationUtils;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;
import org.springframework.util.SerializationUtils;

/**
* @author Dave Syer
* @author Mahmoud Ben Hassine
Expand Down Expand Up @@ -186,4 +193,29 @@ void testSerializable() {
assertEquals(status.getExitCode(), clone.getExitCode());
}

@ParameterizedTest
@MethodSource("provideKnownExitStatuses")
public void testIsNonDefaultExitStatusShouldReturnTrue(ExitStatus status) {
boolean result = ExitStatus.isNonDefaultExitStatus(status);
assertTrue(result);
}

@ParameterizedTest
@MethodSource("provideCustomExitStatuses")
public void testIsNonDefaultExitStatusShouldReturnFalse(ExitStatus status) {
boolean result = ExitStatus.isNonDefaultExitStatus(status);
assertFalse(result);
}

private static Stream<Arguments> provideKnownExitStatuses() {
return Stream.of(Arguments.of((ExitStatus) null), Arguments.of(new ExitStatus(null)),
Arguments.of(ExitStatus.COMPLETED), Arguments.of(ExitStatus.EXECUTING), Arguments.of(ExitStatus.FAILED),
Arguments.of(ExitStatus.NOOP), Arguments.of(ExitStatus.STOPPED), Arguments.of(ExitStatus.UNKNOWN));
}

private static Stream<Arguments> provideCustomExitStatuses() {
return Stream.of(Arguments.of(new ExitStatus("CUSTOM")), Arguments.of(new ExitStatus("SUCCESS")),
Arguments.of(new ExitStatus("DONE")));
}

}

0 comments on commit e86bd65

Please sign in to comment.