Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Matúš Valko
Online Gaming Management System
Commits
b49d448b
Commit
b49d448b
authored
May 17, 2022
by
Adrián Piaček
Browse files
Fixed MatchEntity tests
parent
4a8d802b
Pipeline
#140474
passed with stage
in 1 minute and 6 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
gaming-persistence/src/main/java/cz/muni/fi/pa165/entity/BaseEntity.java
View file @
b49d448b
...
...
@@ -8,6 +8,7 @@ import org.hibernate.annotations.GenericGenerator;
import
javax.persistence.*
;
import
javax.validation.constraints.NotNull
;
import
java.util.ArrayList
;
import
java.util.Objects
;
import
java.util.UUID
;
/**
...
...
@@ -16,7 +17,6 @@ import java.util.UUID;
@Getter
@Setter
@EqualsAndHashCode
@MappedSuperclass
public
abstract
class
BaseEntity
{
...
...
@@ -35,4 +35,19 @@ public abstract class BaseEntity {
public
BaseEntity
(
UUID
id
)
{
this
.
id
=
id
;
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
)
return
false
;
if
(
getClass
()
!=
o
.
getClass
())
return
false
;
BaseEntity
other
=
(
BaseEntity
)
o
;
return
id
!=
null
&&
id
.
equals
(
other
.
getId
());
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
getId
());
}
}
gaming-persistence/src/main/java/cz/muni/fi/pa165/entity/MatchEntity.java
View file @
b49d448b
...
...
@@ -5,6 +5,7 @@ import lombok.Setter;
import
javax.persistence.*
;
import
java.util.HashSet
;
import
java.util.Objects
;
import
java.util.Set
;
/**
...
...
gaming-persistence/src/main/java/cz/muni/fi/pa165/entity/TeamEntity.java
View file @
b49d448b
...
...
@@ -2,6 +2,7 @@ package cz.muni.fi.pa165.entity;
import
cz.muni.fi.pa165.entity.interfaces.Viewable
;
import
cz.muni.fi.pa165.enums.CountryEnum
;
import
lombok.Data
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
@@ -11,6 +12,7 @@ import javax.persistence.ManyToMany;
import
javax.persistence.OneToMany
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.Objects
;
import
java.util.Set
;
/**
...
...
@@ -91,7 +93,4 @@ public class TeamEntity extends BaseEntity implements Viewable {
public
void
removeCoachFromTheTeam
(
TeamCoachEntity
oldCoach
)
{
this
.
coachList
.
remove
(
oldCoach
);
}
}
gaming-persistence/src/test/java/cz/muni/fi/pa165/entity/MatchEntityTest.java
View file @
b49d448b
...
...
@@ -161,18 +161,17 @@ public class MatchEntityTest {
match
=
em1
.
find
(
MatchEntity
.
class
,
matchB
.
getId
());
Assertions
.
assertEquals
(
match
.
getTeams
(),
new
HashSet
<>(
List
.
of
(
teamC
,
teamD
,
teamE
)));
// TODO - fix
// match = em1.find(MatchEntity.class, matchC.getId());
// Assertions.assertEquals(match.getTeams(), new HashSet<>(List.of(teamA, teamC, teamF)));
//
// team = em1.find(TeamEntity.class, teamB.getId());
// Assertions.assertEquals(team.getMatches(), new HashSet<>(List.of(matchA)));
//
// team = em1.find(TeamEntity.class, teamA.getId());
// Assertions.assertEquals(team.getMatches(), new HashSet<>(List.of(matchA, matchC)));
//
// team = em1.find(TeamEntity.class, teamC.getId());
// Assertions.assertEquals(team.getMatches(), new HashSet<>(List.of(matchB,matchC)));
match
=
em1
.
find
(
MatchEntity
.
class
,
matchC
.
getId
());
Assertions
.
assertEquals
(
match
.
getTeams
(),
new
HashSet
<>(
List
.
of
(
teamA
,
teamC
,
teamF
)));
team
=
em1
.
find
(
TeamEntity
.
class
,
teamB
.
getId
());
Assertions
.
assertEquals
(
team
.
getMatches
(),
new
HashSet
<>(
List
.
of
(
matchA
)));
team
=
em1
.
find
(
TeamEntity
.
class
,
teamA
.
getId
());
Assertions
.
assertEquals
(
team
.
getMatches
(),
new
HashSet
<>(
List
.
of
(
matchA
,
matchC
)));
team
=
em1
.
find
(
TeamEntity
.
class
,
teamC
.
getId
());
Assertions
.
assertEquals
(
team
.
getMatches
(),
new
HashSet
<>(
List
.
of
(
matchB
,
matchC
)));
em1
.
getTransaction
().
commit
();
}
finally
{
if
(
em1
!=
null
)
em1
.
close
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment