Package org.candlepin.gutterball.model

Examples of org.candlepin.gutterball.model.ConsumerState


        return formatter.format(date);
    }

    private void createInitialConsumer(Date createdOn, String uuid, String owner, String status) {
        createSnapshot(createdOn, uuid, owner, status);
        consumerStateCurator.create(new ConsumerState(uuid, owner, createdOn));
    }
View Full Code Here


    public void handleCreated(Event event) {
        String newConsumerJson = event.getNewEntity();

        // JPA Insertion
        try {
            ConsumerState consumerState = mapper.readValue(newConsumerJson, ConsumerState.class);
            consumerStateCurator.create(consumerState);
        }
        catch (IOException e) {
            throw new RuntimeException("Unable to deserialize Consumer Created Event.", e);
        }
View Full Code Here

    }

    @Override
    public void handleDeleted(Event event) {
        try {
            ConsumerState consumerState = mapper.readValue(event.getOldEntity(), ConsumerState.class);
            // consumerState is considered a new record here as it is parsed from CP json.
            // We just want to extract the UUID from the event.
            consumerStateCurator.setConsumerDeleted(consumerState.getUuid(), event.getTimestamp());
        }
        catch (IOException e) {
            throw new RuntimeException("Unable to deserialize Consumer Deleted Event.", e);
        }
    }
View Full Code Here

    @Test
    public void testUuidIncludedWhenTargetDateIsBetweenConsumerCreateAndDeleteDates() {
        Calendar cal = getPrimedCalendar();
        String uuid = TestUtils.randomString("test-consumer-uuid");
        ConsumerState state = new ConsumerState(uuid, "test-owner", cal.getTime());
        consumerStateCurator.create(state);

        cal.add(Calendar.MONTH, 1);
        consumerStateCurator.setConsumerDeleted(uuid, cal.getTime());
View Full Code Here

        cal.add(Calendar.MONTH, 1);
        Date targetDate = cal.getTime();

        // Should be filtered out due to different owner.
        String filteredUuid = TestUtils.randomString("filtered-consumer-uuid");
        consumerStateCurator.create(new ConsumerState(filteredUuid, "TO1", creationDate));

        String targetOwnerKey = "TO2";
        String includedUuid = TestUtils.randomString("included-consumer-uuid");
        consumerStateCurator.create(new ConsumerState(includedUuid, targetOwnerKey, creationDate));

        // Should not be returned as it is deleted
        String deletedUuid = TestUtils.randomString("deleted-consumer-uuid");
        consumerStateCurator.create(new ConsumerState(deletedUuid, targetOwnerKey, creationDate));
        consumerStateCurator.setConsumerDeleted(deletedUuid, deletionDate);

        List<String> uuids = consumerStateCurator.getConsumerUuidsOnDate(targetDate,
                Arrays.asList(targetOwnerKey), null);
        assertEquals(1, uuids.size());
View Full Code Here

        Date targetDate = cal.getTime();

        String ownerKey = TestUtils.randomString("owner-key");
        String expectedUuid = TestUtils.randomString("expected-consumer-uuid");

        consumerStateCurator.create(new ConsumerState(expectedUuid, ownerKey, creationDate));
        consumerStateCurator.create(new ConsumerState(TestUtils.randomString("not-inculded"), ownerKey,
                creationDate));
        List<String> uuids = consumerStateCurator.getConsumerUuidsOnDate(targetDate, null,
                Arrays.asList(expectedUuid));
        assertEquals(1, uuids.size());
        assertTrue(uuids.contains(expectedUuid));
View Full Code Here

        return snap;
    }

    private void createInitialConsumer(Date createdOn, String uuid, String owner, String status) {
        createSnapshot(createdOn, uuid, owner, status);
        consumerStateCurator.create(new ConsumerState(uuid, owner, createdOn));
    }
View Full Code Here

    @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

    @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

public class ConsumerStateCuratorTest extends DatabaseTestFixture {

    @Test
    public void testInsertAndFindByUUID() {
        ConsumerState state = new ConsumerState("abc-123", "test-owner", new Date());
        consumerStateCurator.create(state);

        ConsumerState found = consumerStateCurator.findByUuid("abc-123");
        assertNotNull(found);
        assertEquals(state.getUuid(), found.getUuid());
    }
View Full Code Here

TOP

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

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.