Search in sources :

Example 1 with ProxyUtilities

use of au.gov.asd.tac.constellation.security.proxy.ProxyUtilities in project constellation by constellation-app.

the class StartupNGTest method runSetsTitleEnvironmentIsNull.

@Test
public void runSetsTitleEnvironmentIsNull() {
    try (final MockedStatic<WindowManager> windowManagerMockedStatic = Mockito.mockStatic(WindowManager.class);
        final MockedStatic<FontUtilities> fontUtilitiesMockedStatic = Mockito.mockStatic(FontUtilities.class);
        final MockedStatic<ProxyUtilities> proxyUtilitiesMockedStatic = Mockito.mockStatic(ProxyUtilities.class)) {
        final WindowManager windowManager = mock(WindowManager.class);
        windowManagerMockedStatic.when(WindowManager::getDefault).thenReturn(windowManager);
        doAnswer(mockInvocation -> {
            final Runnable runnable = (Runnable) mockInvocation.getArgument(0);
            final JFrame frame = mock(JFrame.class);
            when(windowManager.getMainWindow()).thenReturn(frame);
            runnable.run();
            verify(frame).setTitle("Constellation - (under development)");
            return null;
        }).when(windowManager).invokeWhenUIReady(any(Runnable.class));
        new Startup().run();
        fontUtilitiesMockedStatic.verify(FontUtilities::initialiseOutputFontPreferenceOnFirstUse);
        fontUtilitiesMockedStatic.verify(FontUtilities::initialiseApplicationFontPreferenceOnFirstUse);
        proxyUtilitiesMockedStatic.verify(() -> ProxyUtilities.setProxySelector(isNull()));
    }
}
Also used : FontUtilities(au.gov.asd.tac.constellation.utilities.font.FontUtilities) JFrame(javax.swing.JFrame) ProxyUtilities(au.gov.asd.tac.constellation.security.proxy.ProxyUtilities) WindowManager(org.openide.windows.WindowManager) Test(org.testng.annotations.Test)

Example 2 with ProxyUtilities

use of au.gov.asd.tac.constellation.security.proxy.ProxyUtilities in project constellation by constellation-app.

the class StartupNGTest method runSetsTitleEnvironmentNotNull.

@Test
public void runSetsTitleEnvironmentNotNull() {
    try (final MockedStatic<WindowManager> windowManagerMockedStatic = Mockito.mockStatic(WindowManager.class);
        final MockedStatic<FontUtilities> fontUtilitiesMockedStatic = Mockito.mockStatic(FontUtilities.class);
        final MockedStatic<ProxyUtilities> proxyUtilitiesMockedStatic = Mockito.mockStatic(ProxyUtilities.class)) {
        System.setProperty("constellation.environment", "development");
        final WindowManager windowManager = mock(WindowManager.class);
        windowManagerMockedStatic.when(WindowManager::getDefault).thenReturn(windowManager);
        doAnswer(mockInvocation -> {
            final Runnable runnable = (Runnable) mockInvocation.getArgument(0);
            final JFrame frame = mock(JFrame.class);
            when(windowManager.getMainWindow()).thenReturn(frame);
            runnable.run();
            verify(frame).setTitle("Constellation development - (under development)");
            return null;
        }).when(windowManager).invokeWhenUIReady(any(Runnable.class));
        new Startup().run();
        fontUtilitiesMockedStatic.verify(FontUtilities::initialiseOutputFontPreferenceOnFirstUse);
        fontUtilitiesMockedStatic.verify(FontUtilities::initialiseApplicationFontPreferenceOnFirstUse);
        proxyUtilitiesMockedStatic.verify(() -> ProxyUtilities.setProxySelector(isNull()));
    } finally {
        System.clearProperty("constellation.environment");
    }
}
Also used : FontUtilities(au.gov.asd.tac.constellation.utilities.font.FontUtilities) JFrame(javax.swing.JFrame) ProxyUtilities(au.gov.asd.tac.constellation.security.proxy.ProxyUtilities) WindowManager(org.openide.windows.WindowManager) Test(org.testng.annotations.Test)

Aggregations

ProxyUtilities (au.gov.asd.tac.constellation.security.proxy.ProxyUtilities)2 FontUtilities (au.gov.asd.tac.constellation.utilities.font.FontUtilities)2 JFrame (javax.swing.JFrame)2 WindowManager (org.openide.windows.WindowManager)2 Test (org.testng.annotations.Test)2