Commit b6435325 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

old tests removed

parent 0c3b7c4d
......@@ -5,12 +5,10 @@ import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import lcsb.mapviewer.api.projects.AllProjectTests;
import lcsb.mapviewer.api.users.AllUserTests;
@RunWith(Suite.class)
@SuiteClasses({
AllProjectTests.class,
AllUserTests.class,
})
public class AllRestTests {
......
package lcsb.mapviewer.api.users;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({ UserRestImplTest.class })
public class AllUserTests {
}
package lcsb.mapviewer.api.users;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.io.IOException;
import java.util.*;
import org.junit.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.LinkedMultiValueMap;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.gson.Gson;
import lcsb.mapviewer.api.RestTestFunctions;
import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.user.*;
import lcsb.mapviewer.model.user.annotator.*;
import lcsb.mapviewer.services.ObjectExistsException;
import lcsb.mapviewer.services.interfaces.IUserService;
public class UserRestImplTest extends RestTestFunctions {
private final static String TEST_LOGIN = "test_user";
@Autowired
UserRestImpl userRestImpl;
@Autowired
IUserService userService;
@AfterClass
public static void tearDownAfterClass() throws Exception {
}
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
@Test(expected = ObjectExistsException.class)
public void testAddExistingUser() throws Exception {
User user = new User();
user.setLogin(TEST_LOGIN);
user.setCryptedPassword("");
userService.addUser(user);
userRestImpl.addUser(TEST_LOGIN, new LinkedMultiValueMap<>());
}
@Test
public void testUpdatePreferences() throws Exception {
try {
User user = new User();
user.setCryptedPassword("");
user.setLogin(TEST_LOGIN);
userService.addUser(user);
dbUtils.setAutoFlush(true);
Map<String, Object> data = deserialize(userRestImpl.getUser(TEST_LOGIN, "preferences"));
userRestImpl.updatePreferences(TEST_LOGIN, (Map<String, Object>) data.get("preferences"));
} finally {
dbUtils.setAutoFlush(false);
}
}
private Map<String, Object> deserialize(Map<String, Object> data)
throws JsonParseException, JsonMappingException, IOException {
ObjectMapper mapper = new ObjectMapper();
ObjectNode result = mapper.readValue(mapper.writeValueAsString(data), ObjectNode.class);
return mapper.convertValue(result, Map.class);
}
@Test
public void testGetUsers() throws Exception {
Object response = userRestImpl.getUsers("");
assertNotNull(response);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment