Search in sources :

Example 11 with RegistryPackageType

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);
}
Also used : Metacard(ddf.catalog.data.Metacard) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 12 with RegistryPackageType

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));
}
Also used : Metacard(ddf.catalog.data.Metacard) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 13 with RegistryPackageType

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));
}
Also used : HashMap(java.util.HashMap) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) Collection(java.util.Collection) CatalogEndpoint(ddf.catalog.endpoint.CatalogEndpoint) Map(java.util.Map) HashMap(java.util.HashMap) ServiceReference(org.osgi.framework.ServiceReference) Test(org.junit.Test)

Example 14 with RegistryPackageType

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)));
}
Also used : RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) RegistryPackageWebConverter(org.codice.ddf.registry.schemabindings.converter.web.RegistryPackageWebConverter) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Matchers.anyList(org.mockito.Matchers.anyList) Test(org.junit.Test)

Example 15 with RegistryPackageType

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;
}
Also used : RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) RegistryObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType)

Aggregations

RegistryPackageType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType)46 Test (org.junit.Test)26 Metacard (ddf.catalog.data.Metacard)16 InputStream (java.io.InputStream)12 RegistryObjectListType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectListType)11 ArrayList (java.util.ArrayList)9 JAXBElement (javax.xml.bind.JAXBElement)9 ExtrinsicObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType)9 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)7 HashMap (java.util.HashMap)5 IOException (java.io.IOException)4 Map (java.util.Map)4 AssociationType1 (oasis.names.tc.ebxml_regrep.xsd.rim._3.AssociationType1)4 OrganizationType (oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType)4 PersonType (oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonType)4 RegistryObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType)4 ParserConfigurator (org.codice.ddf.parser.ParserConfigurator)4 FederationAdminException (org.codice.ddf.registry.federationadmin.service.internal.FederationAdminException)4 QueryRequest (ddf.catalog.operation.QueryRequest)3 QueryResponse (ddf.catalog.operation.QueryResponse)3