Skip to content
Snippets Groups Projects
Commit 47b85c9e authored by Thomas's avatar Thomas
Browse files

Random fixs

parent 129557ae
Branches
Tags v0.1
No related merge requests found
...@@ -24,5 +24,5 @@ services: ...@@ -24,5 +24,5 @@ services:
ports: ports:
- 8007:8181 - 8007:8181
volumes: volumes:
- /data/mozen_data/store:/home/data - /data/mozen_data/store:/data
restart: unless-stopped restart: unless-stopped
...@@ -122,10 +122,18 @@ public class Model implements Serializable{ ...@@ -122,10 +122,18 @@ public class Model implements Serializable{
@OneToMany(mappedBy = "model", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) @OneToMany(mappedBy = "model", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
private Set<Comment> comments; private Set<Comment> comments;
@Basic
@ManyToMany(fetch = FetchType.LAZY, cascade = {CascadeType.MERGE, CascadeType.PERSIST})
private Set<User> upvotes;
@Basic
@ManyToMany(fetch = FetchType.LAZY, cascade = {CascadeType.MERGE, CascadeType.PERSIST})
private Set<User> downvotes;
public Model() { public Model() {
} }
public Model(Long id, String name, String shortDescription, String longDescription, Date added, Date lastModified, int votes, double performance, String performanceUnit, double performanceIndex, int parameterCount, String fileName, String contentId, long contentLength, String fileType, String checksum, boolean isVerified, User author, Set<Tag> tags, Set<CustomLayer> customLayers, Set<Comment> comments) { public Model(Long id, String name, String shortDescription, String longDescription, Date added, Date lastModified, int votes, double performance, String performanceUnit, double performanceIndex, int parameterCount, String fileName, String contentId, long contentLength, String fileType, String checksum, boolean isVerified, User author, Set<Tag> tags, Set<CustomLayer> customLayers, Set<Comment> comments, Set<User> upvotes, Set<User> downvotes) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.shortDescription = shortDescription; this.shortDescription = shortDescription;
...@@ -147,6 +155,8 @@ public class Model implements Serializable{ ...@@ -147,6 +155,8 @@ public class Model implements Serializable{
this.tags = tags; this.tags = tags;
this.customLayers = customLayers; this.customLayers = customLayers;
this.comments = comments; this.comments = comments;
this.upvotes = upvotes;
this.downvotes = downvotes;
} }
@JsonIgnore @JsonIgnore
...@@ -325,5 +335,22 @@ public class Model implements Serializable{ ...@@ -325,5 +335,22 @@ public class Model implements Serializable{
this.fileName = fileName; this.fileName = fileName;
} }
@JsonIgnore
public Set<User> getUpvotes() {
return this.upvotes;
}
public void setUpvotes(Set<User> upvotes) {
this.upvotes = upvotes;
}
@JsonIgnore
public Set<User> getDownvotes() {
return this.downvotes;
}
public void setDownvotes(Set<User> downvotes) {
this.downvotes = downvotes;
}
} }
\ No newline at end of file
...@@ -11,6 +11,7 @@ import org.springframework.boot.test.context.SpringBootTest; ...@@ -11,6 +11,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import mozen.messages.SignupMessage; import mozen.messages.SignupMessage;
import mozen.messages.UserUpdateMessage;
import mozen.model.User; import mozen.model.User;
@SpringBootTest @SpringBootTest
...@@ -55,7 +56,45 @@ public class UserManagerTest { ...@@ -55,7 +56,45 @@ public class UserManagerTest {
@Test @Test
void updateUserTest() { void updateUserTest() {
User user = userManager.addUser(new SignupMessage("testuser", "1234", "test@test.com"));
UserUpdateMessage message = new UserUpdateMessage();
message.setId(user.getId());
message.setUsername("newtestuser");
message.setEmail("newtest@test.com");
try {
userManager.updateUser(user, message);
} catch (Exception e) {
assertTrue(false);
}
User userFind = userManager.getUser(user.getId());
assertEquals(message.getUsername(), userFind.getUsername());
assertEquals(message.getEmail(), userFind.getEmail());
assertEquals(message.getUsername(), userFind.getUsername());
}
@Test
void updateUserNotRightTest() {
User user = userManager.addUser(new SignupMessage("testuser", "1234", "test@test.com"));
User user2 = userManager.addUser(new SignupMessage("testuser2", "1234", "test2@test.com"));
UserUpdateMessage message = new UserUpdateMessage();
message.setId(user.getId());
message.setUsername("newtestuser");
message.setEmail("newtest@test.com");
try {
userManager.updateUser(user2, message);
assertTrue(false);
} catch (Exception e) {
assertTrue(true); assertTrue(true);
User userFind = userManager.getUser(user.getId());
assertEquals(message.getUsername(), userFind.getUsername());
assertEquals(message.getEmail(), userFind.getEmail());
assertEquals(message.getUsername(), userFind.getUsername());
}
} }
@Test @Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment