Search in sources :

Example 6 with IPluginElement

use of org.eclipse.pde.core.plugin.IPluginElement in project dsl-devkit by dsldevkit.

the class CheckMarkerHelpExtensionTest method testMarkerTypeUpdate.

/**
 * Tests if the marker type attribute is updated if the trigger kind changes for a check.
 *
 * @throws Exception
 *           the exception
 */
@Test
public void testMarkerTypeUpdate() throws Exception {
    IPluginExtension extension = createMarkerHelpExtension(parser.parse(CATALOG_WITH_FIRST_CHECK_LIVE));
    assertEquals("Before update: Markertype is fast.", MARKERTYPE_FAST, ((IPluginElement) extension.getChildren()[0]).getAttribute(CheckMarkerHelpExtensionHelper.MARKERTYPE_ATTRIBUTE_TAG).getValue());
    CheckCatalog updateMarkertype = parser.parse(CATALOG_WITH_FIRST_CHECK_ONDEMAND);
    markerUtil.updateExtension(updateMarkertype, extension);
    assertEquals("After update: Markertype is expensive.", MARKERTYPE_EXPENSIVE, ((IPluginElement) extension.getChildren()[0]).getAttribute(CheckMarkerHelpExtensionHelper.MARKERTYPE_ATTRIBUTE_TAG).getValue());
}
Also used : IPluginExtension(org.eclipse.pde.core.plugin.IPluginExtension) IPluginElement(org.eclipse.pde.core.plugin.IPluginElement) CheckCatalog(com.avaloq.tools.ddk.check.check.CheckCatalog) Test(org.junit.Test)

Example 7 with IPluginElement

use of org.eclipse.pde.core.plugin.IPluginElement in project dsl-devkit by dsldevkit.

the class CheckMarkerHelpExtensionTest method testAddElement.

/**
 * Tests, if the marker help extension is updated correctly, i.e. add marker help elements for new checks
 * and delete the elements of removed checks.
 *
 * @throws Exception
 *           the exception
 */
@Test
public void testAddElement() throws Exception {
    final CheckCatalog catalogWithOneCheck = parser.parse(CATALOG_WITH_FIRST_CHECK_LIVE);
    IPluginExtension extension = createMarkerHelpExtension(catalogWithOneCheck);
    assertEquals("Original catalog has one marker help extension", 1, extension.getChildCount());
    CheckCatalog catalogWithTwoChecks = parser.parse(CATALOG_WITH_TWO_CHECKS);
    markerUtil.updateExtension(catalogWithTwoChecks, extension);
    Set<String> contextIds = Sets.newHashSet();
    // Test if the marker help element for the old Check has been removed
    for (IPluginObject element : extension.getChildren()) {
        contextIds.add(((IPluginElement) element).getAttribute(CheckMarkerHelpExtensionHelper.CONTEXT_ID_ATTRIBUTE_TAG).getValue());
    }
    assertEquals("The extension has two elements", 2, extension.getChildCount());
    assertTrue("Both checks are elements of the extension ", contextIds.containsAll(Sets.newHashSet(FIRSTCHECK_CONTEXID, SECONDCHECK_CONTEXTID)));
}
Also used : IPluginExtension(org.eclipse.pde.core.plugin.IPluginExtension) IPluginElement(org.eclipse.pde.core.plugin.IPluginElement) IPluginObject(org.eclipse.pde.core.plugin.IPluginObject) CheckCatalog(com.avaloq.tools.ddk.check.check.CheckCatalog) Test(org.junit.Test)

Example 8 with IPluginElement

use of org.eclipse.pde.core.plugin.IPluginElement in project dsl-devkit by dsldevkit.

the class CheckMarkerHelpExtensionTest method testCreateExtension.

/**
 * Tests if the marker help extension is correctly created.
 *
 * @throws Exception
 *           the exception
 */
@Test
public void testCreateExtension() throws Exception {
    IPluginExtension extension = createMarkerHelpExtension(parser.parse(CATALOG_WITH_FIRST_CHECK_LIVE));
    // Test if the extension has been created.
    assertEquals("Marker help extension has been created.", CheckMarkerHelpExtensionHelper.MARKERHELP_EXTENSION_POINT_ID, extension.getPoint());
    // Test if the extension contains the marker help element
    IPluginElement element = (IPluginElement) extension.getChildren()[0];
    assertEquals("The marker help element has the correct context id", FIRSTCHECK_CONTEXID, element.getAttribute(CheckMarkerHelpExtensionHelper.CONTEXT_ID_ATTRIBUTE_TAG).getValue());
    assertEquals("The marker help element has the correct markertype", MARKERTYPE_FAST, element.getAttribute(CheckMarkerHelpExtensionHelper.MARKERTYPE_ATTRIBUTE_TAG).getValue());
}
Also used : IPluginExtension(org.eclipse.pde.core.plugin.IPluginExtension) IPluginElement(org.eclipse.pde.core.plugin.IPluginElement) Test(org.junit.Test)

