-
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.
* feat: add log params * feat: update log params
- Loading branch information
1 parent
0e96173
commit e2bb75c
Showing
8 changed files
with
128 additions
and
25 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
27 changes: 27 additions & 0 deletions
27
src/main/java/org/tkit/onecx/workspace/rs/internal/log/AssignmentLogParam.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,27 @@ | ||
package org.tkit.onecx.workspace.rs.internal.log; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
|
||
import org.tkit.quarkus.log.cdi.LogParam; | ||
|
||
import gen.org.tkit.onecx.workspace.rs.internal.model.*; | ||
|
||
@ApplicationScoped | ||
public class AssignmentLogParam implements LogParam { | ||
|
||
@Override | ||
public List<Item> getClasses() { | ||
return List.of( | ||
item(10, CreateAssignmentRequestDTO.class, | ||
x -> CreateAssignmentRequestDTO.class.getSimpleName() + "[" | ||
+ ((CreateAssignmentRequestDTO) x).getRoleId() + "," | ||
+ ((CreateAssignmentRequestDTO) x).getMenuItemId() + "]"), | ||
item(10, AssignmentSearchCriteriaDTO.class, x -> { | ||
AssignmentSearchCriteriaDTO d = (AssignmentSearchCriteriaDTO) x; | ||
return AssignmentSearchCriteriaDTO.class.getSimpleName() + "[" + d.getPageNumber() + "," + d.getPageSize() | ||
+ "]"; | ||
})); | ||
} | ||
} |
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
31 changes: 31 additions & 0 deletions
31
src/main/java/org/tkit/onecx/workspace/rs/internal/log/RoleLogParam.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,31 @@ | ||
package org.tkit.onecx.workspace.rs.internal.log; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
|
||
import org.tkit.quarkus.log.cdi.LogParam; | ||
|
||
import gen.org.tkit.onecx.workspace.rs.internal.model.*; | ||
|
||
@ApplicationScoped | ||
public class RoleLogParam implements LogParam { | ||
|
||
@Override | ||
public List<Item> getClasses() { | ||
return List.of( | ||
item(10, CreateRoleRequestDTO.class, | ||
x -> CreateRoleRequestDTO.class.getSimpleName() + "[" | ||
+ ((CreateRoleRequestDTO) x).getName() + "," | ||
+ ((CreateRoleRequestDTO) x).getWorkspaceId() + "]"), | ||
item(10, UpdateRoleRequestDTO.class, | ||
x -> UpdateRoleRequestDTO.class.getSimpleName() + "[" + ((UpdateRoleRequestDTO) x).getName() | ||
+ "]"), | ||
item(10, RoleSearchCriteriaDTO.class, x -> { | ||
RoleSearchCriteriaDTO d = (RoleSearchCriteriaDTO) x; | ||
return RoleSearchCriteriaDTO.class.getSimpleName() + "[" + d.getPageNumber() + "," + d.getPageSize() | ||
+ "]"; | ||
})); | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
src/test/java/org/tkit/onecx/workspace/domain/daos/ImageDAOTest.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 | ||
public class ImageDAOTest { | ||
|
||
@Inject | ||
ImageDAO dao; | ||
|
||
@InjectMock | ||
EntityManager em; | ||
|
||
@BeforeEach | ||
void beforeAll() { | ||
Mockito.when(em.getCriteriaBuilder()).thenThrow(new RuntimeException("Test technical error exception")); | ||
} | ||
|
||
@Test | ||
void methodExceptionTests() { | ||
methodExceptionTests(() -> dao.deleteQueryByRefId(null), | ||
ImageDAO.ErrorKeys.FAILED_TO_DELETE_BY_REF_ID_QUERY); | ||
methodExceptionTests(() -> dao.findByRefIdAndRefType(null, null), | ||
ImageDAO.ErrorKeys.FIND_ENTITY_BY_REF_ID_REF_TYPE_FAILED); | ||
} | ||
|
||
void methodExceptionTests(Executable fn, Enum<?> key) { | ||
var exc = Assertions.assertThrows(DAOException.class, fn); | ||
Assertions.assertEquals(key, exc.key); | ||
} | ||
} |