Skip to content

Commit 1d1e15c

Browse files
committed
Finish the model draft + test
1 parent e2463f8 commit 1d1e15c

File tree

8 files changed

+251
-47
lines changed

8 files changed

+251
-47
lines changed

src/com/arm/nimbus/collab/client/domain/Task.java

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/com/arm/nimbus/collab/server/model/PersistentEntity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.arm.nimbus.collab.server.model;
22

3+
import com.google.code.morphia.annotations.Entity;
34
import com.google.code.morphia.annotations.Version;
45
import com.google.code.morphia.annotations.Id;
56
import org.bson.types.ObjectId;
@@ -10,6 +11,7 @@
1011
*
1112
* @creator victor
1213
*/
14+
@Entity
1315
public class PersistentEntity {
1416

1517
/**

src/com/arm/nimbus/collab/server/model/Product.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.arm.nimbus.collab.server.model;
22

3+
import com.arm.nimbus.collab.client.model.ProductProxy;
4+
import com.google.code.morphia.annotations.Entity;
5+
36
import javax.validation.constraints.NotNull;
47
import javax.validation.constraints.Null;
58

@@ -8,7 +11,8 @@
811
*
912
* @creator victor
1013
*/
11-
public class Product extends PersistentEntity {
14+
@Entity
15+
public class Product extends PersistentEntity implements ProductProxy {
1216

1317
// Product name
1418
@NotNull
@@ -22,18 +26,22 @@ public Product() {
2226
super();
2327
}
2428

29+
@Override
2530
public String getName() {
2631
return name;
2732
}
2833

34+
@Override
2935
public void setName(String name) {
3036
this.name = name;
3137
}
3238

39+
@Override
3340
public String getCode() {
3441
return code;
3542
}
3643

44+
@Override
3745
public void setCode(String code) {
3846
this.code = code;
3947
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package com.arm.nimbus.collab.server.model;
2+
3+
import com.arm.nimbus.collab.client.model.ReviewProxy;
4+
5+
import javax.validation.constraints.NotNull;
6+
7+
/**
8+
* TODO description
9+
*
10+
* @creator victor
11+
*/
12+
public class Review extends PersistentEntity implements ReviewProxy {
13+
14+
// Related to a task
15+
@NotNull
16+
String taskID;
17+
18+
@NotNull
19+
String username;
20+
21+
@NotNull
22+
String status;
23+
24+
@NotNull
25+
String note;
26+
27+
// TODO createdDate, updateDate
28+
29+
30+
@Override
31+
public String getTaskID() {
32+
return taskID;
33+
}
34+
35+
@Override
36+
public void setTaskID(String taskID) {
37+
this.taskID = taskID;
38+
}
39+
40+
@Override
41+
public String getUsername() {
42+
return username;
43+
}
44+
45+
@Override
46+
public void setUsername(String username) {
47+
this.username = username;
48+
}
49+
50+
@Override
51+
public String getStatus() {
52+
return status;
53+
}
54+
55+
@Override
56+
public void setStatus(String status) {
57+
this.status = status;
58+
}
59+
60+
@Override
61+
public String getNote() {
62+
return note;
63+
}
64+
65+
@Override
66+
public void setNote(String note) {
67+
this.note = note;
68+
}
69+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package com.arm.nimbus.collab.server.model;
2+
3+
import com.google.code.morphia.annotations.Embedded;
4+
import com.google.code.morphia.annotations.Entity;
5+
6+
import javax.validation.constraints.NotNull;
7+
import java.util.List;
8+
9+
@Entity
10+
public class Task extends PersistentEntity {
11+
12+
@NotNull
13+
String title;
14+
15+
@NotNull
16+
String content;
17+
18+
@NotNull
19+
String status; // Free status
20+
21+
@Embedded
22+
User user; // Owner of the task
23+
24+
public Task(){
25+
super();
26+
}
27+
28+
public Task(String title, String content, String status, User user) {
29+
super();
30+
}
31+
32+
public String getTitle() {
33+
return title;
34+
}
35+
public void setTitle(String title) {
36+
this.title = title;
37+
}
38+
public String getContent() {
39+
return content;
40+
}
41+
public void setContent(String content) {
42+
this.content = content;
43+
}
44+
public String getStatus() {
45+
return status;
46+
}
47+
public void setStatus(String status) {
48+
this.status = status;
49+
}
50+
public User getUser() {
51+
return this.user;
52+
}
53+
public void setUser(User user) {
54+
this.user = user;
55+
}
56+
57+
/***
58+
* Find all task related to a user
59+
* @param user
60+
* @return
61+
*/
62+
public static List<Task> findByUser(User user){
63+
return null;
64+
}
65+
66+
}

src/com/arm/nimbus/collab/server/model/User.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
package com.arm.nimbus.collab.server.model;
22

3+
import com.google.code.morphia.annotations.Entity;
4+
35
import javax.validation.constraints.NotNull;
46

57
/**
68
* TODO description
79
*
810
* @creator victor
911
*/
12+
@Entity
1013
public class User extends PersistentEntity{
1114

15+
//TODO Controller must check if the username is unique or not
1216
@NotNull
1317
String username;
1418

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package unit.server.model;
2+
3+
import com.arm.nimbus.collab.server.model.Review;
4+
import com.arm.nimbus.collab.server.model.Task;
5+
import com.arm.nimbus.collab.server.model.User;
6+
import org.junit.Assert;
7+
import org.junit.Before;
8+
import org.junit.Test;
9+
10+
/**
11+
* TODO description
12+
*
13+
* @creator victor
14+
*/
15+
public class ReviewUnitTest {
16+
Review cl;
17+
18+
@Before
19+
public void setUp(){
20+
cl = new Review();
21+
}
22+
23+
@Test
24+
public void taskID() throws Exception {
25+
String taskID = "x129x";
26+
cl.setTaskID(taskID);
27+
Assert.assertEquals(taskID, cl.getTaskID());
28+
}
29+
30+
@Test
31+
public void username() throws Exception {
32+
String username = "x129x";
33+
cl.setUsername(username);
34+
Assert.assertEquals(username, cl.getUsername());
35+
}
36+
37+
@Test
38+
public void status(){
39+
String status = "in progess";
40+
cl.setStatus(status);
41+
Assert.assertEquals(status, cl.getStatus());
42+
}
43+
44+
@Test
45+
public void note(){
46+
String note = "this is a small note";;
47+
cl.setNote(note);
48+
Assert.assertEquals(note, cl.getNote());
49+
}
50+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package unit.server.model;
2+
3+
import com.arm.nimbus.collab.server.model.PersistentEntity;
4+
import com.arm.nimbus.collab.server.model.Task;
5+
import com.arm.nimbus.collab.server.model.User;
6+
import org.junit.Assert;
7+
import org.junit.Before;
8+
import org.junit.Test;
9+
10+
/**
11+
* TODO description
12+
*
13+
* @creator victor
14+
*/
15+
public class TaskUnitTest {
16+
Task t;
17+
18+
@Before
19+
public void setUp(){
20+
t = new Task();
21+
}
22+
23+
@Test
24+
public void title() throws Exception {
25+
String title = "title";
26+
t.setTitle(title);
27+
Assert.assertEquals(title, t.getTitle());
28+
}
29+
30+
@Test
31+
public void content() throws Exception {
32+
String content = "content";
33+
t.setContent(content);
34+
Assert.assertEquals(content, t.getContent());
35+
}
36+
37+
@Test
38+
public void status() throws Exception {
39+
String status = "status";
40+
t.setStatus(status);
41+
Assert.assertEquals(status, t.getStatus());
42+
}
43+
44+
@Test
45+
public void user() throws Exception {
46+
User user = new User();
47+
user.setUsername("hello");
48+
t.setUser(user);
49+
Assert.assertEquals(user, t.getUser());
50+
}
51+
}

0 commit comments

Comments
 (0)