Search in sources :

Example 1 with CheckstyleProjectService

use of org.infernus.idea.checkstyle.CheckstyleProjectService in project checkstyle-idea by jshiell.

the class OpLoadConfigurationTest method setUp.

@Before
public void setUp() throws IOException {
    interceptApplicationNotifications();
    final ClassLoader checkstyleClassloader = new URLClassLoader(new URL[] {});
    final CheckstyleProjectService checkstyleProjectService = mock(CheckstyleProjectService.class);
    when(checkstyleProjectService.underlyingClassLoader()).thenReturn(checkstyleClassloader);
    when(configurationLocation.resolveAssociatedFile("aFileToResolve", module, checkstyleClassloader)).thenReturn("aResolvedFile");
    when(configurationLocation.resolveAssociatedFile("triggersAnIoException", module, checkstyleClassloader)).thenThrow(new IOException("aTriggeredIoException"));
    underTest = new OpLoadConfiguration(configurationLocation, null, module, checkstyleProjectService);
}
Also used : URLClassLoader(java.net.URLClassLoader) URLClassLoader(java.net.URLClassLoader) IOException(java.io.IOException) CheckstyleProjectService(org.infernus.idea.checkstyle.CheckstyleProjectService) Before(org.junit.Before)

Example 2 with CheckstyleProjectService

use of org.infernus.idea.checkstyle.CheckstyleProjectService in project checkstyle-idea by jshiell.

the class OpLoadConfigurationTest method testConstructors.

@Test
public void testConstructors() {
    final CheckstyleProjectService checkstyleProjectService = mock(CheckstyleProjectService.class);
    new OpLoadConfiguration(configurationLocation, checkstyleProjectService);
    new OpLoadConfiguration(configurationLocation, null, checkstyleProjectService);
    new OpLoadConfiguration(configurationLocation, null, module, checkstyleProjectService);
    VirtualFile virtualFile = mock(VirtualFile.class);
    new OpLoadConfiguration(virtualFile, checkstyleProjectService);
    new OpLoadConfiguration(virtualFile, null, checkstyleProjectService);
    new OpLoadConfiguration("doesn't matter", checkstyleProjectService);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CheckstyleProjectService(org.infernus.idea.checkstyle.CheckstyleProjectService) Test(org.junit.Test)

Example 3 with CheckstyleProjectService

use of org.infernus.idea.checkstyle.CheckstyleProjectService in project checkstyle-idea by jshiell.

the class ServiceLayerBasicTest method setUp.

@BeforeClass
public static void setUp() {
    PluginConfigurationManager mockPluginConfig = mock(PluginConfigurationManager.class);
    final PluginConfiguration mockConfigDto = PluginConfigurationBuilder.testInstance(currentCsVersion()).build();
    when(mockPluginConfig.getCurrent()).thenReturn(mockConfigDto);
    when(PROJECT.getService(PluginConfigurationManager.class)).thenReturn(mockPluginConfig);
    checkstyleProjectService = new CheckstyleProjectService(PROJECT);
}
Also used : PluginConfigurationManager(org.infernus.idea.checkstyle.config.PluginConfigurationManager) PluginConfiguration(org.infernus.idea.checkstyle.config.PluginConfiguration) CheckstyleProjectService(org.infernus.idea.checkstyle.CheckstyleProjectService) BeforeClass(org.junit.BeforeClass)

Example 4 with CheckstyleProjectService

use of org.infernus.idea.checkstyle.CheckstyleProjectService in project checkstyle-idea by jshiell.

the class OpLoadConfigurationTest method testNoConfiguration.

@Test
public void testNoConfiguration() {
    CheckstyleProjectService projectService = mock(CheckstyleProjectService.class);
    when(projectService.underlyingClassLoader()).thenReturn(getClass().getClassLoader());
    OpLoadConfiguration testee = new OpLoadConfiguration(configurationLocation, null, module, projectService) {

        @Override
        Configuration callLoadConfiguration(final InputStream inputStream) {
            return null;
        }
    };
    try {
        testee.execute(PROJECT);
    } catch (CheckstyleException e) {
        assertTrue(e.getMessage().contains("Couldn't find root module"));
    }
}
Also used : InputStream(java.io.InputStream) CheckstyleException(com.puppycrawl.tools.checkstyle.api.CheckstyleException) CheckstyleProjectService(org.infernus.idea.checkstyle.CheckstyleProjectService) Test(org.junit.Test)

Example 5 with CheckstyleProjectService

use of org.infernus.idea.checkstyle.CheckstyleProjectService in project checkstyle-idea by jshiell.

the class OpLoadConfigurationTest method testLoadBundledSunChecks.

@Test
public void testLoadBundledSunChecks() {
    final ConfigurationLocationFactory clf = new ConfigurationLocationFactory();
    CheckstyleProjectService projectService = mock(CheckstyleProjectService.class);
    when(projectService.underlyingClassLoader()).thenReturn(getClass().getClassLoader());
    CheckstyleInternalObject csConfig = new CheckstyleActionsImpl(PROJECT, projectService).loadConfiguration(clf.create(BundledConfig.SUN_CHECKS, mock(Project.class)), true, null);
    Assert.assertNotNull(csConfig);
}
Also used : CheckstyleActionsImpl(org.infernus.idea.checkstyle.service.CheckstyleActionsImpl) ConfigurationLocationFactory(org.infernus.idea.checkstyle.model.ConfigurationLocationFactory) CheckstyleInternalObject(org.infernus.idea.checkstyle.csapi.CheckstyleInternalObject) CheckstyleProjectService(org.infernus.idea.checkstyle.CheckstyleProjectService) Test(org.junit.Test)

Aggregations

CheckstyleProjectService (org.infernus.idea.checkstyle.CheckstyleProjectService)8 Test (org.junit.Test)5 CheckstyleInternalObject (org.infernus.idea.checkstyle.csapi.CheckstyleInternalObject)3 CheckstyleActionsImpl (org.infernus.idea.checkstyle.service.CheckstyleActionsImpl)3 PluginConfiguration (org.infernus.idea.checkstyle.config.PluginConfiguration)2 PluginConfigurationManager (org.infernus.idea.checkstyle.config.PluginConfigurationManager)2 ConfigurationLocationFactory (org.infernus.idea.checkstyle.model.ConfigurationLocationFactory)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 CheckstyleException (com.puppycrawl.tools.checkstyle.api.CheckstyleException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URLClassLoader (java.net.URLClassLoader)1 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1