Search in sources :

Example 6 with NameListHolder

use of org.codice.alliance.nsili.common.UCO.NameListHolder in project alliance by codice.

the class GetRelatedFilesRequestImplTest method testNoThumbnail.

@Test
public void testNoThumbnail() throws Exception {
    NameListHolder locations = new NameListHolder();
    GetRelatedFilesRequestImpl noPortRequest = new GetRelatedFilesRequestImpl(getBadMetacards(), getTestFileLocation(), "THUMBNAIL", null);
    noPortRequest.setHttpClient(mockHttpClient);
    State state = noPortRequest.complete(locations);
    assertValidStateNoLocs(state, locations);
}
Also used : GetRelatedFilesRequestImpl(org.codice.alliance.nsili.endpoint.requests.GetRelatedFilesRequestImpl) State(org.codice.alliance.nsili.common.UCO.State) NameListHolder(org.codice.alliance.nsili.common.UCO.NameListHolder) Test(org.junit.Test)

Example 7 with NameListHolder

use of org.codice.alliance.nsili.common.UCO.NameListHolder in project alliance by codice.

the class GetRelatedFilesRequestImplTest method testComplete201.

@Test
public void testComplete201() throws Exception {
    when(mockHttpClient.execute(any(HttpUriRequest.class))).thenReturn(getGoodResponse(201));
    NameListHolder locations = new NameListHolder();
    State state = relatedFilesRequest.complete(locations);
    assertValidState(state, locations);
}
Also used : HttpUriRequest(org.apache.http.client.methods.HttpUriRequest) State(org.codice.alliance.nsili.common.UCO.State) NameListHolder(org.codice.alliance.nsili.common.UCO.NameListHolder) Test(org.junit.Test)

Example 8 with NameListHolder

use of org.codice.alliance.nsili.common.UCO.NameListHolder in project alliance by codice.

the class GetRelatedFilesRequestImplTest method testComplete202.

@Test
public void testComplete202() throws Exception {
    when(mockHttpClient.execute(any(HttpUriRequest.class))).thenReturn(getGoodResponse(202));
    NameListHolder locations = new NameListHolder();
    State state = relatedFilesRequest.complete(locations);
    assertValidState(state, locations);
}
Also used : HttpUriRequest(org.apache.http.client.methods.HttpUriRequest) State(org.codice.alliance.nsili.common.UCO.State) NameListHolder(org.codice.alliance.nsili.common.UCO.NameListHolder) Test(org.junit.Test)

Example 9 with NameListHolder

use of org.codice.alliance.nsili.common.UCO.NameListHolder in project alliance by codice.

the class GetRelatedFilesRequestImplTest method testNoHostLocation.

@Test
public void testNoHostLocation() throws Exception {
    FileLocation fileLocation = getTestFileLocation();
    fileLocation.host_name = "";
    NameListHolder locations = new NameListHolder();
    GetRelatedFilesRequestImpl noPortRequest = new GetRelatedFilesRequestImpl(getTestMetacards(), fileLocation, "THUMBNAIL", null);
    noPortRequest.setHttpClient(mockHttpClient);
    State state = noPortRequest.complete(locations);
    assertValidStateNoLocs(state, locations);
}
Also used : GetRelatedFilesRequestImpl(org.codice.alliance.nsili.endpoint.requests.GetRelatedFilesRequestImpl) State(org.codice.alliance.nsili.common.UCO.State) FileLocation(org.codice.alliance.nsili.common.UCO.FileLocation) NameListHolder(org.codice.alliance.nsili.common.UCO.NameListHolder) Test(org.junit.Test)

Example 10 with NameListHolder

use of org.codice.alliance.nsili.common.UCO.NameListHolder in project alliance by codice.

the class SampleNsiliClient method getRelatedFiles.

public String[] getRelatedFiles(Product product) throws Exception {
    if (productMgr != null) {
        LOGGER.info("Sending Get Related Files Request...");
        final FileLocation fileLocation = new FileLocation("user", "pass", "localhost", "/nsili/file", "");
        Any portAny = orb.create_any();
        portAny.insert_string(String.valueOf(listenPort));
        NameValue portProp = new NameValue("PORT", portAny);
        NameValue[] properties = new NameValue[] { portProp };
        Product[] products = { product };
        GetRelatedFilesRequest relatedFilesRequest = productMgr.get_related_files(products, fileLocation, NsiliConstants.THUMBNAIL_TYPE, properties);
        relatedFilesRequest.set_user_info(ALLIANCE);
        NameListHolder locations = new NameListHolder();
        relatedFilesRequest.complete(locations);
        String[] locationList = locations.value;
        if (locationList.length > 0) {
            LOGGER.info("Location List : ");
            for (String location : locationList) {
                LOGGER.info("\t Stored File: {}", location);
            }
        } else {
            LOGGER.info("No locations returned from Get Related Files Request");
        }
        return locationList;
    } else {
        LOGGER.warn("ProductMgr is not initialized, unable to get related files");
        return null;
    }
}
Also used : NameValue(org.codice.alliance.nsili.common.UCO.NameValue) FileLocation(org.codice.alliance.nsili.common.UCO.FileLocation) GetRelatedFilesRequest(org.codice.alliance.nsili.common.GIAS.GetRelatedFilesRequest) Product(org.codice.alliance.nsili.common.UID.Product) Any(org.omg.CORBA.Any) NameListHolder(org.codice.alliance.nsili.common.UCO.NameListHolder)

Aggregations

NameListHolder (org.codice.alliance.nsili.common.UCO.NameListHolder)10 State (org.codice.alliance.nsili.common.UCO.State)9 Test (org.junit.Test)9 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)5 GetRelatedFilesRequestImpl (org.codice.alliance.nsili.endpoint.requests.GetRelatedFilesRequestImpl)4 FileLocation (org.codice.alliance.nsili.common.UCO.FileLocation)2 GetRelatedFilesRequest (org.codice.alliance.nsili.common.GIAS.GetRelatedFilesRequest)1 NameValue (org.codice.alliance.nsili.common.UCO.NameValue)1 Product (org.codice.alliance.nsili.common.UID.Product)1 Any (org.omg.CORBA.Any)1