in plugin/tst/software/aws/toolkits/eclipse/amazonq/util/QInvocationSessionTest.java [82:125]
public static void setUp() throws Exception {
prefMockStatic = mockStatic(Platform.class, RETURNS_DEEP_STUBS);
Preferences prefMock = mock(Preferences.class);
prefMockStatic.when(() -> Platform.getPreferencesService().getRootNode().node(anyString()).node(anyString())).thenReturn(prefMock);
when(prefMock.getBoolean(anyString(), any(Boolean.class))).thenReturn(true);
when(prefMock.getInt(anyString(), any(Integer.class))).thenReturn(4);
platformUIMockStatic = mockStatic(PlatformUI.class);
IWorkbench wbMock = mock(IWorkbench.class);
platformUIMockStatic.when(PlatformUI::getWorkbench).thenReturn(wbMock);
editorUtilsMock = mockQEclipseEditorUtils();
mockContextService = mock(IContextService.class);
mockContextActivation = mock(IContextActivation.class);
when(wbMock.getService(IContextService.class)).thenReturn(mockContextService);
when(mockContextService.activateContext(anyString())).thenReturn(mockContextActivation);
doNothing().when(mockContextService).deactivateContext(mockContextActivation);
Set<String> activeContexts = Set.of();
when(mockContextService.getActiveContextIds()).thenReturn(activeContexts);
activatorMockStatic = mockStatic(Activator.class);
DefaultLoginService loginSerivceMock = mock(DefaultLoginService.class, RETURNS_DEEP_STUBS);
LoggingService loggingServiceMock = mock(LoggingService.class);
activatorMockStatic.when(Activator::getLoginService).thenReturn(loginSerivceMock);
activatorMockStatic.when(Activator::getLogger).thenReturn(loggingServiceMock);
when(loginSerivceMock.getAuthState().isLoggedIn()).thenReturn(true);
displayMockStatic = mockStatic(Display.class);
Display displayMock = mock(Display.class);
displayMockStatic.when(Display::getDefault).thenReturn(displayMock);
doAnswer(new Answer<Void>() {
@Override
public Void answer(final InvocationOnMock invocation) throws Throwable {
Runnable runnable = invocation.getArgument(0);
runnable.run();
return null;
}
}).when(displayMock).asyncExec(any(Runnable.class));
when(POTENT_PARAM.getContext().getTriggerKind()).thenReturn(InlineCompletionTriggerKind.Automatic);
when(IMPOTENT_PARAM.getContext().getTriggerKind()).thenReturn(InlineCompletionTriggerKind.Automatic);
}