-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
6 changed files
with
62 additions
and
40 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
68 changes: 36 additions & 32 deletions
68
src/test/groovy/no/fint/provider/events/eventstate/JanitorServiceSpec.groovy
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 |
---|---|---|
@@ -1,32 +1,36 @@ | ||
package no.fint.provider.events.eventstate | ||
|
||
import no.fint.audit.FintAuditService | ||
import no.fint.event.model.Event | ||
import spock.lang.Specification | ||
|
||
class JanitorServiceSpec extends Specification { | ||
private EventStateService eventStateService | ||
private FintAuditService fintAuditService | ||
private JanitorService janitorService | ||
|
||
void setup() { | ||
eventStateService = Mock(EventStateService) | ||
fintAuditService = Mock(FintAuditService) | ||
janitorService = new JanitorService(eventStateService: eventStateService, fintAuditService: fintAuditService) | ||
} | ||
|
||
def "Remove expired event states"() { | ||
given: | ||
def event = new Event(orgId: 'rogfk.no') | ||
def expiredEventState = new EventState(event, -10) | ||
def notExpiredEventState = new EventState(event, 5000) | ||
|
||
when: | ||
janitorService.cleanUpEventStates() | ||
|
||
then: | ||
1 * eventStateService.getEventStates() >> [expiredEventState, notExpiredEventState] | ||
1 * eventStateService.remove(_ as Event) | ||
1 * fintAuditService.audit(_ as Event) | ||
} | ||
} | ||
package no.fint.provider.events.eventstate | ||
|
||
import no.fint.audit.FintAuditService | ||
import no.fint.event.model.Event | ||
import no.fint.events.FintEvents | ||
import spock.lang.Specification | ||
|
||
class JanitorServiceSpec extends Specification { | ||
private EventStateService eventStateService | ||
private FintAuditService fintAuditService | ||
private JanitorService janitorService | ||
private FintEvents fintEvents | ||
|
||
void setup() { | ||
eventStateService = Mock(EventStateService) | ||
fintAuditService = Mock(FintAuditService) | ||
fintEvents = Mock(FintEvents) | ||
janitorService = new JanitorService(eventStateService: eventStateService, fintAuditService: fintAuditService, fintEvents: fintEvents) | ||
} | ||
|
||
def "Remove expired event states"() { | ||
given: | ||
def event = new Event(orgId: 'rogfk.no') | ||
def expiredEventState = new EventState(event, -10) | ||
def notExpiredEventState = new EventState(event, 5000) | ||
|
||
when: | ||
janitorService.cleanUpEventStates() | ||
|
||
then: | ||
1 * eventStateService.getEventStates() >> [expiredEventState, notExpiredEventState] | ||
1 * eventStateService.remove(_ as Event) | ||
1 * fintAuditService.audit(_ as Event) | ||
1 * fintEvents.sendUpstream(_ as Event) | ||
} | ||
} |