Example 9 with IPluginElement

use of org.eclipse.pde.core.plugin.IPluginElement in project dsl-devkit by dsldevkit.

the class CheckMarkerHelpExtensionTest method testCheckHasTwoIssueCodes.

/**
 * Tests if a marker help element is added if an additional issueCode is added to an existing check.
 *
 * @throws Exception
 *           the exception
 */
@Test
public void testCheckHasTwoIssueCodes() throws Exception {
    IPluginExtension extension = createMarkerHelpExtension(parser.parse(CATALOG_WITH_FIRST_CHECK_LIVE));
    CheckCatalog twoIssueCodes = parser.parse(CATALOG_CHECK_HAS_TWO_ISSUECODES);
    markerUtil.updateExtension(twoIssueCodes, extension);
    List<String> issueCodesOfCheck = Lists.newArrayList();
    for (final XIssueExpression i : generatorExtension.issues(twoIssueCodes.getChecks().get(0))) {
        issueCodesOfCheck.add(CheckGeneratorExtensions.issueCodeValue(twoIssueCodes.getChecks().get(0), CheckGeneratorExtensions.issueCode(i)));
    }
    List<String> issueCodesInExtension = Lists.newArrayList();
    for (IPluginObject obj : extension.getChildren()) {
        for (IPluginObject element : ((IPluginElement) obj).getChildren()) {
            issueCodesInExtension.add(((IPluginElement) element).getAttribute(CheckMarkerHelpExtensionHelper.ATTRIBUTE_VALUE_TAG).getValue());
        }
    }
    assertTrue("A marker help element for both issueCodes has been created.", Iterables.elementsEqual(issueCodesInExtension, issueCodesOfCheck));
    assertEquals("extension has two marker help elements", 2, issueCodesInExtension.size());
}
Also used : IPluginExtension(org.eclipse.pde.core.plugin.IPluginExtension) XIssueExpression(com.avaloq.tools.ddk.check.check.XIssueExpression) IPluginElement(org.eclipse.pde.core.plugin.IPluginElement) IPluginObject(org.eclipse.pde.core.plugin.IPluginObject) CheckCatalog(com.avaloq.tools.ddk.check.check.CheckCatalog) Test(org.junit.Test)

Example 10 with IPluginElement

use of org.eclipse.pde.core.plugin.IPluginElement in project dsl-devkit by dsldevkit.

the class CheckTocExtensionTest method testUpdateTocExtension.

/**
 * Tests if an update of a toc extension is correctly done.
 *
 * @throws CoreException
 *           the core exception
 */
@Test
public void testUpdateTocExtension() throws CoreException {
    IPluginExtension extension = createErroneousTocExtension();
    assertNotSame("File location is not as expected", CheckTocExtensionHelper.TOC_FILE_NAME, ((IPluginElement) extension.getChildren()[0]).getAttribute("file").getValue());
    tocUtil.updateExtension(catalog, extension);
    assertEquals("Toc file location is now set correctly", CheckTocExtensionHelper.TOC_FILE_NAME, ((IPluginElement) extension.getChildren()[0]).getAttribute("file").getValue());
}
Also used : IPluginExtension(org.eclipse.pde.core.plugin.IPluginExtension) IPluginElement(org.eclipse.pde.core.plugin.IPluginElement) Test(org.junit.Test)

Aggregations

IPluginElement (org.eclipse.pde.core.plugin.IPluginElement)24 IPluginExtension (org.eclipse.pde.core.plugin.IPluginExtension)19 Test (org.junit.Test)11 CheckCatalog (com.avaloq.tools.ddk.check.check.CheckCatalog)4 IPluginObject (org.eclipse.pde.core.plugin.IPluginObject)4 Check (com.avaloq.tools.ddk.check.check.Check)3 IQualifiedNameProvider (org.eclipse.xtext.naming.IQualifiedNameProvider)2 XIssueExpression (com.avaloq.tools.ddk.check.check.XIssueExpression)1 NoSuchElementException (java.util.NoSuchElementException)1 IPluginAttribute (org.eclipse.pde.core.plugin.IPluginAttribute)1 Pair (org.eclipse.xtext.util.Pair)1