/** Tests the execute method. */ @Test public void testExecuteError() { final List<String> arguments = Arrays.asList("a", "b"); final String messageKey = "error.config"; final String messageValue = "message-value"; final IStatus status = new Status(IStatus.ERROR, "a", messageKey); final ITextAccessor textAccessor = EasyMock.createMock(ITextAccessor.class); EasyMock.expect(textAccessor.getText(messageKey)).andReturn(messageValue); EasyMock.replay(textAccessor); final ILog log = new ILog() { @Override public void removeLogListener(ILogListener listener) { // nop } @Override public void log(IStatus status) { // nop } @Override public Bundle getBundle() { return null; } @Override public void addLogListener(ILogListener listener) { // nop } }; final String pluginId = "plugin"; TestProjectConfigurationCommand command = new TestProjectConfigurationCommand(arguments, textAccessor, pluginId, log, status); final IProject project = EasyMock.createMock(IProject.class); EasyMock.replay(project); List<IProject> projects = Arrays.asList(project); IStatus result = command.execute(projects); assertNotNull(result); assertEquals(IStatus.WARNING, result.getSeverity()); }
/** Tests the createStatus methods. */ @Test public void testCreateStatus() { final List<String> arguments = Arrays.asList("a", "b"); final String messageKey = "message-key"; final String messageValue = "message-value"; final ITextAccessor textAccessor = EasyMock.createMock(ITextAccessor.class); EasyMock.expect(textAccessor.getText(messageKey)).andReturn(messageValue); EasyMock.replay(textAccessor); final ILog log = EasyMock.createMock(ILog.class); EasyMock.replay(log); final String pluginId = "plugin"; TestProjectConfigurationCommand command = new TestProjectConfigurationCommand( arguments, textAccessor, pluginId, log, Status.OK_STATUS); IStatus status = command.createStatus(IStatus.ERROR, messageKey); assertNotNull(status); assertEquals(pluginId, status.getPlugin()); assertEquals(IStatus.ERROR, status.getSeverity()); assertEquals(messageValue, status.getMessage()); }