use of com.yahoo.rdl.Struct in project athenz by yahoo.
the class ZMSFileChangeLogStoreCommonTest method testDeleteException.
@Test
public void testDeleteException() throws IOException {
ZMSFileChangeLogStoreCommon fstore = new ZMSFileChangeLogStoreCommon(FSTORE_PATH);
// create the file
Struct data = new Struct();
data.put("key", "val1");
fstore.put("test1", JSON.bytes(data));
// update the helper to be our mock
FilesHelper helper = Mockito.mock(FilesHelper.class);
Mockito.doThrow(new IOException("io exception")).when(helper).delete(any());
fstore.filesHelper = helper;
try {
fstore.delete("test1");
fail();
} catch (Exception ex) {
assertTrue(true);
}
}
use of com.yahoo.rdl.Struct in project athenz by yahoo.
the class ZMSFileChangeLogStoreCommonTest method testGetNonExistent.
@Test
public void testGetNonExistent() {
ZMSFileChangeLogStoreCommon fstore = new ZMSFileChangeLogStoreCommon(FSTORE_PATH);
Struct st = fstore.get("NotExistent", Struct.class);
assertNull(st);
}
use of com.yahoo.rdl.Struct in project athenz by yahoo.
the class ZMSFileChangeLogStoreCommonTest method testGetExistent.
@Test
public void testGetExistent() {
ZMSFileChangeLogStoreCommon fstore = new ZMSFileChangeLogStoreCommon(FSTORE_PATH);
Struct data = new Struct();
data.put("key", "val1");
fstore.put("test1", JSON.bytes(data));
Struct st = fstore.get("test1", Struct.class);
assertNotNull(st);
assertEquals(st.get("key"), "val1");
}
use of com.yahoo.rdl.Struct in project athenz by yahoo.
the class ZMSFileChangeLogStoreCommonTest method testJsonValueAsBytes.
@Test
public void testJsonValueAsBytes() {
ZMSFileChangeLogStoreCommon fstore = new ZMSFileChangeLogStoreCommon(FSTORE_PATH);
ObjectMapper mapper = Mockito.mock(ObjectMapper.class);
Mockito.when(mapper.writerWithView(Struct.class)).thenThrow(new RuntimeException("invalid class"));
fstore.jsonMapper = mapper;
Struct testStruct = new Struct();
testStruct.putIfAbsent("key", "value");
assertNull(fstore.jsonValueAsBytes(testStruct, Struct.class));
}
use of com.yahoo.rdl.Struct in project athenz by yahoo.
the class ZMSFileChangeLogStoreCommonTest method testGetJsonException.
@Test
public void testGetJsonException() throws IOException {
ZMSFileChangeLogStoreCommon fstore = new ZMSFileChangeLogStoreCommon(FSTORE_PATH);
Struct data = new Struct();
data.put("key", "val1");
fstore.put("test1", JSON.bytes(data));
ObjectMapper mapper = Mockito.mock(ObjectMapper.class);
File file = new File(FSTORE_PATH, "test1");
Mockito.when(mapper.readValue(file, Struct.class)).thenThrow(new RuntimeException("invalid class"));
fstore.jsonMapper = mapper;
assertNull(fstore.get("test1", Struct.class));
}
Aggregations