bug-66052 fix broken test

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1903816 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2022-09-01 15:44:26 +00:00
parent 0cdae64b9a
commit fe8c8eca89
2 changed files with 6 additions and 7 deletions

View File

@ -28,7 +28,6 @@ import org.apache.poi.ss.util.CellUtil;
import org.apache.poi.xssf.XSSFITestDataProvider;
import org.apache.poi.xssf.usermodel.XSSFColor;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import java.io.IOException;
@ -41,7 +40,6 @@ class TestXSSFCellUtil extends BaseTestCellUtil {
super(XSSFITestDataProvider.instance);
}
@Disabled("see bug-66052 comment 10")
@Test
public void testSetForegroundColorCellStyleProperty() throws IOException, DecoderException {
try (Workbook workbook = new XSSFWorkbook()) {

View File

@ -23,6 +23,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import org.apache.logging.log4j.LogManager;
@ -415,16 +416,16 @@ public final class CellUtil {
cell.setCellStyle(newStyle);
}
private static boolean styleMapsMatch(final Map<String, Object> map1, final Map<String, Object> map2) {
final Map<String, Object> map1Copy = new HashMap<>(map1);
final Map<String, Object> map2Copy = new HashMap<>(map2);
private static boolean styleMapsMatch(final Map<String, Object> newProps, final Map<String, Object> storedProps) {
final Map<String, Object> map1Copy = new HashMap<>(newProps);
final Map<String, Object> map2Copy = new HashMap<>(storedProps);
final Object backColor1 = map1Copy.remove(FILL_BACKGROUND_COLOR_COLOR);
final Object backColor2 = map2Copy.remove(FILL_BACKGROUND_COLOR_COLOR);
final Object foreColor1 = map1Copy.remove(FILL_FOREGROUND_COLOR_COLOR);
final Object foreColor2 = map2Copy.remove(FILL_FOREGROUND_COLOR_COLOR);
if (map1Copy.equals(map2Copy)) {
final boolean backColorsMatch = backColor1 == null || backColor2 == null || backColor1.equals(backColor2);
final boolean foreColorsMatch = foreColor1 == null || foreColor2 == null || foreColor1.equals(foreColor2);
final boolean backColorsMatch = backColor2 == null || Objects.equals(backColor1, backColor2);
final boolean foreColorsMatch = foreColor2 == null || Objects.equals(foreColor1, foreColor2);
return backColorsMatch && foreColorsMatch;
}
return false;