Search in sources :

Example 31 with ResourceRequest

use of ddf.catalog.operation.ResourceRequest in project ddf by codice.

the class TestResourceUsagePlugin method testPreResourcePersistenceException.

@Test
public void testPreResourcePersistenceException() throws StopProcessingException, PluginExecutionException, PersistenceException {
    doThrow(PersistenceException.class).when(attributeStore).getCurrentDataUsageByUser(anyString());
    ResourceRequest originalRequest = getMockLocalResourceRequest(RESOURCE_SIZE, TEST_USER);
    ResourceRequest request = plugin.process(originalRequest);
    assertThat(request, notNullValue());
    assertThat(request, is(originalRequest));
}
Also used : ResourceRequest(ddf.catalog.operation.ResourceRequest) Test(org.junit.Test)

Example 32 with ResourceRequest

use of ddf.catalog.operation.ResourceRequest in project ddf by codice.

the class TestResourceUsagePlugin method testPreResourceValidSize.

@Test
public void testPreResourceValidSize() throws StopProcessingException, PluginExecutionException, PersistenceException {
    ArgumentCaptor<String> usernameArg = ArgumentCaptor.forClass(String.class);
    ResourceRequest originalRequest = getMockLocalResourceRequest(RESOURCE_SIZE, TEST_USER);
    ResourceRequest request = plugin.process(originalRequest);
    assertThat(request, notNullValue());
    assertThat(request, is(originalRequest));
    verify(attributeStore).getDataLimitByUser(usernameArg.capture());
    assertThat(usernameArg.getValue(), is(TEST_USER));
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) ResourceRequest(ddf.catalog.operation.ResourceRequest) Test(org.junit.Test)

Example 33 with ResourceRequest

use of ddf.catalog.operation.ResourceRequest in project ddf by codice.

the class TestResourceUsagePlugin method testPreResourceRemoteSourceValidSize.

@Test
public void testPreResourceRemoteSourceValidSize() throws Exception {
    plugin.setMonitorLocalSources(false);
    ArgumentCaptor<String> usernameArg = ArgumentCaptor.forClass(String.class);
    ResourceRequest originalRequest = getMockRemoteResourceRequest(RESOURCE_SIZE, TEST_USER);
    ResourceRequest request = plugin.process(originalRequest);
    assertThat(request, notNullValue());
    assertThat(request, is(originalRequest));
    verify(attributeStore).getDataLimitByUser(usernameArg.capture());
    assertThat(usernameArg.getValue(), is(TEST_USER));
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) ResourceRequest(ddf.catalog.operation.ResourceRequest) Test(org.junit.Test)

Example 34 with ResourceRequest

use of ddf.catalog.operation.ResourceRequest in project ddf by codice.

the class TestResourceUsagePlugin method testPreResourceSizeExceedsDataLimit.

@Test(expected = DataUsageLimitExceededException.class)
public void testPreResourceSizeExceedsDataLimit() throws StopProcessingException, PluginExecutionException, PersistenceException {
    doReturn(DATA_LIMIT).when(attributeStore).getCurrentDataUsageByUser(anyString());
    ResourceRequest originalRequest = getMockLocalResourceRequest(RESOURCE_SIZE_LARGE, TEST_USER);
    plugin.process(originalRequest);
}
Also used : ResourceRequest(ddf.catalog.operation.ResourceRequest) Test(org.junit.Test)

Aggregations

ResourceRequest (ddf.catalog.operation.ResourceRequest)34 Test (org.junit.Test)20 ResourceResponse (ddf.catalog.operation.ResourceResponse)11 Metacard (ddf.catalog.data.Metacard)10 Resource (ddf.catalog.resource.Resource)7 Serializable (java.io.Serializable)7 HashMap (java.util.HashMap)7 ResourceRequestById (ddf.catalog.operation.impl.ResourceRequestById)6 ResourceNotFoundException (ddf.catalog.resource.ResourceNotFoundException)6 ResourceNotSupportedException (ddf.catalog.resource.ResourceNotSupportedException)6 IOException (java.io.IOException)6 Matchers.anyString (org.mockito.Matchers.anyString)6 QueryRequest (ddf.catalog.operation.QueryRequest)5 ResourceRetriever (ddf.catalog.resourceretriever.ResourceRetriever)5 Result (ddf.catalog.data.Result)4 DeleteRequest (ddf.catalog.operation.DeleteRequest)4 QueryResponse (ddf.catalog.operation.QueryResponse)4 MimeType (javax.activation.MimeType)4 Subject (ddf.security.Subject)3 ArrayList (java.util.ArrayList)3