Search in sources :

Example 1 with ParameterizedMetricKey

use of net.sourceforge.pmd.lang.metrics.ParameterizedMetricKey in project pmd by pmd.

the class ParameterizedMetricKeyTest method testIdentity.

@Test
public void testIdentity() {
    for (JavaClassMetricKey key : JavaClassMetricKey.values()) {
        ParameterizedMetricKey key1 = ParameterizedMetricKey.getInstance(key, DUMMY_VERSION_1);
        ParameterizedMetricKey key2 = ParameterizedMetricKey.getInstance(key, DUMMY_VERSION_1);
        assertEquals(key1, key2);
        assertTrue(key1 == key2);
    }
    for (JavaOperationMetricKey key : JavaOperationMetricKey.values()) {
        ParameterizedMetricKey key1 = ParameterizedMetricKey.getInstance(key, DUMMY_VERSION_1);
        ParameterizedMetricKey key2 = ParameterizedMetricKey.getInstance(key, DUMMY_VERSION_1);
        assertEquals(key1, key2);
        assertTrue(key1 == key2);
    }
}
Also used : JavaClassMetricKey(net.sourceforge.pmd.lang.java.metrics.api.JavaClassMetricKey) ParameterizedMetricKey(net.sourceforge.pmd.lang.metrics.ParameterizedMetricKey) JavaOperationMetricKey(net.sourceforge.pmd.lang.java.metrics.api.JavaOperationMetricKey) Test(org.junit.Test)

Example 2 with ParameterizedMetricKey

use of net.sourceforge.pmd.lang.metrics.ParameterizedMetricKey in project pmd by pmd.

the class ParameterizedMetricKeyTest method testVersioning.

@Test
public void testVersioning() {
    for (JavaClassMetricKey key : JavaClassMetricKey.values()) {
        ParameterizedMetricKey key1 = ParameterizedMetricKey.getInstance(key, DUMMY_VERSION_1);
        ParameterizedMetricKey key2 = ParameterizedMetricKey.getInstance(key, DUMMY_VERSION_2);
        assertNotEquals(key1, key2);
        assertFalse(key1 == key2);
    }
    for (JavaOperationMetricKey key : JavaOperationMetricKey.values()) {
        ParameterizedMetricKey key1 = ParameterizedMetricKey.getInstance(key, DUMMY_VERSION_1);
        ParameterizedMetricKey key2 = ParameterizedMetricKey.getInstance(key, DUMMY_VERSION_2);
        assertNotEquals(key1, key2);
        assertFalse(key1 == key2);
    }
}
Also used : JavaClassMetricKey(net.sourceforge.pmd.lang.java.metrics.api.JavaClassMetricKey) ParameterizedMetricKey(net.sourceforge.pmd.lang.metrics.ParameterizedMetricKey) JavaOperationMetricKey(net.sourceforge.pmd.lang.java.metrics.api.JavaOperationMetricKey) Test(org.junit.Test)

Example 3 with ParameterizedMetricKey

use of net.sourceforge.pmd.lang.metrics.ParameterizedMetricKey in project pmd by pmd.

the class ParameterizedMetricKeyTest method testToString.

@Test
public void testToString() {
    for (JavaClassMetricKey key : JavaClassMetricKey.values()) {
        ParameterizedMetricKey key1 = ParameterizedMetricKey.getInstance(key, DUMMY_VERSION_1);
        assertTrue(key1.toString().contains(key1.key.name()));
        assertTrue(key1.toString().contains(key1.options.toString()));
    }
}
Also used : JavaClassMetricKey(net.sourceforge.pmd.lang.java.metrics.api.JavaClassMetricKey) ParameterizedMetricKey(net.sourceforge.pmd.lang.metrics.ParameterizedMetricKey) Test(org.junit.Test)

Example 4 with ParameterizedMetricKey

use of net.sourceforge.pmd.lang.metrics.ParameterizedMetricKey in project pmd by pmd.

the class ParameterizedMetricKeyTest method testAdHocMetricKey.

@Test
public void testAdHocMetricKey() {
    MetricKey<ASTAnyTypeDeclaration> adHocKey = MetricKeyUtil.of("metric", null);
    ParameterizedMetricKey key1 = ParameterizedMetricKey.getInstance(adHocKey, DUMMY_VERSION_1);
    ParameterizedMetricKey key2 = ParameterizedMetricKey.getInstance(adHocKey, DUMMY_VERSION_1);
    assertNotNull(key1);
    assertNotNull(key2);
    assertTrue(key1 == key2);
    assertEquals(key1, key2);
    assertTrue(key1.toString().contains(key1.key.name()));
    assertTrue(key1.toString().contains(key1.options.toString()));
}
Also used : ASTAnyTypeDeclaration(net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration) ParameterizedMetricKey(net.sourceforge.pmd.lang.metrics.ParameterizedMetricKey) Test(org.junit.Test)

Aggregations

ParameterizedMetricKey (net.sourceforge.pmd.lang.metrics.ParameterizedMetricKey)4 Test (org.junit.Test)4 JavaClassMetricKey (net.sourceforge.pmd.lang.java.metrics.api.JavaClassMetricKey)3 JavaOperationMetricKey (net.sourceforge.pmd.lang.java.metrics.api.JavaOperationMetricKey)2 ASTAnyTypeDeclaration (net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration)1