use of ddf.catalog.operation.impl.CreateResponseImpl in project ddf by codice.
the class FederationAdminServiceImplTest method testAddRegistryEntry.
@Test
public void testAddRegistryEntry() throws Exception {
String destination = TEST_DESTINATION;
Metacard metacard = testMetacard;
Metacard createdMetacard = testMetacard;
Set<String> destinations = new HashSet<>();
destinations.add(destination);
Subject systemSubject = security.getSystemSubject();
Map<String, Serializable> properties = new HashMap<>();
properties.put(SecurityConstants.SECURITY_SUBJECT, systemSubject);
CreateRequest request = new CreateRequestImpl(Collections.singletonList(metacard), properties, destinations);
CreateResponse response = new CreateResponseImpl(request, null, Collections.singletonList(createdMetacard));
when(catalogFramework.create(any(CreateRequest.class))).thenReturn(response);
String createdMetacardId = federationAdminServiceImpl.addRegistryEntry(metacard, destinations);
assertThat(createdMetacardId, is(equalTo(RegistryObjectMetacardType.REGISTRY_ID)));
verify(catalogFramework).create(any(CreateRequest.class));
}
use of ddf.catalog.operation.impl.CreateResponseImpl in project ddf by codice.
the class FederationAdminServiceImplTest method testAddRegistryEntryWithNullDestinations.
@Test
public void testAddRegistryEntryWithNullDestinations() throws Exception {
String registryId = RegistryObjectMetacardType.REGISTRY_ID;
Metacard metacard = testMetacard;
Metacard createdMetacard = testMetacard;
Set<String> destinations = null;
Subject systemSubject = security.getSystemSubject();
Map<String, Serializable> properties = new HashMap<>();
properties.put(SecurityConstants.SECURITY_SUBJECT, systemSubject);
CreateRequest request = new CreateRequestImpl(Collections.singletonList(metacard), properties, destinations);
CreateResponse response = new CreateResponseImpl(request, null, Collections.singletonList(createdMetacard));
when(catalogFramework.create(any(CreateRequest.class))).thenReturn(response);
String createdMetacardId = federationAdminServiceImpl.addRegistryEntry(metacard, destinations);
assertThat(createdMetacardId, is(equalTo(registryId)));
verify(catalogFramework).create(any(CreateRequest.class));
}
use of ddf.catalog.operation.impl.CreateResponseImpl in project ddf by codice.
the class CreateOperations method doRemoteCreate.
private CreateResponse doRemoteCreate(CreateRequest createRequest) {
HashSet<ProcessingDetails> exceptions = new HashSet<>();
Map<String, Serializable> properties = new HashMap<>();
List<CatalogStore> stores = opsCatStoreSupport.getCatalogStoresForRequest(createRequest, exceptions);
for (CatalogStore store : stores) {
try {
if (!store.isAvailable()) {
exceptions.add(new ProcessingDetailsImpl(store.getId(), null, "CatalogStore is not available"));
} else {
CreateResponse response = store.create(createRequest);
properties.put(store.getId(), new ArrayList<>(response.getCreatedMetacards()));
}
} catch (IngestException e) {
INGEST_LOGGER.error("Error creating metacards for CatalogStore {}", store.getId(), e);
exceptions.add(new ProcessingDetailsImpl(store.getId(), e));
}
}
return new CreateResponseImpl(createRequest, properties, createRequest.getMetacards(), exceptions);
}
use of ddf.catalog.operation.impl.CreateResponseImpl in project ddf by codice.
the class TestCswEndpoint method setUpBeforeClass.
@org.junit.Before
public void setUpBeforeClass() throws URISyntaxException, SourceUnavailableException, UnsupportedQueryException, FederationException, ParseException, IngestException {
URI mockUri = new URI("http://example.com/services/csw");
when(mockUriInfo.getBaseUri()).thenReturn(mockUri);
URL resourceUrl = TestCswEndpoint.class.getResource("/record.xsd");
URL resourceUrlDot = TestCswEndpoint.class.getClass().getResource(".");
when(mockBundle.getResource("record.xsd")).thenReturn(resourceUrl);
when(mockBundle.getResource("csw/2.0.2/record.xsd")).thenReturn(resourceUrl);
when(mockBundle.getResource("gmd/record_gmd.xsd")).thenReturn(resourceUrl);
when(mockBundle.getResource(".")).thenReturn(resourceUrlDot);
csw = new CswEndpointStub(catalogFramework, mockMimeTypeManager, mockSchemaManager, mockInputManager, validator, queryFactory, mockBundle);
csw.setUri(mockUriInfo);
when(mockMimeTypeManager.getAvailableMimeTypes()).thenReturn(Arrays.asList(MediaType.APPLICATION_XML));
when(mockSchemaManager.getAvailableSchemas()).thenReturn(new ArrayList<>(Arrays.asList(CswConstants.CSW_OUTPUT_SCHEMA)));
when(mockSchemaManager.getTransformerBySchema(CswConstants.CSW_OUTPUT_SCHEMA)).thenReturn(mockTransformer);
when(mockInputManager.getAvailableIds()).thenReturn(Arrays.asList(CswConstants.CSW_RECORD));
QueryResponseImpl response = new QueryResponseImpl(null, new LinkedList<>(), 0);
argument = ArgumentCaptor.forClass(QueryRequest.class);
reset(catalogFramework);
when(catalogFramework.query(argument.capture())).thenReturn(response);
when(catalogFramework.getSourceIds()).thenReturn(new HashSet<>(Arrays.asList("source1", "source2", "source3")));
CreateResponseImpl createResponse = new CreateResponseImpl(null, null, Arrays.asList(new MetacardImpl()));
when(catalogFramework.create(any(CreateRequest.class))).thenReturn(createResponse);
}
use of ddf.catalog.operation.impl.CreateResponseImpl in project ddf by codice.
the class TestPlugin method testCreate.
@Test
@Ignore
public void testCreate() throws PluginExecutionException, CatalogTransformerException, IOException, IngestException, SourceUnavailableException {
// given
CreateResponse createResponse = new CreateResponseImpl(new CreateRequestImpl(metacard), null, Arrays.asList(metacard));
// when
CreateResponse response = plugin.process(createResponse);
// then
verify(endpoint).addDocument(isA(HttpHeaders.class), isA(UriInfo.class), isA(InputStream.class));
assertThat(response, sameInstance(createResponse));
}
Aggregations