Search in sources :

Example 1 with QualifiedMetacardType

use of ddf.catalog.data.QualifiedMetacardType in project ddf by codice.

the class MetacardTypeRegistryImpl method lookup.

@Override
public QualifiedMetacardType lookup(String namespace, String metacardTypeName) throws IllegalArgumentException {
    validateInput(namespace, metacardTypeName);
    for (QualifiedMetacardType qmt : registeredMetacardTypes) {
        String currName = qmt.getName();
        String currNamespace = qmt.getNamespace();
        if (metacardTypeName.equals(currName) && namespace.equals(currNamespace)) {
            return qmt;
        }
    }
    LOGGER.debug("No registered MetacardType with namespace: {} and name: {}", namespace, metacardTypeName);
    return null;
}
Also used : QualifiedMetacardType(ddf.catalog.data.QualifiedMetacardType)

Example 2 with QualifiedMetacardType

use of ddf.catalog.data.QualifiedMetacardType in project ddf by codice.

the class MetacardTypeRegistryTest method registerMetacardTypeNullName.

@Test(expected = IllegalArgumentException.class)
public void registerMetacardTypeNullName() {
    QualifiedMetacardType qmt = new QualifiedMetacardTypeImpl(QUALIFIED_METACARD_TYPE_NAMESPACE_1, null, qmtAttributes);
    mtr.register(qmt);
}
Also used : QualifiedMetacardTypeImpl(ddf.catalog.data.impl.QualifiedMetacardTypeImpl) QualifiedMetacardType(ddf.catalog.data.QualifiedMetacardType) Test(org.junit.Test)

Example 3 with QualifiedMetacardType

use of ddf.catalog.data.QualifiedMetacardType in project ddf by codice.

the class MetacardTypeRegistryTest method testLookupMetacardTypeCantFindNamespace.

@Test
public void testLookupMetacardTypeCantFindNamespace() {
    QualifiedMetacardType qmt = mtr.lookup(QUALIFIED_METACARD_TYPE_NAMESPACE_BAD, QUALIFIED_METACARD_TYPE_NAME_3);
    assertNull(qmt);
}
Also used : QualifiedMetacardType(ddf.catalog.data.QualifiedMetacardType) Test(org.junit.Test)

Example 4 with QualifiedMetacardType

use of ddf.catalog.data.QualifiedMetacardType in project ddf by codice.

the class MetacardTypeRegistryTest method registerMetacardType.

@Test
public void registerMetacardType() throws InvalidSyntaxException, IllegalArgumentException, MetacardTypeUnregistrationException {
    assertEquals(4, mtr.getRegisteredTypes().size());
    mtr.register(sampleMetacardTypeA());
    mtr.register(sampleMetacardTypeB());
    assertEquals(6, mtr.getRegisteredTypes().size());
    QualifiedMetacardType metacardTypeAFromRegistry = mtr.lookup(QualifiedMetacardType.DEFAULT_METACARD_TYPE_NAMESPACE, SAMPLE_A_METACARD_TYPE_NAME);
    assertNotNull(metacardTypeAFromRegistry);
    assertEquals(SAMPLE_A_METACARD_TYPE_NAME, metacardTypeAFromRegistry.getName());
    assertEquals(QualifiedMetacardType.DEFAULT_METACARD_TYPE_NAMESPACE, metacardTypeAFromRegistry.getNamespace());
    assertOnSampleMetacardTypeAExpectedAttributes(metacardTypeAFromRegistry);
    QualifiedMetacardType metacardTypeBFromRegistry = mtr.lookup(SAMPLE_B_METACARD_TYPE_NAMESPACE, SAMPLE_B_METACARD_TYPE_NAME);
    assertNotNull(metacardTypeBFromRegistry);
    assertEquals(SAMPLE_B_METACARD_TYPE_NAME, metacardTypeBFromRegistry.getName());
    assertEquals(SAMPLE_B_METACARD_TYPE_NAMESPACE, metacardTypeBFromRegistry.getNamespace());
    assertOnSampleMetacardTypeBExcpectedAttributes(metacardTypeBFromRegistry);
    mtr.unregister(sampleMetacardTypeA());
    mtr.unregister(sampleMetacardTypeB());
}
Also used : QualifiedMetacardType(ddf.catalog.data.QualifiedMetacardType) Test(org.junit.Test)

