Package org.candlepin.gutterball.model

Examples of org.candlepin.gutterball.model.Event


    @Test
    public void testHandleCreatedCreatesANewComplianceStatusAndSetsDateToStatusDate() throws Exception {
        handler = new ComplianceHandler(mapper, complianceCurator);

        Event event = new Event();
        event.setNewEntity("test-string");

        Date expectedDate = new Date();
        ComplianceStatus status = new ComplianceStatus(expectedDate, "VALID");
        // Date is null here -- expected to be filled in with the status date.
        Compliance snap = new Compliance(null, new Consumer(), status);

        when(mapper.readValue(eq(event.getNewEntity()), eq(Compliance.class))).thenReturn(snap);
        handler.handleCreated(event);

        verify(complianceCurator).create(eq(snap));
        assertEquals(snap.getStatus().getDate(), snap.getDate());
    }
View Full Code Here


    @Test
    public void ensurePersistableFromJson() throws Exception {
        String eventJson = loadJsonFile("org/candlepin/gutterball/jackson/compliance-created.json");
        GutterballObjectMapper mapper = new GutterballObjectMapper();
        Event event = mapper.readValue(eventJson, Event.class);
        Compliance complianceSnap = mapper.readValue(event.getNewEntity(), Compliance.class);
        // This is normally done by the event handlers.
        complianceSnap.setDate(complianceSnap.getStatus().getDate());
        complianceSnapshotCurator.create(complianceSnap);
    }
View Full Code Here

        handler = new ConsumerHandler(mapper, consumerStateCurator);
    }

    @Test
    public void testCuratorCreatesNewConsumerStateOnHandlingCreatedEvent() throws Exception {
        Event event = new Event();
        event.setNewEntity("test-string");

        ConsumerState state = new ConsumerState();
        when(mapper.readValue(eq(event.getNewEntity()), eq(ConsumerState.class))).thenReturn(state);

        handler.handleCreated(event);
        verify(consumerStateCurator).create(eq(state));
    }
View Full Code Here

        verify(consumerStateCurator).create(eq(state));
    }

    @Test
    public void testCuratorUpdatesDeletedConsumerStateOnDeletedEvent() throws Exception {
        Event event = new Event();
        event.setOldEntity("test-string");

        ConsumerState state = new ConsumerState("test-uuid", "owner-key", new Date());
        when(mapper.readValue(eq(event.getOldEntity()), eq(ConsumerState.class))).thenReturn(state);

        handler.handleDeleted(event);
        verify(consumerStateCurator).setConsumerDeleted(eq(state.getUuid()), any(Date.class));
    }
View Full Code Here

        verify(consumerStateCurator).setConsumerDeleted(eq(state.getUuid()), any(Date.class));
    }

    @Test
    public void testConsumerStateIsNotUpdatedOnUpdateEvent() {
        handler.handleUpdated(new Event());
        verifyZeroInteractions(consumerStateCurator);
    }
View Full Code Here

    public void onMessage(Message message) {
        log.info(message.toString());

        try {
            String messageBody = getMessageBody(message);
            Event event = mapper.readValue(messageBody, Event.class);
            unitOfWork.begin();
            eventManager.handle(event);
            log.info("Received Event: " + event);
        }
        catch (Exception e) {
View Full Code Here

        eventManager = new TestingEventManager(handlers, eventCurator);
    }

    @Test
    public void verifyHandleCreated() {
        Event toHandle = new Event();
        toHandle.setTarget(TEST_HANDLER_TARGET);
        toHandle.setType(EventManager.CREATED_EVENT_TYPE);
        eventManager.handle(toHandle);
        verify(eventCurator).create(eq(toHandle));
        verify(handler).handleCreated(eq(toHandle));
        verify(handler, never()).handleUpdated(any(Event.class));
        verify(handler, never()).handleDeleted(any(Event.class));
View Full Code Here

        verify(handler, never()).handleDeleted(any(Event.class));
    }

    @Test
    public void verifyHandleUpdated() {
        Event toHandle = new Event();
        toHandle.setTarget(TEST_HANDLER_TARGET);
        toHandle.setType(EventManager.MODIFIED_EVENT_TYPE);
        eventManager.handle(toHandle);
        verify(eventCurator).create(eq(toHandle));
        verify(handler).handleUpdated(eq(toHandle));
        verify(handler, never()).handleCreated(any(Event.class));
        verify(handler, never()).handleDeleted(any(Event.class));
View Full Code Here

        verify(handler, never()).handleDeleted(any(Event.class));
    }

    @Test
    public void verifyHandleDeleted() {
        Event toHandle = new Event();
        toHandle.setTarget(TEST_HANDLER_TARGET);
        toHandle.setType(EventManager.DELETED_EVENT_TYPE);
        eventManager.handle(toHandle);
        verify(eventCurator).create(eq(toHandle));
        verify(handler).handleDeleted(eq(toHandle));
        verify(handler, never()).handleCreated(any(Event.class));
        verify(handler, never()).handleUpdated(any(Event.class));
View Full Code Here

        verify(handler, never()).handleUpdated(any(Event.class));
    }

    @Test
    public void testEventManagerUnknown() {
        Event toHandle = new Event();
        toHandle.setTarget("UNKNOWN_EVENT_TARGET");
        eventManager.handle(toHandle);
        verify(eventCurator).create(eq(toHandle));
        verify(handler, never()).handleCreated(any(Event.class));
        verify(handler, never()).handleUpdated(any(Event.class));
        verify(handler, never()).handleDeleted(any(Event.class));
View Full Code Here

TOP

Related Classes of org.candlepin.gutterball.model.Event

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.