Search in sources :

Example 16 with MetacardType

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

the class MetacardTypeImplTest method testMediaType.

@Test
public void testMediaType() {
    List<MetacardType> metacardTypeList = new ArrayList<>();
    metacardTypeList.add(MEDIA_ATTRIBUTES);
    MetacardType metacardType = new MetacardTypeImpl(TEST_NAME, metacardTypeList);
    assertMetacardAttributes(metacardType, CORE_ATTRIBUTES.getAttributeDescriptors());
    assertMetacardAttributes(metacardType, MEDIA_ATTRIBUTES.getAttributeDescriptors());
}
Also used : ArrayList(java.util.ArrayList) MetacardType(ddf.catalog.data.MetacardType) Test(org.junit.Test)

Example 17 with MetacardType

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

the class MetacardTypeImplTest method testNullAttributeDescriptors.

@Test
public void testNullAttributeDescriptors() {
    MetacardType mt = new MetacardTypeImpl(NAME, (Set<AttributeDescriptor>) null);
    assertThat(mt.getAttributeDescriptors(), hasSize(0));
}
Also used : AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) MetacardType(ddf.catalog.data.MetacardType) Test(org.junit.Test)

Example 18 with MetacardType

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

the class CatalogBackupPluginTest method getDeleteResponse.

private DeleteResponse getDeleteResponse(List<String> metacardIds) {
    MetacardType mockMetacardType = mock(MetacardType.class);
    when(mockMetacardType.getName()).thenReturn(MetacardType.DEFAULT_METACARD_TYPE_NAME);
    List<Metacard> deletedMetacards = new ArrayList<>(metacardIds.size());
    for (String metacardId : metacardIds) {
        Metacard mockMetacard = mock(Metacard.class);
        when(mockMetacard.getId()).thenReturn(metacardId);
        when(mockMetacard.getMetacardType()).thenReturn(mockMetacardType);
        deletedMetacards.add(mockMetacard);
    }
    DeleteRequest request = mock(DeleteRequest.class);
    DeleteResponse mockDeleteResponse = mock(DeleteResponse.class);
    when(mockDeleteResponse.getDeletedMetacards()).thenReturn(deletedMetacards);
    when(mockDeleteResponse.getRequest()).thenReturn(request);
    return mockDeleteResponse;
}
Also used : Metacard(ddf.catalog.data.Metacard) DeleteResponse(ddf.catalog.operation.DeleteResponse) ArrayList(java.util.ArrayList) DeleteRequest(ddf.catalog.operation.DeleteRequest) MetacardType(ddf.catalog.data.MetacardType)

Example 19 with MetacardType

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

the class AttributeInjectorImplTest method testInjectIntoMetacard.

@Test
public void testInjectIntoMetacard() {
    final String title = "title";
    final Date created = new Date();
    final MetacardImpl basicMetacard = new MetacardImpl();
    basicMetacard.setTitle(title);
    basicMetacard.setCreatedDate(created);
    final MetacardType expectedBasicMetacardType = new MetacardTypeImpl(BASIC_METACARD.getName(), BASIC_METACARD, Sets.newHashSet(globalAttribute, basicAttribute, basicAndNitfAttribute));
    final Metacard injectedBasicMetacard = attributeInjector.injectAttributes(basicMetacard);
    assertThat(injectedBasicMetacard.getMetacardType(), is(expectedBasicMetacardType));
    assertThat(injectedBasicMetacard.getTitle(), is(title));
    assertThat(injectedBasicMetacard.getCreatedDate(), is(created));
    final MetacardImpl nitfMetacard = new MetacardImpl(NITF_TYPE);
    nitfMetacard.setTitle(title);
    nitfMetacard.setCreatedDate(created);
    final MetacardType expectedNitfMetacardType = new MetacardTypeImpl(NITF, NITF_TYPE, Sets.newHashSet(globalAttribute, basicAndNitfAttribute));
    final Metacard injectedNitfMetacard = attributeInjector.injectAttributes(nitfMetacard);
    assertThat(injectedNitfMetacard.getMetacardType(), is(expectedNitfMetacardType));
    assertThat(injectedNitfMetacard.getTitle(), is(title));
    assertThat(injectedNitfMetacard.getCreatedDate(), is(created));
}
Also used : Metacard(ddf.catalog.data.Metacard) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) Date(java.util.Date) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) MetacardType(ddf.catalog.data.MetacardType) Test(org.junit.Test)

Example 20 with MetacardType

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

the class AttributeInjectorImplTest method testInjectNothingIntoMetacardType.

@Test
public void testInjectNothingIntoMetacardType() {
    attributeInjector.setInjectableAttributes(Lists.newArrayList(basicInjection));
    final MetacardType injectedMetacardType = attributeInjector.injectAttributes(NITF_TYPE);
    assertThat(injectedMetacardType, is(sameInstance(NITF_TYPE)));
}
Also used : MetacardType(ddf.catalog.data.MetacardType) Test(org.junit.Test)

Aggregations

MetacardType (ddf.catalog.data.MetacardType)88 Test (org.junit.Test)57 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)41 Metacard (ddf.catalog.data.Metacard)35 ArrayList (java.util.ArrayList)29 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)20 MetacardTypeImpl (ddf.catalog.data.impl.MetacardTypeImpl)17 HashSet (java.util.HashSet)15 Attribute (ddf.catalog.data.Attribute)12 Serializable (java.io.Serializable)10 IOException (java.io.IOException)8 Date (java.util.Date)8 HashMap (java.util.HashMap)8 List (java.util.List)8 Map (java.util.Map)8 AttributeDescriptorImpl (ddf.catalog.data.impl.AttributeDescriptorImpl)7 InputStream (java.io.InputStream)7 Set (java.util.Set)7 ContentItem (ddf.catalog.content.data.ContentItem)6 ContentItemImpl (ddf.catalog.content.data.impl.ContentItemImpl)6