Added tests

This commit is contained in:
Filip Izydorczyk
2021-01-05 11:44:54 +01:00
parent 0b40d3729c
commit 463af01dc6
4 changed files with 85 additions and 27 deletions

View File

@ -46,15 +46,20 @@ public class AssignmentService {
return this.repo.save(assignment);
}
/*
* getCommisionAssignments Return id of the commision
/**
* gets list of assignments of given commision
*
* @param com Commision to get assinments from
* @return list of assignments
*/
public List<Assignment> getCommisionAssignments(Commision com) {
return this.repo.getByCommision(com.getId());
}
/*
* getAssignmentsAmmount Return count assignments ammount
/**
* get ammount of all assignments (not only for selected commision)
*
* @return long - ammount of assingments
*/
public long getAssignmentsAmmount() {
return this.repo.count();

View File

@ -12,7 +12,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Service of CommisionService which can save commision, get user's commisions, get newest user's commision, get ammount of commisions.
* Service of CommisionService which can save commision, get user's commisions,
* get newest user's commision, get ammount of commisions.
*/
@Service
@ -25,12 +26,6 @@ public class CommisionService {
public CommisionService() {
}
/*
* save
*
* @param commision which assignment should be save in service
* @return commision
*/
public Commision save(Commision commision) {
Optional<Commision> lastCommision = this.getNewestCommision(commision.getCommisionOwner());
if (lastCommision.isPresent()) {
@ -45,25 +40,31 @@ public class CommisionService {
}
/*
* getUsersCommisions
* Return given users id
/**
* gets user commisions
*
* @param user owner of commisions
* @return list of user commisions
*/
public List<Commision> getUsersCommisions(User user) {
return this.repo.getUsers(user.getId());
}
/*
* getNewestCommision
* Return the newest commision of the user
/**
* get newest commision ov given user
*
* @param user owener of commision we attemp to get
* @return optional if commition was found
*/
public Optional<Commision> getNewestCommision(User user) {
return this.repo.getNewestCommision(user.getId()).stream().findFirst();
}
/*
* getCommisionsAmmount
* Return ammount of commisions
/**
* get ammpounts of commisions
*
* @return long - ammounts of commisions (all even from history, not only
* cutrrent one)
*/
public long getCommisionsAmmount() {
return this.repo.count();