Search in sources :

Example 21 with MetacardTypeImpl

use of ddf.catalog.data.impl.MetacardTypeImpl in project ddf by codice.

the class RegistryTransformerTest method setUp.

@Before
public void setUp() {
    registryTransformer = new RegistryTransformer();
    parser = new XmlParser();
    metacardTypes = new ArrayList<>();
    metacardTypes.addAll(Arrays.asList(new RegistryObjectMetacardType(), new TopicAttributes(), new MediaAttributes(), new ContactAttributes(), new CoreAttributes(), new DateTimeAttributes()));
    metacardType = new MetacardTypeImpl("registryMetacard", metacardTypes);
    registryTransformer.setParser(parser);
    registryTransformer.setRegistryMetacardType(metacardType);
    System.setProperty(RegistryConstants.REGISTRY_ID_PROPERTY, "identityRegistryId");
}
Also used : XmlParser(org.codice.ddf.parser.xml.XmlParser) ContactAttributes(ddf.catalog.data.impl.types.ContactAttributes) DateTimeAttributes(ddf.catalog.data.impl.types.DateTimeAttributes) CoreAttributes(ddf.catalog.data.impl.types.CoreAttributes) MediaAttributes(ddf.catalog.data.impl.types.MediaAttributes) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) RegistryObjectMetacardType(org.codice.ddf.registry.common.metacard.RegistryObjectMetacardType) TopicAttributes(ddf.catalog.data.impl.types.TopicAttributes) Before(org.junit.Before)

Example 22 with MetacardTypeImpl

use of ddf.catalog.data.impl.MetacardTypeImpl in project ddf by codice.

the class ConfluenceSourceTest method setup.

@Before
public void setup() {
    MetacardType type = new MetacardTypeImpl("confluence", (List) null);
    transformer = new ConfluenceInputTransformer(type);
    encryptionService = mock(EncryptionService.class);
    reader = mock(ResourceReader.class);
    factory = mock(SecureCxfClientFactory.class);
    client = mock(SearchResource.class);
    clientResponse = mock(Response.class);
    when(factory.getClient()).thenReturn(client);
    doReturn(clientResponse).when(client).search(anyString(), anyString(), anyString(), anyString(), anyInt(), anyInt(), anyBoolean());
    when(encryptionService.decryptValue(anyString())).thenReturn("decryptedPass");
    confluence = new TestConfluenceSource(adapter, encryptionService, transformer, reader, factory);
    confluence.setAvailabilityPollInterval(1);
    confluence.setConfigurationPid("configPid");
    confluence.setEndpointUrl("https://confluence/rest/api/content");
    confluence.setExpandedSections(Collections.singletonList("expandedField"));
    confluence.setUsername("username");
    confluence.setPassword("password");
    confluence.setIncludeArchivedSpaces(false);
    List<String> additionalAttributes = new ArrayList<>();
    additionalAttributes.add("attrib1=val1");
    additionalAttributes.add("attrib2=val1,val2,val3");
    confluence.setAdditionalAttributes(additionalAttributes);
}
Also used : ResourceReader(ddf.catalog.resource.ResourceReader) SourceResponse(ddf.catalog.operation.SourceResponse) Response(javax.ws.rs.core.Response) SecureCxfClientFactory(org.codice.ddf.cxf.SecureCxfClientFactory) EncryptionService(ddf.security.encryption.EncryptionService) ArrayList(java.util.ArrayList) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) Matchers.anyString(org.mockito.Matchers.anyString) SearchResource(org.codice.ddf.confluence.api.SearchResource) MetacardType(ddf.catalog.data.MetacardType) Before(org.junit.Before)

Example 23 with MetacardTypeImpl

use of ddf.catalog.data.impl.MetacardTypeImpl in project ddf by codice.

the class FilterPluginTest method getNoSecurityAttributeMetacard.

