-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb952f3
commit 17588e6
Showing
10 changed files
with
110 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/test/java/org/tkit/onecx/workspace/domain/daos/AssignmentDAOTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.tkit.onecx.workspace.domain.daos; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.persistence.EntityManager; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.function.Executable; | ||
import org.mockito.Mockito; | ||
import org.tkit.quarkus.jpa.exceptions.DAOException; | ||
|
||
import io.quarkus.test.InjectMock; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@QuarkusTest | ||
class AssignmentDAOTest { | ||
@Inject | ||
AssignmentDAO dao; | ||
|
||
@InjectMock | ||
EntityManager em; | ||
|
||
@BeforeEach | ||
void beforeAll() { | ||
Mockito.when(em.getCriteriaBuilder()).thenThrow(new RuntimeException("Test technical error exception")); | ||
} | ||
|
||
@Test | ||
void methodExceptionTests() { | ||
methodExceptionTests(() -> dao.findByCriteria(null), | ||
AssignmentDAO.ErrorKeys.ERROR_FIND_ASSIGNMENT_BY_CRITERIA); | ||
methodExceptionTests(() -> dao.findById(null), | ||
AssignmentDAO.ErrorKeys.FIND_ENTITY_BY_ID_FAILED); | ||
|
||
} | ||
|
||
void methodExceptionTests(Executable fn, Enum<?> key) { | ||
var exc = Assertions.assertThrows(DAOException.class, fn); | ||
Assertions.assertEquals(key, exc.key); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/test/java/org/tkit/onecx/workspace/domain/daos/RoleDAOTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.tkit.onecx.workspace.domain.daos; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.persistence.EntityManager; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.function.Executable; | ||
import org.mockito.Mockito; | ||
import org.tkit.quarkus.jpa.exceptions.DAOException; | ||
|
||
import io.quarkus.test.InjectMock; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@QuarkusTest | ||
class RoleDAOTest { | ||
@Inject | ||
RoleDAO dao; | ||
|
||
@InjectMock | ||
EntityManager em; | ||
|
||
@BeforeEach | ||
void beforeAll() { | ||
Mockito.when(em.getCriteriaBuilder()).thenThrow(new RuntimeException("Test technical error exception")); | ||
} | ||
|
||
@Test | ||
void methodExceptionTests() { | ||
methodExceptionTests(() -> dao.findByCriteria(null), | ||
RoleDAO.ErrorKeys.ERROR_FIND_ROLE_BY_CRITERIA); | ||
methodExceptionTests(() -> dao.findById(null), | ||
RoleDAO.ErrorKeys.FIND_ENTITY_BY_ID_FAILED); | ||
|
||
} | ||
|
||
void methodExceptionTests(Executable fn, Enum<?> key) { | ||
var exc = Assertions.assertThrows(DAOException.class, fn); | ||
Assertions.assertEquals(key, exc.key); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters