use of codeu.model.data.Conversation in project CodeU-Spring-2018 by jwang281.
the class PersistentDataStoreTest method testSaveAndLoadConversations.
@Test
public void testSaveAndLoadConversations() throws PersistentDataStoreException {
UUID idOne = UUID.randomUUID();
UUID ownerOne = UUID.randomUUID();
String titleOne = "Test_Title";
Instant creationOne = Instant.ofEpochMilli(1000);
Conversation inputConversationOne = new Conversation(idOne, ownerOne, titleOne, creationOne);
UUID idTwo = UUID.randomUUID();
UUID ownerTwo = UUID.randomUUID();
String titleTwo = "Test_Title_Two";
Instant creationTwo = Instant.ofEpochMilli(2000);
Conversation inputConversationTwo = new Conversation(idTwo, ownerTwo, titleTwo, creationTwo);
// save
persistentDataStore.writeThrough(inputConversationOne);
persistentDataStore.writeThrough(inputConversationTwo);
// load
List<Conversation> resultConversations = persistentDataStore.loadConversations();
// confirm that what we saved matches what we loaded
Conversation resultConversationOne = resultConversations.get(0);
Assert.assertEquals(idOne, resultConversationOne.getId());
Assert.assertEquals(ownerOne, resultConversationOne.getOwnerId());
Assert.assertEquals(titleOne, resultConversationOne.getTitle());
Assert.assertEquals(creationOne, resultConversationOne.getCreationTime());
Conversation resultConversationTwo = resultConversations.get(1);
Assert.assertEquals(idTwo, resultConversationTwo.getId());
Assert.assertEquals(ownerTwo, resultConversationTwo.getOwnerId());
Assert.assertEquals(titleTwo, resultConversationTwo.getTitle());
Assert.assertEquals(creationTwo, resultConversationTwo.getCreationTime());
}
use of codeu.model.data.Conversation in project CodeU-Spring-2018 by jwang281.
the class DefaultDataStore method addRandomConversations.
private void addRandomConversations() {
for (int i = 1; i <= DEFAULT_CONVERSATION_COUNT; i++) {
User user = getRandomElement(users);
String title = "Conversation_" + i;
Conversation conversation = new Conversation(UUID.randomUUID(), user.getId(), title, Instant.now());
PersistentStorageAgent.getInstance().writeThrough(conversation);
conversations.add(conversation);
}
}
Aggregations