use of com.yahoo.ycsb.StringByteIterator in project YCSB by brianfrankcooper.
the class RestClientTest method update_404.
@Test
public void update_404() {
HashMap<String, ByteIterator> data = new HashMap<String, ByteIterator>();
data.put(DATA_TAG, new StringByteIterator(INPUT_DATA));
Status status = rc.update(null, ABSENT_RESOURCE, data);
assertEquals(Status.NOT_FOUND, status);
}
use of com.yahoo.ycsb.StringByteIterator in project YCSB by brianfrankcooper.
the class RestClientTest method update_403.
@Test
public void update_403() {
HashMap<String, ByteIterator> data = new HashMap<String, ByteIterator>();
data.put(DATA_TAG, new StringByteIterator(INPUT_DATA));
Status status = rc.update(null, UNAUTHORIZED_RESOURCE, data);
assertEquals(Status.FORBIDDEN, status);
}
use of com.yahoo.ycsb.StringByteIterator in project YCSB by brianfrankcooper.
the class RestClientTest method insert_403.
@Test
public void insert_403() {
HashMap<String, ByteIterator> data = new HashMap<String, ByteIterator>();
data.put(DATA_TAG, new StringByteIterator(INPUT_DATA));
Status status = rc.insert(null, UNAUTHORIZED_RESOURCE, data);
assertEquals(Status.FORBIDDEN, status);
}
use of com.yahoo.ycsb.StringByteIterator in project YCSB by brianfrankcooper.
the class RestClientTest method insert_500.
@Test
public void insert_500() {
HashMap<String, ByteIterator> data = new HashMap<String, ByteIterator>();
data.put(DATA_TAG, new StringByteIterator(INPUT_DATA));
Status status = rc.insert(null, INVALID_RESOURCE, data);
assertEquals(Status.ERROR, status);
}
use of com.yahoo.ycsb.StringByteIterator in project YCSB by brianfrankcooper.
the class OrientDBClientTest method updateTest.
@Test
public void updateTest() {
String preupdateString = "preupdate";
String user0 = "user0";
String user1 = "user1";
String user2 = "user2";
OPartitionedDatabasePool pool = orientDBClient.getDatabasePool();
try (ODatabaseDocumentTx db = pool.acquire()) {
// Manually insert three documents
for (String key : Arrays.asList(user0, user1, user2)) {
ODocument doc = new ODocument(CLASS);
for (int i = 0; i < NUM_FIELDS; i++) {
doc.field(FIELD_PREFIX + i, preupdateString);
}
doc.save();
ODictionary<ORecord> dictionary = db.getDictionary();
dictionary.put(key, doc);
}
}
HashMap<String, ByteIterator> updateMap = new HashMap<>();
for (int i = 0; i < NUM_FIELDS; i++) {
updateMap.put(FIELD_PREFIX + i, new StringByteIterator(buildDeterministicValue(user1, FIELD_PREFIX + i)));
}
orientDBClient.update(CLASS, user1, updateMap);
try (ODatabaseDocumentTx db = pool.acquire()) {
ODictionary<ORecord> dictionary = db.getDictionary();
// Ensure that user0 record was not changed
ODocument result = dictionary.get(user0);
for (int i = 0; i < NUM_FIELDS; i++) {
assertEquals("Assert first row fields contain preupdateString", result.field(FIELD_PREFIX + i), preupdateString);
}
// Check that all the columns have expected values for user1 record
result = dictionary.get(user1);
for (int i = 0; i < NUM_FIELDS; i++) {
assertEquals("Assert updated row fields are correct", result.field(FIELD_PREFIX + i), updateMap.get(FIELD_PREFIX + i).toString());
}
// Ensure that user2 record was not changed
result = dictionary.get(user2);
for (int i = 0; i < NUM_FIELDS; i++) {
assertEquals("Assert third row fields contain preupdateString", result.field(FIELD_PREFIX + i), preupdateString);
}
}
}
Aggregations