Example 5 with QualifiedMetacardType

use of ddf.catalog.data.QualifiedMetacardType in project ddf by codice.

the class MetacardTypeRegistryTest method testUnregister.

@Test
public void testUnregister() throws IllegalArgumentException, MetacardTypeUnregistrationException {
    assertEquals(4, mtr.getRegisteredTypes().size());
    mtr.register(sampleMetacardTypeA());
    mtr.register(sampleMetacardTypeB());
    assertEquals(6, mtr.getRegisteredTypes().size());
    QualifiedMetacardType metacardTypeAFromRegistry = mtr.lookup(QualifiedMetacardType.DEFAULT_METACARD_TYPE_NAMESPACE, SAMPLE_A_METACARD_TYPE_NAME);
    assertNotNull(metacardTypeAFromRegistry);
    assertEquals(SAMPLE_A_METACARD_TYPE_NAME, metacardTypeAFromRegistry.getName());
    assertEquals(QualifiedMetacardType.DEFAULT_METACARD_TYPE_NAMESPACE, metacardTypeAFromRegistry.getNamespace());
    assertOnSampleMetacardTypeAExpectedAttributes(metacardTypeAFromRegistry);
    QualifiedMetacardType metacardTypeBFromRegistry = mtr.lookup(SAMPLE_B_METACARD_TYPE_NAMESPACE, SAMPLE_B_METACARD_TYPE_NAME);
    assertNotNull(metacardTypeBFromRegistry);
    assertEquals(SAMPLE_B_METACARD_TYPE_NAME, metacardTypeBFromRegistry.getName());
    assertEquals(SAMPLE_B_METACARD_TYPE_NAMESPACE, metacardTypeBFromRegistry.getNamespace());
    assertOnSampleMetacardTypeBExcpectedAttributes(metacardTypeBFromRegistry);
    mtr.unregister(sampleMetacardTypeA());
    assertEquals(5, mtr.getRegisteredTypes().size());
    assertTrue(mtr.getRegisteredTypes().contains(sampleMetacardTypeB()));
    assertFalse(mtr.getRegisteredTypes().contains(sampleMetacardTypeA()));
    QualifiedMetacardTypeImpl qmt1 = new QualifiedMetacardTypeImpl(QUALIFIED_METACARD_TYPE_NAMESPACE_1, QUALIFIED_METACARD_TYPE_NAME_1, qmtAttributes);
    assertTrue(mtr.getRegisteredTypes().contains(qmt1));
    QualifiedMetacardTypeImpl qmt2 = new QualifiedMetacardTypeImpl(QUALIFIED_METACARD_TYPE_NAMESPACE_1, QUALIFIED_METACARD_TYPE_NAME_2, qmtAttributes);
    assertTrue(mtr.getRegisteredTypes().contains(qmt2));
    QualifiedMetacardTypeImpl qmt3 = new QualifiedMetacardTypeImpl(QualifiedMetacardType.DEFAULT_METACARD_TYPE_NAMESPACE, QUALIFIED_METACARD_TYPE_NAME_3, qmtAttributes);
    assertTrue(mtr.getRegisteredTypes().contains(qmt3));
    mtr.unregister(sampleMetacardTypeB());
}
Also used : QualifiedMetacardTypeImpl(ddf.catalog.data.impl.QualifiedMetacardTypeImpl) QualifiedMetacardType(ddf.catalog.data.QualifiedMetacardType) Test(org.junit.Test)

Aggregations

QualifiedMetacardType (ddf.catalog.data.QualifiedMetacardType)15 Test (org.junit.Test)14 QualifiedMetacardTypeImpl (ddf.catalog.data.impl.QualifiedMetacardTypeImpl)6