use of codeu.model.data.User in project CodeU-Spring-2018 by jwang281.
the class UserStoreTest method testAddUser.
@Test
public void testAddUser() {
User inputUser = new User(UUID.randomUUID(), "test_username", "test_userpw", Instant.now());
userStore.addUser(inputUser);
User resultUser = userStore.getUser("test_username");
assertEquals(inputUser, resultUser);
Mockito.verify(mockPersistentStorageAgent).writeThrough(inputUser);
}
use of codeu.model.data.User in project CodeU-Spring-2018 by jwang281.
the class UserStoreTest method testGetUser_byUsername_found.
@Test
public void testGetUser_byUsername_found() {
User resultUser = userStore.getUser(USER_ONE.getName());
assertEquals(USER_ONE, resultUser);
}
use of codeu.model.data.User in project CodeU-Spring-2018 by jwang281.
the class PersistentDataStoreTest method testSaveAndLoadUsers.
@Test
public void testSaveAndLoadUsers() throws PersistentDataStoreException {
UUID idOne = UUID.randomUUID();
String nameOne = "test_username_one";
String pwOne = "test_password_one";
Instant creationOne = Instant.ofEpochMilli(1000);
User inputUserOne = new User(idOne, nameOne, pwOne, creationOne);
UUID idTwo = UUID.randomUUID();
String nameTwo = "test_username_two";
String pwTwo = "test_password_two";
Instant creationTwo = Instant.ofEpochMilli(2000);
User inputUserTwo = new User(idTwo, nameTwo, pwTwo, creationTwo);
// save
persistentDataStore.writeThrough(inputUserOne);
persistentDataStore.writeThrough(inputUserTwo);
// load
List<User> resultUsers = persistentDataStore.loadUsers();
// confirm that what we saved matches what we loaded
User resultUserOne = resultUsers.get(0);
Assert.assertEquals(idOne, resultUserOne.getId());
Assert.assertEquals(nameOne, resultUserOne.getName());
Assert.assertEquals(pwOne, resultUserOne.getPassword());
Assert.assertEquals(creationOne, resultUserOne.getCreationTime());
User resultUserTwo = resultUsers.get(1);
Assert.assertEquals(idTwo, resultUserTwo.getId());
Assert.assertEquals(nameTwo, resultUserTwo.getName());
Assert.assertEquals(pwTwo, resultUserTwo.getPassword());
Assert.assertEquals(creationTwo, resultUserTwo.getCreationTime());
}
use of codeu.model.data.User in project CodeU-Spring-2018 by jwang281.
the class PersistentStorageAgentTest method testWriteThroughUser.
@Test
public void testWriteThroughUser() {
User user = new User(UUID.randomUUID(), "test_username", "test_password", Instant.now());
persistentStorageAgent.writeThrough(user);
Mockito.verify(mockPersistentDataStore).writeThrough(user);
}
use of codeu.model.data.User in project CodeU-Spring-2018 by jwang281.
the class DefaultDataStore method addRandomMessages.
private void addRandomMessages() {
for (int i = 0; i < DEFAULT_MESSAGE_COUNT; i++) {
Conversation conversation = getRandomElement(conversations);
User author = getRandomElement(users);
String content = getRandomMessageContent();
Message message = new Message(UUID.randomUUID(), conversation.getId(), author.getId(), content, Instant.now());
PersistentStorageAgent.getInstance().writeThrough(message);
messages.add(message);
}
}
Aggregations