Search in sources :

Example 31 with RegistryPackageType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType in project ddf by codice.

the class FederationAdminTest method testBindEndpointNullReference.

@Test
public void testBindEndpointNullReference() 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));
    federationAdmin.bindEndpoint(null);
    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 : RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) Collection(java.util.Collection) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 32 with RegistryPackageType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType in project ddf by codice.

the class FederationAdminTest method testUpdateLocalEntryWithEmptyExistingList.

@Test(expected = FederationAdminException.class)
public void testUpdateLocalEntryWithEmptyExistingList() throws Exception {
    RegistryPackageType registryObject = getRegistryObjectFromResource("/csw-full-registry-package.xml");
    Map<String, Object> registryMap = getMapFromRegistryObject(registryObject);
    List<Metacard> existingMetacards = new ArrayList<>();
    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 33 with RegistryPackageType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType in project ddf by codice.

the class FederationAdminTest method testCreateLocalEntry.

@Test
public void testCreateLocalEntry() throws Exception {
    String metacardId = "metacardId";
    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))).thenReturn(metacardId);
    String createdMetacardId = federationAdmin.createLocalEntry(registryMap);
    assertThat(createdMetacardId, is(equalTo(metacardId)));
    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 34 with RegistryPackageType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType in project ddf by codice.

the class FederationAdminServiceImplTest method testGetRegistryObjectByMetacardId.

@Test
public void testGetRegistryObjectByMetacardId() throws Exception {
    Metacard metacard = testMetacard;
    QueryRequest request = getTestQueryRequest();
    QueryResponse response = getPopulatedTestQueryResponse(request, metacard);
    RegistryPackageType expectedRegistryPackage = getTestRegistryPackage();
    JAXBElement<RegistryPackageType> jaxbRegistryPackage = EbrimConstants.RIM_FACTORY.createRegistryPackage(expectedRegistryPackage);
    when(catalogFramework.query(any(QueryRequest.class))).thenReturn(response);
    when(parser.unmarshal(any(ParserConfigurator.class), eq(JAXBElement.class), any(InputStream.class))).thenReturn(jaxbRegistryPackage);
    RegistryPackageType registryPackage = federationAdminServiceImpl.getRegistryObjectByRegistryId(TEST_METACARD_ID, null);
    assertThat(registryPackage, is(sameInstance(expectedRegistryPackage)));
}
Also used : ParserConfigurator(org.codice.ddf.parser.ParserConfigurator) Metacard(ddf.catalog.data.Metacard) QueryRequest(ddf.catalog.operation.QueryRequest) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) InputStream(java.io.InputStream) QueryResponse(ddf.catalog.operation.QueryResponse) JAXBElement(javax.xml.bind.JAXBElement) Test(org.junit.Test)

Example 35 with RegistryPackageType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType in project ddf by codice.

the class FederationAdminServiceImplTest method testGetRegistryObjectsWithNoRegistryEntries.

@Test
public void testGetRegistryObjectsWithNoRegistryEntries() throws Exception {
    QueryRequest request = getTestQueryRequest();
    QueryResponse response = getPopulatedTestQueryResponse(request);
    when(catalogFramework.query(any(QueryRequest.class))).thenReturn(response);
    List<RegistryPackageType> packages = federationAdminServiceImpl.getRegistryObjects();
    assertThat(packages, empty());
    verify(catalogFramework).query(any(QueryRequest.class));
    verify(parser, never()).unmarshal(any(ParserConfigurator.class), eq(JAXBElement.class), any(InputStream.class));
}
Also used : ParserConfigurator(org.codice.ddf.parser.ParserConfigurator) QueryRequest(ddf.catalog.operation.QueryRequest) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) InputStream(java.io.InputStream) QueryResponse(ddf.catalog.operation.QueryResponse) JAXBElement(javax.xml.bind.JAXBElement) Test(org.junit.Test)

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