private Metacard getNoSecurityAttributeMetacard() {
    MetacardImpl metacard = new MetacardImpl();
    metacard.setResourceSize("100");
    try {
        metacard.setResourceURI(new URI("http://some.fancy.uri/goes/here"));
    } catch (URISyntaxException e) {
        LOGGER.error("", e);
    }
    //Intentionally do not set the Metacard.SECURITY attribute
    metacard.setContentTypeName("Resource");
    metacard.setTitle("Metacard 1");
    metacard.setContentTypeVersion("1");
    metacard.setType(new MetacardTypeImpl(MetacardType.DEFAULT_METACARD_TYPE_NAME, new HashSet<>()));
    return metacard;
}
Also used : MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) HashSet(java.util.HashSet)

Example 24 with MetacardTypeImpl

use of ddf.catalog.data.impl.MetacardTypeImpl in project ddf by codice.

the class FilterPluginTest method getExactRolesMetacard.

private Metacard getExactRolesMetacard() {
    MetacardImpl metacard = new MetacardImpl();
    metacard.setResourceSize("100");
    try {
        metacard.setResourceURI(new URI("http://some.fancy.uri/goes/here"));
    } catch (URISyntaxException e) {
        LOGGER.error("", e);
    }
    metacard.setContentTypeName("Resource");
    metacard.setTitle("Metacard 1");
    metacard.setContentTypeVersion("1");
    metacard.setType(new MetacardTypeImpl(MetacardType.DEFAULT_METACARD_TYPE_NAME, new HashSet<>()));
    HashMap<String, List<String>> security = new HashMap<>();
    security.put("Roles", Arrays.asList("A", "B"));
    metacard.setSecurity(security);
    metacard.setId("exactroles");
    return metacard;
}
Also used : HashMap(java.util.HashMap) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) List(java.util.List) ArrayList(java.util.ArrayList) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) HashSet(java.util.HashSet)

Example 25 with MetacardTypeImpl

use of ddf.catalog.data.impl.MetacardTypeImpl in project ddf by codice.

the class FilterPluginTest method getMissingRolesMetacard.

private Metacard getMissingRolesMetacard() {
    MetacardImpl metacard = new MetacardImpl();
    metacard.setResourceSize("100");
    try {
        metacard.setResourceURI(new URI("http://some.fancy.uri/goes/here"));
    } catch (URISyntaxException e) {
        LOGGER.error("", e);
    }
    metacard.setContentTypeName("Resource");
    metacard.setTitle("Metacard 1");
    metacard.setContentTypeVersion("1");
    metacard.setType(new MetacardTypeImpl(MetacardType.DEFAULT_METACARD_TYPE_NAME, new HashSet<>()));
    HashMap<String, List<String>> security = new HashMap<>();
    security.put("Roles", Arrays.asList("A"));
    metacard.setSecurity(security);
    return metacard;
}
Also used : HashMap(java.util.HashMap) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) List(java.util.List) ArrayList(java.util.ArrayList) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) HashSet(java.util.HashSet)

Aggregations

MetacardTypeImpl (ddf.catalog.data.impl.MetacardTypeImpl)40 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)22 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)21 Test (org.junit.Test)21 Metacard (ddf.catalog.data.Metacard)20 HashSet (java.util.HashSet)16 ArrayList (java.util.ArrayList)15 MetacardType (ddf.catalog.data.MetacardType)14 AttributeDescriptorImpl (ddf.catalog.data.impl.AttributeDescriptorImpl)10 URI (java.net.URI)9 HashMap (java.util.HashMap)6 List (java.util.List)6 Metadata (org.apache.tika.metadata.Metadata)6 URISyntaxException (java.net.URISyntaxException)5 SourceResponse (ddf.catalog.operation.SourceResponse)4 QueryImpl (ddf.catalog.operation.impl.QueryImpl)3 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)3 MetacardTypeAdapter (ddf.catalog.transformer.xml.adapter.MetacardTypeAdapter)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 ContentItem (ddf.catalog.content.data.ContentItem)2