use of v7db.files.spi.StoredContent in project v7files by thiloplanz.
the class MongoReferenceTrackingTest method testUpdate.
public void testUpdate() throws MongoException, IOException {
byte[] oldRef = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
prepareMockData("test.v7files.refs", new BasicBSONObject("_id", "x").append("refs", new Object[] { oldRef }).append("refHistory", new Object[] { oldRef }));
Mongo mongo = getMongo();
ReferenceTracking refs = new MongoReferenceTracking(mongo.getDB("test").getCollection("v7files.refs"));
refs.updateReferences("x", new StoredContent(new byte[20], 1000));
assertMockMongoFieldContains(new byte[20], "test.v7files.refs", "x", "refs");
assertMockMongoFieldContains(new byte[20], "test.v7files.refs", "x", "refHistory");
assertMockMongoFieldDoesNotContain(oldRef, "test.v7files.refs", "x", "refs");
assertMockMongoFieldContains(oldRef, "test.v7files.refs", "x", "refHistory");
mongo.close();
}
Aggregations