Search in sources :

Example 1 with StringPropertyDeserializer

use of com.mesosphere.sdk.http.types.StringPropertyDeserializer 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());
}
Also used : StateStoreException(com.mesosphere.sdk.state.StateStoreException) Response(javax.ws.rs.core.Response) StringPropertyDeserializer(com.mesosphere.sdk.http.types.StringPropertyDeserializer) StateStoreUtilsTest(com.mesosphere.sdk.state.StateStoreUtilsTest) Test(org.junit.Test)

Example 2 with StringPropertyDeserializer

use of com.mesosphere.sdk.http.types.StringPropertyDeserializer in project dcos-commons by mesosphere.

the class StateQueriesTest method testGetProperty.

@Test
public void testGetProperty() {
    byte[] property = "hello this is a property".getBytes(StandardCharsets.UTF_8);
    when(mockStateStore.fetchProperty("foo")).thenReturn(property);
    Response response = StateQueries.getProperty(mockStateStore, new StringPropertyDeserializer(), "foo");
    assertEquals(200, response.getStatus());
    assertEquals("hello this is a property", response.getEntity());
}
Also used : Response(javax.ws.rs.core.Response) StringPropertyDeserializer(com.mesosphere.sdk.http.types.StringPropertyDeserializer) StateStoreUtilsTest(com.mesosphere.sdk.state.StateStoreUtilsTest) Test(org.junit.Test)

Example 3 with StringPropertyDeserializer

use of com.mesosphere.sdk.http.types.StringPropertyDeserializer 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());
}
Also used : StateStoreException(com.mesosphere.sdk.state.StateStoreException) Response(javax.ws.rs.core.Response) StringPropertyDeserializer(com.mesosphere.sdk.http.types.StringPropertyDeserializer) StateStoreUtilsTest(com.mesosphere.sdk.state.StateStoreUtilsTest) Test(org.junit.Test)

Aggregations

StringPropertyDeserializer (com.mesosphere.sdk.http.types.StringPropertyDeserializer)3 StateStoreUtilsTest (com.mesosphere.sdk.state.StateStoreUtilsTest)3 Response (javax.ws.rs.core.Response)3 Test (org.junit.Test)3 StateStoreException (com.mesosphere.sdk.state.StateStoreException)2