public void testUseCase() throws Exception {
byte[] content = "Dummy content".getBytes();
Object interactId = fileManager.startInteraction();
GFile file = fileManager.factoryGFile(interactId, "test");
fileManager.persistNew(interactId, file);
file.addProperty("name1", "value1");
file.addProperty("name2", "value2");
file.addProperty("name3", "value3");
file.setContent(new ByteArrayInputStream(content));
fileManager.endInteraction(interactId);
interactId = fileManager.startInteraction();
InputStream in = file.getInputStream();
int read;
int nbRead = 0;
while ( -1 < (read = in.read()) ) {
assertEquals("Wrong content", content[nbRead], read);
nbRead++;
}
Map properties = file.getProperties();
assertEquals("Properties issue", 3, properties.size());
assertEquals("Properties issue", "value1", properties.get("name1"));
assertEquals("Properties issue", "value2", properties.get("name2"));
assertEquals("Properties issue", "value3", properties.get("name3"));
file.addProperty("name4", "value4");
file.removeProperty("name3");
fileManager.persistUpdate(interactId, file);
fileManager.endInteraction(interactId);
interactId = fileManager.startInteraction();
properties = file.getProperties();
assertEquals("Properties issue", 3, properties.size());
assertEquals("Properties issue", "value1", properties.get("name1"));
assertEquals("Properties issue", "value2", properties.get("name2"));
assertEquals("Properties issue", "value4", properties.get("name4"));
fileManager.persistDelete(interactId, file);