From e705f918ced413e4c532793b9c13e5a93523f7cc Mon Sep 17 00:00:00 2001 From: Patrick Hobusch Date: Tue, 19 Mar 2024 17:29:40 +0800 Subject: [PATCH] Upgrade Jira version to 9.12.5 (LTS) --- pom.xml | 2 +- .../service/SettingsBrandingServiceTest.java | 52 ++++++++++--------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/pom.xml b/pom.xml index bd740cc..eabc655 100644 --- a/pom.xml +++ b/pom.xml @@ -53,7 +53,7 @@ - 8.15.0 + 9.12.5 8.12.1 8209 diff --git a/src/test/java/de/aservo/confapi/jira/service/SettingsBrandingServiceTest.java b/src/test/java/de/aservo/confapi/jira/service/SettingsBrandingServiceTest.java index e7d807a..cd02d57 100644 --- a/src/test/java/de/aservo/confapi/jira/service/SettingsBrandingServiceTest.java +++ b/src/test/java/de/aservo/confapi/jira/service/SettingsBrandingServiceTest.java @@ -5,6 +5,7 @@ import com.atlassian.jira.config.properties.ApplicationProperties; import com.atlassian.jira.config.properties.LnFDefaultColorProvider; import com.atlassian.jira.config.properties.LogoProvider; +import com.atlassian.jira.config.properties.UiSettingsStateManager; import com.atlassian.jira.config.util.JiraHome; import com.atlassian.jira.lookandfeel.LogoChoice; import com.atlassian.jira.lookandfeel.LookAndFeelProperties; @@ -20,12 +21,13 @@ import org.mockito.MockedStatic; import org.mockito.junit.jupiter.MockitoExtension; -import java.io.ByteArrayInputStream; +import java.io.IOException; import java.io.InputStream; import java.util.Map; import static de.aservo.confapi.jira.model.util.SettingsColourSchemeBeanUtilTest.getDummyBaseColourScheme; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) @@ -86,18 +88,19 @@ void testGetLogo() { } @Test - void testSetLogo() { - InputStream is = new ByteArrayInputStream("".getBytes()); - - try (MockedStatic componentAccessorMockedStatic = mockStatic(ComponentAccessor.class)) { - componentAccessorMockedStatic.when(() -> ComponentAccessor.getComponent(LnFDefaultColorProvider.class)).thenReturn(mock(LnFDefaultColorProvider.class)); - componentAccessorMockedStatic.when(() -> ComponentAccessor.getComponent(LogoProvider.class)).thenReturn(mock(LogoProvider.class)); - componentAccessorMockedStatic.when(() -> ComponentAccessor.getComponent(EventPublisher.class)).thenReturn(mock(EventPublisher.class)); - - settingsBrandingService.setLogo(is); + void testSetLogo() throws IOException { + try (InputStream is = getClass().getClassLoader().getResourceAsStream("images/plugin-icon.png")) { + try (MockedStatic componentAccessorMockedStatic = mockStatic(ComponentAccessor.class)) { + componentAccessorMockedStatic.when(() -> ComponentAccessor.getComponent(LnFDefaultColorProvider.class)).thenReturn(mock(LnFDefaultColorProvider.class)); + componentAccessorMockedStatic.when(() -> ComponentAccessor.getComponent(LogoProvider.class)).thenReturn(mock(LogoProvider.class)); + componentAccessorMockedStatic.when(() -> ComponentAccessor.getComponent(EventPublisher.class)).thenReturn(mock(EventPublisher.class)); + componentAccessorMockedStatic.when(() -> ComponentAccessor.getComponent(UiSettingsStateManager.class)).thenReturn(mock(UiSettingsStateManager.class)); + + settingsBrandingService.setLogo(is); + } + + verify(lookAndFeelProperties).setLogoChoice(LogoChoice.UPLOAD); } - - verify(lookAndFeelProperties).setLogoChoice(LogoChoice.UPLOAD); } //InternalServerErrorException -> FileNotFoundException is expected because no logofile is present in the filesystem at test time @@ -109,17 +112,18 @@ void testGetFavicon() { } @Test - void testSetFavicon() { - final InputStream is = new ByteArrayInputStream("".getBytes()); - - try (MockedStatic componentAccessorMockedStatic = mockStatic(ComponentAccessor.class)) { - componentAccessorMockedStatic.when(() -> ComponentAccessor.getComponent(LnFDefaultColorProvider.class)).thenReturn(mock(LnFDefaultColorProvider.class)); - componentAccessorMockedStatic.when(() -> ComponentAccessor.getComponent(LogoProvider.class)).thenReturn(mock(LogoProvider.class)); - componentAccessorMockedStatic.when(() -> ComponentAccessor.getComponent(EventPublisher.class)).thenReturn(mock(EventPublisher.class)); - - settingsBrandingService.setFavicon(is); + void testSetFavicon() throws IOException { + try (InputStream is = getClass().getClassLoader().getResourceAsStream("images/plugin-icon.png")) { + try (MockedStatic componentAccessorMockedStatic = mockStatic(ComponentAccessor.class)) { + componentAccessorMockedStatic.when(() -> ComponentAccessor.getComponent(LnFDefaultColorProvider.class)).thenReturn(mock(LnFDefaultColorProvider.class)); + componentAccessorMockedStatic.when(() -> ComponentAccessor.getComponent(LogoProvider.class)).thenReturn(mock(LogoProvider.class)); + componentAccessorMockedStatic.when(() -> ComponentAccessor.getComponent(EventPublisher.class)).thenReturn(mock(EventPublisher.class)); + componentAccessorMockedStatic.when(() -> ComponentAccessor.getComponent(UiSettingsStateManager.class)).thenReturn(mock(UiSettingsStateManager.class)); + + settingsBrandingService.setFavicon(is); + } + + verify(lookAndFeelProperties).setFaviconChoice(LogoChoice.UPLOAD); } - - verify(lookAndFeelProperties).setFaviconChoice(LogoChoice.UPLOAD); } }