Assignments tests
This commit is contained in:
parent
e9ae1a0ed0
commit
95fcfc4e06
@ -15,7 +15,6 @@ public class AssignmentService {
|
||||
private AssignmentRepository repo;
|
||||
|
||||
public AssignmentService() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void save(Assignment assignment) {
|
||||
@ -25,4 +24,8 @@ public class AssignmentService {
|
||||
public List<Assignment> getCommisionAssignments(Commision com) {
|
||||
return this.repo.getByCommision(com.getId());
|
||||
}
|
||||
|
||||
public long getAssignmentsAmmount() {
|
||||
return this.repo.count();
|
||||
}
|
||||
}
|
@ -1,12 +1,20 @@
|
||||
package com.plannaplan.services;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
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.runner.RunWith;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@ -14,20 +22,35 @@ import org.junit.runner.RunWith;
|
||||
@ContextConfiguration
|
||||
public class AssignmentServiceTest {
|
||||
|
||||
// @Autowired
|
||||
// private AssignmentService service;
|
||||
@Autowired
|
||||
private AssignmentService service;
|
||||
@Autowired
|
||||
private CommisionService comServie;
|
||||
private Commision com;
|
||||
|
||||
// @Autowired
|
||||
// private UserService userService;
|
||||
@Before
|
||||
public void init() {
|
||||
this.com = new Commision();
|
||||
this.comServie.save(this.com);
|
||||
}
|
||||
|
||||
@Test
|
||||
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
|
||||
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;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
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.runner.RunWith;
|
||||
|
||||
@ -21,15 +16,6 @@ public class CommisionServiceTest {
|
||||
|
||||
// @Autowired
|
||||
// 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
|
||||
public void shouldSaveCommision() {
|
||||
|
@ -22,9 +22,9 @@ import org.junit.runner.RunWith;
|
||||
@ContextConfiguration
|
||||
@TestMethodOrder(OrderAnnotation.class)
|
||||
public class UserServiceTest {
|
||||
public static String TEST_USER_MAIL = "noteexisitingmail@notexistingdomain.com";
|
||||
public static String TEST_USER_NAME = "Tom";
|
||||
public static String TEST_USER_SUERNAME = "Kovalsky";
|
||||
private static String TEST_USER_MAIL = "noteexisitingmail@notexistingdomain.com";
|
||||
private static String TEST_USER_NAME = "Tom";
|
||||
private static String TEST_USER_SUERNAME = "Kovalsky";
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
Loading…
Reference in New Issue
Block a user