Search in sources :

Example 1 with ConfigurationLocationFactory

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

the class CheckStyleConfigurableTest method buildMockPanel.

private CheckStyleConfigPanel buildMockPanel(final Project mockProject) {
    CheckStyleConfigPanel mockPanel = mock(CheckStyleConfigPanel.class);
    final SortedSet<ConfigurationLocation> mockLocations = buildMockLocations(mockProject, new ConfigurationLocationFactory());
    final PluginConfiguration mockConfigDto = PluginConfigurationBuilder.testInstance("7.1.2").withLocations(mockLocations).withThirdPartyClassPath(Arrays.asList("cp1", "cp2")).withActiveLocation(mockLocations.first()).build();
    when(mockPanel.getPluginConfiguration()).thenReturn(mockConfigDto);
    return mockPanel;
}
Also used : CheckStyleConfigPanel(org.infernus.idea.checkstyle.ui.CheckStyleConfigPanel) ConfigurationLocationFactory(org.infernus.idea.checkstyle.model.ConfigurationLocationFactory) ConfigurationLocation(org.infernus.idea.checkstyle.model.ConfigurationLocation) PluginConfiguration(org.infernus.idea.checkstyle.config.PluginConfiguration)

Example 2 with ConfigurationLocationFactory

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

the class CheckStyleConfigurableTest method mockPluginConfigurationManager.

private PluginConfigurationManager mockPluginConfigurationManager(@NotNull final Project project) {
    final ConfigurationLocationFactory mockLocFactory = new ConfigurationLocationFactory();
    final SortedSet<ConfigurationLocation> mockLocations = buildMockLocations(project, mockLocFactory);
    final PluginConfiguration mockConfigDto = PluginConfigurationBuilder.testInstance("7.1.2").withLocations(mockLocations).withThirdPartyClassPath(Arrays.asList("cp1", "cp2")).withActiveLocation(mockLocations.first()).build();
    PluginConfigurationManager mockConfig = mock(PluginConfigurationManager.class);
    when(mockConfig.getCurrent()).thenReturn(mockConfigDto);
    return mockConfig;
}
Also used : ConfigurationLocationFactory(org.infernus.idea.checkstyle.model.ConfigurationLocationFactory) ConfigurationLocation(org.infernus.idea.checkstyle.model.ConfigurationLocation) PluginConfigurationManager(org.infernus.idea.checkstyle.config.PluginConfigurationManager) PluginConfiguration(org.infernus.idea.checkstyle.config.PluginConfiguration)

Example 3 with ConfigurationLocationFactory

use of org.infernus.idea.checkstyle.model.ConfigurationLocationFactory 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)

Example 4 with ConfigurationLocationFactory

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

the class OpLoadConfigurationTest method testLoadBundledGoogleChecks.

@Test
public void testLoadBundledGoogleChecks() {
    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.GOOGLE_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)

Example 5 with ConfigurationLocationFactory

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

the class CheckstylePluginApiTest method currentConfigurationCanBeVisited.

@Test
public void currentConfigurationCanBeVisited() {
    BundledConfigurationLocation googleChecks = new ConfigurationLocationFactory().create(GOOGLE_CHECKS, project);
    TreeSet<ConfigurationLocation> locations = new TreeSet<>();
    locations.add(googleChecks);
    when(pluginConfigManager.getCurrent()).thenReturn(PluginConfigurationBuilder.testInstance(CHECKSTYLE_VERSION).withLocations(locations).withActiveLocation(googleChecks).build());
    CheckstylePluginApi.ConfigurationVisitor visitor = mock(CheckstylePluginApi.ConfigurationVisitor.class);
    underTest.visitCurrentConfiguration(visitor);
    ArgumentCaptor<ConfigurationModule> configModuleCaptor = ArgumentCaptor.forClass(ConfigurationModule.class);
    verify(visitor, times(58)).accept(eq("Google Checks"), configModuleCaptor.capture());
    assertThat(configModuleCaptor.getValue(), is(not(nullValue())));
    assertThat(configModuleCaptor.getValue().getName(), is("CommentsIndentation"));
}
Also used : ConfigurationLocationFactory(org.infernus.idea.checkstyle.model.ConfigurationLocationFactory) ConfigurationLocation(org.infernus.idea.checkstyle.model.ConfigurationLocation) BundledConfigurationLocation(org.infernus.idea.checkstyle.model.BundledConfigurationLocation) TreeSet(java.util.TreeSet) BundledConfigurationLocation(org.infernus.idea.checkstyle.model.BundledConfigurationLocation) ConfigurationModule(org.infernus.idea.checkstyle.csapi.ConfigurationModule) Test(org.junit.Test)

Aggregations

ConfigurationLocationFactory (org.infernus.idea.checkstyle.model.ConfigurationLocationFactory)5 ConfigurationLocation (org.infernus.idea.checkstyle.model.ConfigurationLocation)3 Test (org.junit.Test)3 CheckstyleProjectService (org.infernus.idea.checkstyle.CheckstyleProjectService)2 PluginConfiguration (org.infernus.idea.checkstyle.config.PluginConfiguration)2 CheckstyleInternalObject (org.infernus.idea.checkstyle.csapi.CheckstyleInternalObject)2 CheckstyleActionsImpl (org.infernus.idea.checkstyle.service.CheckstyleActionsImpl)2 TreeSet (java.util.TreeSet)1 PluginConfigurationManager (org.infernus.idea.checkstyle.config.PluginConfigurationManager)1 ConfigurationModule (org.infernus.idea.checkstyle.csapi.ConfigurationModule)1 BundledConfigurationLocation (org.infernus.idea.checkstyle.model.BundledConfigurationLocation)1 CheckStyleConfigPanel (org.infernus.idea.checkstyle.ui.CheckStyleConfigPanel)1