Skip to content

Commit

Permalink
Add event for TTL migration (#4273)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamg-hmcts authored Jan 16, 2025
1 parent 89c812a commit e750c9a
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package uk.gov.hmcts.divorce.systemupdate.event;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import uk.gov.hmcts.ccd.sdk.api.CCDConfig;
import uk.gov.hmcts.ccd.sdk.api.ConfigBuilder;
import uk.gov.hmcts.divorce.divorcecase.model.CaseData;
import uk.gov.hmcts.divorce.divorcecase.model.State;
import uk.gov.hmcts.divorce.divorcecase.model.UserRole;

import static uk.gov.hmcts.divorce.common.ccd.CcdPageConfiguration.NEVER_SHOW;
import static uk.gov.hmcts.divorce.divorcecase.model.State.Draft;
import static uk.gov.hmcts.divorce.divorcecase.model.UserRole.SYSTEMUPDATE;
import static uk.gov.hmcts.divorce.divorcecase.model.access.Permissions.CREATE_READ_UPDATE;

@Component
@Slf4j
@RequiredArgsConstructor
public class SystemSetTimeToLive implements CCDConfig<CaseData, State, UserRole> {

public static final String SYSTEM_SET_TTL = "system-set-ttl";

@Override
public void configure(final ConfigBuilder<CaseData, State, UserRole> configBuilder) {
configBuilder
.event(SYSTEM_SET_TTL)
.forStates(Draft)
.showCondition(NEVER_SHOW)
.name("System set TTL")
.description("System set TTL")
.grant(CREATE_READ_UPDATE, SYSTEMUPDATE);
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package uk.gov.hmcts.divorce.systemupdate.event;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.junit.jupiter.MockitoExtension;
import uk.gov.hmcts.ccd.sdk.ConfigBuilderImpl;
import uk.gov.hmcts.ccd.sdk.api.Event;
import uk.gov.hmcts.divorce.divorcecase.model.CaseData;
import uk.gov.hmcts.divorce.divorcecase.model.State;
import uk.gov.hmcts.divorce.divorcecase.model.UserRole;

import static org.assertj.core.api.Assertions.assertThat;
import static uk.gov.hmcts.divorce.systemupdate.event.SystemSetTimeToLive.SYSTEM_SET_TTL;
import static uk.gov.hmcts.divorce.testutil.ConfigTestUtil.createCaseDataConfigBuilder;
import static uk.gov.hmcts.divorce.testutil.ConfigTestUtil.getEventsFrom;

@ExtendWith(MockitoExtension.class)
class SystemSetTimeToLiveTest {

@InjectMocks
private SystemSetTimeToLive systemSetTimeToLive;

@Test
void shouldAddConfigurationToConfigBuilder() {
final ConfigBuilderImpl<CaseData, State, UserRole> configBuilder = createCaseDataConfigBuilder();

systemSetTimeToLive.configure(configBuilder);

assertThat(getEventsFrom(configBuilder).values())
.extracting(Event::getId)
.contains(SYSTEM_SET_TTL);
}
}

0 comments on commit e750c9a

Please sign in to comment.