Skip to content

Commit

Permalink
Fixing node registry tests
Browse files Browse the repository at this point in the history
- removing `Transactional` from test class
- using hibernate sessions
  • Loading branch information
davet1985 committed Feb 5, 2025
1 parent c858454 commit 573384e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package uk.gov.hmcts.darts.noderegistration.controller;

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
Expand All @@ -10,7 +12,6 @@
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.transaction.annotation.Transactional;
import uk.gov.hmcts.darts.authorisation.component.UserIdentity;
import uk.gov.hmcts.darts.common.entity.CourthouseEntity;
import uk.gov.hmcts.darts.common.entity.CourtroomEntity;
Expand All @@ -34,7 +35,6 @@

@Slf4j
@AutoConfigureMockMvc
@Transactional
class NodeRegistrationControllerTest extends IntegrationBase {

@Autowired
Expand All @@ -43,6 +43,15 @@ class NodeRegistrationControllerTest extends IntegrationBase {
@MockitoBean
private UserIdentity mockUserIdentity;

@BeforeEach
void startHibernateSession() {
openInViewUtil.openEntityManager();
}

@AfterEach
void closeHibernateSession() {
openInViewUtil.closeEntityManager();
}

@Test
void testPostRegisterDevices() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ HearingEntity retrieveOrCreateHearing(String courthouseName, String courtroomNam
* Retrieve or create a case and link to media.
* @deprecated This method is only used by tests. Tests should be refactored and this method should be removed.
*/
@Deprecated
@Deprecated(since = "04/02/2025")
HearingEntity retrieveOrCreateHearingWithMedia(String courthouseName, String courtroomName, String caseNumber, LocalDateTime hearingDate,
UserAccountEntity userAccount, MediaEntity mediaEntity);

Expand All @@ -52,7 +52,7 @@ HearingEntity retrieveOrCreateHearingWithMedia(String courthouseName, String cou
* @deprecated This method is only used by tests.
* Tests should be refactored to use the other `retrieveOrCreateCourtroom` method, and this method should be removed.
*/
@Deprecated
@Deprecated(since = "04/02/2025")
CourtroomEntity retrieveOrCreateCourtroom(CourthouseEntity courthouse, String courtroomName, UserAccountEntity userAccount);

/**
Expand Down Expand Up @@ -87,7 +87,7 @@ HearingEntity retrieveOrCreateHearingWithMedia(String courthouseName, String cou
* @deprecated This method is only used by tests.
* Tests should be refactored to use the other `retrieveOrCreateCase` method, and this method should be removed.
*/
@Deprecated
@Deprecated(since = "04/02/2025")
CourtCaseEntity retrieveOrCreateCase(String courthouseName, String caseNumber, UserAccountEntity userAccount);

/**
Expand Down

0 comments on commit 573384e

Please sign in to comment.