use of com.mesosphere.sdk.state.StateStoreException in project dcos-commons by mesosphere.
the class StateQueriesTest method testFailedUpload.
@Test
public void testFailedUpload() throws IOException {
InputStream inputStream = new ByteArrayInputStream(FILE_CONTENT.getBytes(StateQueries.FILE_ENCODING));
when(formDataContentDisposition.getFileName()).thenReturn(FILE_NAME);
when(formDataContentDisposition.getSize()).thenReturn((long) FILE_CONTENT.getBytes(StateQueries.FILE_ENCODING).length);
doThrow(new StateStoreException(new PersisterException(Reason.STORAGE_ERROR, "Failed to store"))).when(mockStateStore).storeProperty(StateQueries.FILE_NAME_PREFIX + FILE_NAME, FILE_CONTENT.getBytes(StateQueries.FILE_ENCODING));
Response response = StateQueries.putFile(mockStateStore, inputStream, formDataContentDisposition);
assertEquals(500, response.getStatus());
}
use of com.mesosphere.sdk.state.StateStoreException in project dcos-commons by mesosphere.
the class StateQueriesTest method testGetPropertyFails.
@Test
public void testGetPropertyFails() {
when(mockStateStore.fetchProperty("foo")).thenThrow(new StateStoreException(Reason.UNKNOWN, "hi"));
Response response = StateQueries.getProperty(mockStateStore, new StringPropertyDeserializer(), "foo");
assertEquals(500, response.getStatus());
}
use of com.mesosphere.sdk.state.StateStoreException in project dcos-commons by mesosphere.
the class StateQueriesTest method testGetPropertyMissing.
@Test
public void testGetPropertyMissing() {
when(mockStateStore.fetchProperty("foo")).thenThrow(new StateStoreException(Reason.NOT_FOUND, "hi"));
Response response = StateQueries.getProperty(mockStateStore, new StringPropertyDeserializer(), "foo");
assertEquals(404, response.getStatus());
}
use of com.mesosphere.sdk.state.StateStoreException in project dcos-commons by mesosphere.
the class StateQueriesTest method testGetFrameworkIdFails.
@Test
public void testGetFrameworkIdFails() {
when(mockFrameworkStore.fetchFrameworkId()).thenThrow(new StateStoreException(Reason.UNKNOWN, "hi"));
Response response = StateQueries.getFrameworkId(mockFrameworkStore);
assertEquals(500, response.getStatus());
}
use of com.mesosphere.sdk.state.StateStoreException in project dcos-commons by mesosphere.
the class StateQueriesTest method testGetPropertyKeysFails.
@Test
public void testGetPropertyKeysFails() {
when(mockStateStore.fetchPropertyKeys()).thenThrow(new StateStoreException(Reason.UNKNOWN, "hi"));
Response response = StateQueries.getPropertyKeys(mockStateStore);
assertEquals(500, response.getStatus());
}
Aggregations