-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: delete image by product delete (#44)
- Loading branch information
Showing
8 changed files
with
230 additions
and
11 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
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
48 changes: 48 additions & 0 deletions
48
src/test/java/org/tkit/onecx/product/store/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,48 @@ | ||
package org.tkit.onecx.product.store.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.onecx.product.store.AbstractTest; | ||
import org.tkit.quarkus.jpa.exceptions.DAOException; | ||
|
||
import gen.org.tkit.onecx.image.rs.internal.model.RefTypeDTO; | ||
import io.quarkus.test.InjectMock; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@QuarkusTest | ||
class ImageDAOTest extends AbstractTest { | ||
@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("1"), | ||
ImageDAO.ErrorKeys.FAILED_TO_DELETE_BY_REF_ID_QUERY); | ||
methodExceptionTests(() -> dao.findByRefIdAndRefType(null, null), | ||
ImageDAO.ErrorKeys.FIND_ENTITY_BY_REF_ID_REF_TYPE_FAILED); | ||
methodExceptionTests(() -> dao.findByRefIdAndRefType(null, null), | ||
ImageDAO.ErrorKeys.FIND_ENTITY_BY_REF_ID_REF_TYPE_FAILED); | ||
methodExceptionTests(() -> dao.deleteQueryByRefIdAndRefType("1", RefTypeDTO.LOGO), | ||
ImageDAO.ErrorKeys.FAILED_TO_DELETE_BY_REF_ID_REF_TYPE_QUERY); | ||
|
||
} | ||
|
||
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