use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType in project ddf by codice.
the class FederationAdminTest method testCreateLocalEntryWithFederationAdminException.
@Test(expected = FederationAdminException.class)
public void testCreateLocalEntryWithFederationAdminException() throws Exception {
RegistryPackageType registryObject = getRegistryObjectFromResource("/csw-full-registry-package.xml");
Map<String, Object> registryMap = getMapFromRegistryObject(registryObject);
Metacard metacard = getTestMetacard();
when(registryTransformer.transform(any(InputStream.class))).thenReturn(metacard);
when(federationAdminService.addRegistryEntry(any(Metacard.class))).thenThrow(FederationAdminException.class);
federationAdmin.createLocalEntry(registryMap);
verify(federationAdminService).addRegistryEntry(metacard);
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType in project ddf by codice.
the class FederationAdminTest method testUpdateLocalEntryWithMultipleExistingMetacards.
@Test(expected = FederationAdminException.class)
public void testUpdateLocalEntryWithMultipleExistingMetacards() throws Exception {
RegistryPackageType registryObject = getRegistryObjectFromResource("/csw-full-registry-package.xml");
Map<String, Object> registryMap = getMapFromRegistryObject(registryObject);
List<Metacard> existingMetacards = new ArrayList<>();
existingMetacards.add(getTestMetacard());
existingMetacards.add(getTestMetacard());
when(federationAdminService.getLocalRegistryMetacardsByRegistryIds(Collections.singletonList(registryObject.getId()))).thenReturn(existingMetacards);
federationAdmin.updateLocalEntry(registryMap);
verify(federationAdminService, never()).getLocalRegistryMetacardsByRegistryIds(Collections.singletonList(registryObject.getId()));
verify(registryTransformer, never()).transform(any(InputStream.class));
verify(federationAdminService, never()).updateRegistryEntry(any(Metacard.class));
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType in project ddf by codice.
the class FederationAdminTest method testUnbindEndpoint.
@Test
public void testUnbindEndpoint() throws Exception {
List<RegistryPackageType> regObjects = Collections.singletonList((RegistryPackageType) getRegistryObjectFromResource("/csw-full-registry-package.xml"));
when(federationAdminService.getRegistryObjects()).thenReturn(regObjects);
mcard.setAttribute(RegistryObjectMetacardType.REGISTRY_ID, "urn:uuid:2014ca7f59ac46f495e32b4a67a51276");
when(federationAdminService.getRegistryMetacards()).thenReturn(Collections.singletonList(mcard));
ServiceReference reference = mock(ServiceReference.class);
CatalogEndpoint endpoint = mock(CatalogEndpoint.class);
Map<String, String> props = new HashMap<>();
props.put(CatalogEndpoint.ID_KEY, "myId");
when(endpoint.getEndpointProperties()).thenReturn(props);
when(context.getService(reference)).thenReturn(endpoint);
federationAdmin.bindEndpoint(reference);
federationAdmin.unbindEndpoint(reference);
Map<String, Object> autoValues = (Map<String, Object>) federationAdmin.getLocalNodes().get("autoPopulateValues");
assertThat(autoValues.size(), is(1));
Collection bindingValues = (Collection) autoValues.get("ServiceBinding");
assertThat(bindingValues.size(), is(0));
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType in project ddf by codice.
the class FederationAdminTest method testGetLocalNodes.
@Test
public void testGetLocalNodes() throws Exception {
RegistryPackageType registryObject = getRegistryObjectFromResource("/csw-registry-package-smaller.xml");
Map<String, Object> registryObjectMap = new RegistryPackageWebConverter().convert(registryObject);
List<RegistryPackageType> registryPackages = new ArrayList<>();
registryPackages.add((RegistryPackageType) registryObject);
when(federationAdminService.getLocalRegistryObjects()).thenReturn(registryPackages);
Map<String, Object> localNodes = federationAdmin.getLocalNodes();
Map<String, Object> localNode = ((List<Map<String, Object>>) localNodes.get(LOCAL_NODE_KEY)).get(0);
verify(federationAdminService).getLocalRegistryObjects();
assertThat(localNode, is(equalTo(registryObjectMap)));
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType in project ddf by codice.
the class FederationAdminTest method getRegistryObjectFromResource.
private RegistryPackageType getRegistryObjectFromResource(String path) throws ParserException {
RegistryObjectType registryObject = null;
JAXBElement<RegistryObjectType> jaxbRegistryObject = parser.unmarshal(configurator, JAXBElement.class, getClass().getResourceAsStream(path));
if (jaxbRegistryObject != null) {
registryObject = jaxbRegistryObject.getValue();
}
return (RegistryPackageType) registryObject;
}
Aggregations