Search in sources :

Example 6 with Product

use of org.codice.alliance.nsili.common.UID.Product in project alliance by codice.

the class OrderMgrImplTest method testIsAvailable.

@Test
public void testIsAvailable() throws Exception {
    MetacardImpl testMetacard = new MetacardImpl();
    testMetacard.setId(testMetacardId);
    testMetacard.setTitle("JUnit Test Card");
    Result testResult = new ResultImpl(testMetacard);
    DAG dag = ResultDAGConverter.convertResult(testResult, orb, rootPOA, new ArrayList<>(), new HashMap<>());
    Product product = ProductHelper.extract(dag.nodes[0].value);
    boolean avail = orderMgr.is_available(product, null);
    assertThat(avail, is(false));
    avail = orderMgr.is_available(null, null);
    assertThat(avail, is(false));
}
Also used : Product(org.codice.alliance.nsili.common.UID.Product) ResultImpl(ddf.catalog.data.impl.ResultImpl) DAG(org.codice.alliance.nsili.common.UCO.DAG) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Result(ddf.catalog.data.Result) Test(org.junit.Test)

Example 7 with Product

use of org.codice.alliance.nsili.common.UID.Product in project alliance by codice.

the class ProductMgrImplTest method testGetRelatedFilesWithBadPort.

@Test
public void testGetRelatedFilesWithBadPort() throws Exception {
    MetacardImpl testMetacard = new MetacardImpl();
    testMetacard.setId(testMetacardId);
    testMetacard.setTitle("JUnit Test Card");
    Result testResult = new ResultImpl(testMetacard);
    DAG dag = ResultDAGConverter.convertResult(testResult, orb, rootPOA, new ArrayList<>(), new HashMap<>());
    Product product = ProductHelper.extract(dag.nodes[0].value);
    Product[] products = new Product[] { product };
    String userName = "";
    String password = "";
    String hostName = "localhost";
    String pathName = "/nsili/file";
    FileLocation location = new FileLocation(userName, password, hostName, pathName, null);
    NameValue[] props = new NameValue[1];
    Any portAny = orb.create_any();
    portAny.insert_string("NOPE");
    NameValue prop = new NameValue("PORT", portAny);
    props[0] = prop;
    GetRelatedFilesRequest request = productMgr.get_related_files(products, location, NsiliConstants.THUMBNAIL_TYPE, props);
    assertThat(request, notNullValue());
}
Also used : Product(org.codice.alliance.nsili.common.UID.Product) ResultImpl(ddf.catalog.data.impl.ResultImpl) DAG(org.codice.alliance.nsili.common.UCO.DAG) Any(org.omg.CORBA.Any) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Result(ddf.catalog.data.Result) NameValue(org.codice.alliance.nsili.common.UCO.NameValue) FileLocation(org.codice.alliance.nsili.common.UCO.FileLocation) GetRelatedFilesRequest(org.codice.alliance.nsili.common.GIAS.GetRelatedFilesRequest) Test(org.junit.Test)

Example 8 with Product

use of org.codice.alliance.nsili.common.UID.Product in project alliance by codice.

the class ProductMgrImpl method get_related_files.

@Override
public GetRelatedFilesRequest get_related_files(Product[] products, FileLocation location, String type, NameValue[] properties) throws ProcessingFault, InvalidInputParameter, SystemFault {
    String id = UUID.randomUUID().toString();
    try {
        List<Metacard> metacards = new ArrayList<>();
        AccessManagerImpl accessMgr = getAccessManager();
        for (Product product : products) {
            Metacard metacard = accessMgr.getMetacard(accessMgr.getProductId(product));
            if (metacard != null) {
                metacards.add(metacard);
            }
        }
        Integer port = getPort(properties);
        GetRelatedFilesRequestImpl getRelatedFilesRequest = new GetRelatedFilesRequestImpl(metacards, location, type, port);
        _poa().activate_object_with_id(id.getBytes(Charset.forName(NsiliEndpoint.ENCODING)), getRelatedFilesRequest);
    } catch (ServantAlreadyActive | ObjectAlreadyActive | WrongPolicy | WrongAdapter | UnsupportedEncodingException e) {
        LOGGER.debug("get_related_files : Unable to activate getRelatedFilesRequest object.", e);
    }
    org.omg.CORBA.Object obj = _poa().create_reference_with_id(id.getBytes(Charset.forName(NsiliEndpoint.ENCODING)), GetRelatedFilesRequestHelper.id());
    GetRelatedFilesRequest queryRequest = GetRelatedFilesRequestHelper.narrow(obj);
    return queryRequest;
}
Also used : GetRelatedFilesRequestImpl(org.codice.alliance.nsili.endpoint.requests.GetRelatedFilesRequestImpl) ObjectAlreadyActive(org.omg.PortableServer.POAPackage.ObjectAlreadyActive) ArrayList(java.util.ArrayList) Product(org.codice.alliance.nsili.common.UID.Product) UnsupportedEncodingException(java.io.UnsupportedEncodingException) WrongPolicy(org.omg.PortableServer.POAPackage.WrongPolicy) Metacard(ddf.catalog.data.Metacard) WrongAdapter(org.omg.PortableServer.POAPackage.WrongAdapter) GetRelatedFilesRequest(org.codice.alliance.nsili.common.GIAS.GetRelatedFilesRequest) ServantAlreadyActive(org.omg.PortableServer.POAPackage.ServantAlreadyActive)

