use of uk.gov.gchq.gaffer.proxystore.operation.GetProxyProperties in project Gaffer by gchq.
the class GetProxyPropertiesHandler method doOperation.
/**
* This implementation could work with with any store and properties but gets ONLY the Proxy Properties value from the Proxy store.
*
* @param operation the {@link GetProxyProperties} to be executed
* @param context the operation chain context, containing the user who executed the operation
* @param store the {@link Store} the operation should be run on
* @return the proxy specific properties only.
* @throws OperationException Error making return string map
*/
@Override
public Map<String, Object> doOperation(final GetProxyProperties operation, final Context context, final Store store) throws OperationException {
try {
ProxyProperties properties = new ProxyProperties(store.getProperties().getProperties());
HashMap<String, Object> rtn = new HashMap<>();
rtn.put(GAFFER_CONTEXT_ROOT, properties.getGafferContextRoot());
rtn.put(GAFFER_HOST, properties.getGafferHost());
rtn.put(GAFFER_PORT, String.valueOf(properties.getGafferPort()));
rtn.put(CONNECT_TIMEOUT, String.valueOf(properties.getConnectTimeout()));
rtn.put(READ_TIMEOUT, String.valueOf(properties.getReadTimeout()));
rtn.put(URL_INFERRED, properties.getGafferUrl().toString());
return rtn;
} catch (final Exception e) {
throw new OperationException("Error making return string map", e);
}
}
use of uk.gov.gchq.gaffer.proxystore.operation.GetProxyProperties in project Gaffer by gchq.
the class GetProxyPropertiesHandlerTest method shouldGetURl.
@Test
public void shouldGetURl() throws Exception {
// given
Store store = Mockito.mock(Store.class);
ProxyProperties properties = new ProxyProperties();
properties.set(GAFFER_PORT, PORT);
properties.set(GAFFER_HOST, HOST);
properties.set(GAFFER_CONTEXT_ROOT, DEFAULT_GAFFER_CONTEXT_ROOT);
properties.setConnectTimeout(999);
properties.set(EXTRA_KEY, "value");
Mockito.when(store.getProperties()).thenReturn(properties);
HashMap expected = getExpected(properties);
// when
Map<String, Object> actual = new GetProxyPropertiesHandler().doOperation(new GetProxyProperties(), new Context(), store);
// then
assertFalse(actual.containsKey(EXTRA_KEY));
assertTrue(actual.containsKey(URL_INFERRED));
assertEquals(expected, actual);
}
Aggregations