Assignments tests
This commit is contained in:
parent
e9ae1a0ed0
commit
95fcfc4e06
@ -15,7 +15,6 @@ public class AssignmentService {
|
|||||||
private AssignmentRepository repo;
|
private AssignmentRepository repo;
|
||||||
|
|
||||||
public AssignmentService() {
|
public AssignmentService() {
|
||||||
super();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save(Assignment assignment) {
|
public void save(Assignment assignment) {
|
||||||
@ -25,4 +24,8 @@ public class AssignmentService {
|
|||||||
public List<Assignment> getCommisionAssignments(Commision com) {
|
public List<Assignment> getCommisionAssignments(Commision com) {
|
||||||
return this.repo.getByCommision(com.getId());
|
return this.repo.getByCommision(com.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getAssignmentsAmmount() {
|
||||||
|
return this.repo.count();
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,12 +1,20 @@
|
|||||||
package com.plannaplan.services;
|
package com.plannaplan.services;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.plannaplan.entities.Assignment;
|
||||||
|
import com.plannaplan.entities.Commision;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@ -14,20 +22,35 @@ import org.junit.runner.RunWith;
|
|||||||
@ContextConfiguration
|
@ContextConfiguration
|
||||||
public class AssignmentServiceTest {
|
public class AssignmentServiceTest {
|
||||||
|
|
||||||
// @Autowired
|
@Autowired
|
||||||
// private AssignmentService service;
|
private AssignmentService service;
|
||||||
|
@Autowired
|
||||||
|
private CommisionService comServie;
|
||||||
|
private Commision com;
|
||||||
|
|
||||||
// @Autowired
|
@Before
|
||||||
// private UserService userService;
|
public void init() {
|
||||||
|
this.com = new Commision();
|
||||||
|
this.comServie.save(this.com);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldSaveAssignment() {
|
public void shouldSaveAssignment() {
|
||||||
assertTrue("Not implemented", false);
|
long beginState = this.service.getAssignmentsAmmount();
|
||||||
|
this.addAssignmentToCommision(this.com);
|
||||||
|
assertTrue("Assign ammount should increase", this.service.getAssignmentsAmmount() > beginState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldGetCommisionAssignments() {
|
public void shouldGetCommisionAssignments() {
|
||||||
assertTrue("Not implemented", false);
|
this.addAssignmentToCommision(this.com);
|
||||||
|
final List<Assignment> response = this.service.getCommisionAssignments(com);
|
||||||
|
assertTrue("Returned list size should be 1", response.size() == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addAssignmentToCommision(Commision com) {
|
||||||
|
Assignment a = new Assignment(null, com);
|
||||||
|
this.service.save(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
package com.plannaplan.services;
|
package com.plannaplan.services;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import com.plannaplan.entities.User;
|
|
||||||
import com.plannaplan.types.UserRoles;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
@ -21,15 +16,6 @@ public class CommisionServiceTest {
|
|||||||
|
|
||||||
// @Autowired
|
// @Autowired
|
||||||
// private CommisionService service;
|
// private CommisionService service;
|
||||||
@Autowired
|
|
||||||
private UserService userService;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void initialize() {
|
|
||||||
User testUser = new User(UserServiceTest.TEST_USER_NAME, UserServiceTest.TEST_USER_SUERNAME,
|
|
||||||
UserServiceTest.TEST_USER_MAIL, UserRoles.TEST_USER);
|
|
||||||
this.userService.save(testUser);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldSaveCommision() {
|
public void shouldSaveCommision() {
|
||||||
|
@ -22,9 +22,9 @@ import org.junit.runner.RunWith;
|
|||||||
@ContextConfiguration
|
@ContextConfiguration
|
||||||
@TestMethodOrder(OrderAnnotation.class)
|
@TestMethodOrder(OrderAnnotation.class)
|
||||||
public class UserServiceTest {
|
public class UserServiceTest {
|
||||||
public static String TEST_USER_MAIL = "noteexisitingmail@notexistingdomain.com";
|
private static String TEST_USER_MAIL = "noteexisitingmail@notexistingdomain.com";
|
||||||
public static String TEST_USER_NAME = "Tom";
|
private static String TEST_USER_NAME = "Tom";
|
||||||
public static String TEST_USER_SUERNAME = "Kovalsky";
|
private static String TEST_USER_SUERNAME = "Kovalsky";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
Loading…
Reference in New Issue
Block a user