generated from hmcts/spring-boot-template
-
Notifications
You must be signed in to change notification settings - Fork 6
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
89c812a
commit e750c9a
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/main/java/uk/gov/hmcts/divorce/systemupdate/event/SystemSetTimeToLive.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,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); | ||
} | ||
} | ||
|
34 changes: 34 additions & 0 deletions
34
src/test/java/uk/gov/hmcts/divorce/systemupdate/event/SystemSetTimeToLiveTest.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,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); | ||
} | ||
} |