Example 9 with Product

use of org.codice.alliance.nsili.common.UID.Product in project alliance by codice.

the class ProductMgrImplTest method testGetParametersNullDesiredParams.

@Test
public void testGetParametersNullDesiredParams() throws Exception {
    MetacardImpl testMetacard = new MetacardImpl();
    testMetacard.setId(testMetacardId);
    testMetacard.setTitle("JUnit Test Card");
    Result testResult = new ResultImpl(testMetacard);
    DAG dag = ResultDAGConverter.convertResult(testResult, orb, rootPOA, new ArrayList<>(), new HashMap<>());
    Product product = ProductHelper.extract(dag.nodes[0].value);
    GetParametersRequest parametersRequest = productMgr.get_parameters(product, null, null);
    assertThat(parametersRequest, notNullValue());
    DAGHolder dagHolder = new DAGHolder();
    parametersRequest.complete(dagHolder);
    assertThat(dagHolder, notNullValue());
}
Also used : DAGHolder(org.codice.alliance.nsili.common.UCO.DAGHolder) Product(org.codice.alliance.nsili.common.UID.Product) ResultImpl(ddf.catalog.data.impl.ResultImpl) DAG(org.codice.alliance.nsili.common.UCO.DAG) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) GetParametersRequest(org.codice.alliance.nsili.common.GIAS.GetParametersRequest) Result(ddf.catalog.data.Result) Test(org.junit.Test)

Example 10 with Product

use of org.codice.alliance.nsili.common.UID.Product in project alliance by codice.

the class ProductMgrImplTest method testIsAvailable.

@Test
public void testIsAvailable() throws Exception {
    MetacardImpl testMetacard = new MetacardImpl();
    testMetacard.setId(testMetacardId);
    testMetacard.setTitle("JUnit Test Card");
    Result testResult = new ResultImpl(testMetacard);
    DAG dag = ResultDAGConverter.convertResult(testResult, orb, rootPOA, new ArrayList<>(), new HashMap<>());
    Product product = ProductHelper.extract(dag.nodes[0].value);
    boolean avail = productMgr.is_available(product, null);
    assertThat(avail, is(false));
    avail = productMgr.is_available(null, null);
    assertThat(avail, is(false));
}
Also used : Product(org.codice.alliance.nsili.common.UID.Product) ResultImpl(ddf.catalog.data.impl.ResultImpl) DAG(org.codice.alliance.nsili.common.UCO.DAG) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Result(ddf.catalog.data.Result) Test(org.junit.Test)

Aggregations

Product (org.codice.alliance.nsili.common.UID.Product)16 DAG (org.codice.alliance.nsili.common.UCO.DAG)10 Result (ddf.catalog.data.Result)9 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)9 ResultImpl (ddf.catalog.data.impl.ResultImpl)9 Test (org.junit.Test)9 GetRelatedFilesRequest (org.codice.alliance.nsili.common.GIAS.GetRelatedFilesRequest)5 NameValue (org.codice.alliance.nsili.common.UCO.NameValue)5 Any (org.omg.CORBA.Any)5 FileLocation (org.codice.alliance.nsili.common.UCO.FileLocation)4 ArrayList (java.util.ArrayList)3 Metacard (ddf.catalog.data.Metacard)2 GetParametersRequest (org.codice.alliance.nsili.common.GIAS.GetParametersRequest)2 PackageElement (org.codice.alliance.nsili.common.GIAS.PackageElement)2 DAGHolder (org.codice.alliance.nsili.common.UCO.DAGHolder)2 ObjectAlreadyActive (org.omg.PortableServer.POAPackage.ObjectAlreadyActive)2 ServantAlreadyActive (org.omg.PortableServer.POAPackage.ServantAlreadyActive)2 WrongPolicy (org.omg.PortableServer.POAPackage.WrongPolicy)2 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)1 QueryRequest (ddf.catalog.operation.QueryRequest)1