Browse Source

junit test for updateUser()

M10
Raymond Zhang 3 years ago
parent
commit
ea920fe405
2 changed files with 21 additions and 0 deletions
  1. +17
    -0
      Clean-Water-Crowdsourcing/src/test/java/org/cs2340/cleanwater/model/ModelTest.java
  2. +4
    -0
      M2/rzhang339.gradle

+ 17
- 0
Clean-Water-Crowdsourcing/src/test/java/org/cs2340/cleanwater/model/ModelTest.java View File

@@ -1,6 +1,8 @@
package test.java.org.cs2340.cleanwater.model;

import main.java.org.cs2340.cleanwater.model.Model;
import main.java.org.cs2340.cleanwater.model.User;
import main.java.org.cs2340.cleanwater.model.Role;
import org.junit.Test;

import static junit.framework.TestCase.*;
@@ -32,4 +34,19 @@ public class ModelTest {
assertFalse("Case: setting current user to invalid user.", m.setCurrentUser("cbritt30", "test"));
}

@Test
public void testUpdateUser() {
Model model = new Model();
model.setCurrentUser("raymond", "password");
User user = model.getCurrentUser();
model.updateUser(Role.USER, "Raymond", "Mr.", "rzhang339@gmail.com", "1500 Asheforde Dr");
String[] expectedProfileInfo = new String[]{"Sir", "Raymond", "abc@hotmail.com", "100 First Dr", "ADMIN"};
model.updateUser(Role.ADMIN, "Raymond", "Sir", "abc@hotmail.com", "100 First Dr");
assertEquals(expectedProfileInfo[0], model.getCurrentUser().getProfileInformation()[0]);
assertEquals(expectedProfileInfo[1], model.getCurrentUser().getProfileInformation()[1]);
assertEquals(expectedProfileInfo[2], model.getCurrentUser().getProfileInformation()[2]);
assertEquals(expectedProfileInfo[3], model.getCurrentUser().getProfileInformation()[3]);
assertEquals(expectedProfileInfo[4], model.getCurrentUser().getProfileInformation()[4]);
}

}

+ 4
- 0
M2/rzhang339.gradle View File

@@ -2,10 +2,14 @@ apply plugin: 'java'

defaultTasks 'jar'

//noinspection GroovyAssignabilityCheck

dependencies {
compile fileTree(dir: 'lib', include: '*.jar')
}

//noinspection GroovyAssignabilityCheck

jar {
manifest {
attributes(


Loading…
Cancel
Save