Checkpoint: Added test to ExchangeRepo

Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
Marcin Woźniak 2021-01-11 16:56:39 +01:00
parent 76faedc40d
commit 3583d30b26
Signed by: y0rune
GPG Key ID: F204C385F57EB348
2 changed files with 90 additions and 39 deletions

View File

@ -0,0 +1,44 @@
package com.plannaplan.models;
import com.plannaplan.entities.Assignment;
public class MatchData {
private Assignment assignmentOne;
private Assignment assignmentTwo;
public MatchData(Assignment assignmentOne, Assignment assignmentTwo) {
this.assignmentOne = assignmentOne;
this.assignmentTwo = assignmentTwo;
}
public Assignment getAssignmentTwo() {
return assignmentTwo;
}
public Assignment getAssignmentOne() {
return assignmentOne;
}
@Override
public boolean equals(Object o) {
// If the object is compared with itself then return true
if (o == this) {
return true;
}
/*
* Check if o is an instance of Complex or not "null instanceof [type]" also
* returns false
*/
if (!(o instanceof MatchData)) {
return false;
}
// typecast o to Complex so that we can compare data members
MatchData c = (MatchData) o;
// Compare the data members and return accordingly
return (this.assignmentOne.equals(c.getAssignmentOne()) && this.assignmentTwo.equals(c.getAssignmentTwo())) || (this.assignmentOne.equals(c.getAssignmentTwo()) && this.assignmentTwo.equals(c.getAssignmentOne()));
}
}

View File

@ -6,6 +6,7 @@ import java.util.Optional;
import com.plannaplan.entities.Assignment; import com.plannaplan.entities.Assignment;
import com.plannaplan.entities.Exchange; import com.plannaplan.entities.Exchange;
import com.plannaplan.entities.Groups; import com.plannaplan.entities.Groups;
import com.plannaplan.models.MatchData;
import com.plannaplan.repositories.ExchangeRepository; import com.plannaplan.repositories.ExchangeRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -60,4 +61,10 @@ public class ExchangeService {
public void performExchange() { public void performExchange() {
} }
// public void getMatches(){
// final List<MatchData> matches = this.repo.getMatches().stream().map(m -> {
// return (MatchData) m;
// });
// }
} }