Package com.saasovation.collaboration.domain.model.calendar

Examples of com.saasovation.collaboration.domain.model.calendar.Calendar


        Tenant tenant = new Tenant("01234567");

        Set<CalendarSharer> invitees = new TreeSet<CalendarSharer>();
        invitees.add(new CalendarSharer(new Participant("zoe", "Zoe Doe", "zoe@saasovation.com")));

        Calendar calendar1 =
                new Calendar(
                        tenant,
                        DomainRegistry.calendarRepository().nextIdentity(),
                        "John Doe's Calendar",
                        "John Doe's everyday work calendar.",
                        new Owner("jdoe", "John Doe", "jdoe@saasovation.com"),
                        invitees);

        Calendar calendar2 =
                new Calendar(
                        tenant,
                        DomainRegistry.calendarRepository().nextIdentity(),
                        "Zoe Doe's Calendar",
                        "Zoe Doe's awesome person calendar.",
                        new Owner("zoe", "Zoe Doe", "zoe@saasovation.com"),
                        invitees);

        Calendar calendar3 =
                new Calendar(
                        tenant,
                        DomainRegistry.calendarRepository().nextIdentity(),
                        "Joe Smith's Calendar",
                        "Joe Smith's know-everything calendar.",
                        new Owner("joe", "Joe Smith", "joe@saasovation.com"),
View Full Code Here


        super();
    }

    public void testChangeCalendarDescription() throws Exception {

        Calendar calendar = this.calendarAggregate();

        DomainRegistry.calendarRepository().save(calendar);

        calendarApplicationService
            .changeCalendarDescription(
                    calendar.tenant().id(),
                    calendar.calendarId().id(),
                    "This is a changed description.");

        Calendar changedCalendar =
                DomainRegistry
                    .calendarRepository()
                    .calendarOfId(
                            calendar.tenant(),
                            calendar.calendarId());

        assertNotNull(changedCalendar);
        assertFalse(calendar.description().equals(changedCalendar.description()));
        assertEquals("This is a changed description.", changedCalendar.description());
    }
View Full Code Here

                    "My personal training calendar.",
                    "owner1",
                    sharerWith,
                    result);

        Calendar calendar =
                DomainRegistry
                    .calendarRepository()
                    .calendarOfId(
                            new Tenant(tenantId),
                            new CalendarId(calendarId));

        assertNotNull(calendar);
        assertEquals(tenantId, calendar.tenant().id());
        assertEquals(calendarId, calendar.calendarId().id());
        assertEquals("Personal Training", calendar.name());
        assertEquals("My personal training calendar.", calendar.description());
        assertEquals("owner1", calendar.owner().identity());
        assertEquals(1, calendar.allSharedWith().size());
        assertEquals("participant1", calendar.allSharedWith().iterator().next().participant().identity());
    }
View Full Code Here

        assertEquals("participant1", calendar.allSharedWith().iterator().next().participant().identity());
    }

    public void testRenameCalendar() throws Exception {

        Calendar calendar = this.calendarAggregate();

        DomainRegistry.calendarRepository().save(calendar);

        calendarApplicationService
            .renameCalendar(
                    calendar.tenant().id(),
                    calendar.calendarId().id(),
                    "My Training Calendar");

        Calendar changedCalendar =
                DomainRegistry
                    .calendarRepository()
                    .calendarOfId(
                            calendar.tenant(),
                            calendar.calendarId());

        assertNotNull(changedCalendar);
        assertFalse(calendar.name().equals(changedCalendar.name()));
        assertEquals("My Training Calendar", changedCalendar.name());
    }
View Full Code Here

        assertEquals("My Training Calendar", changedCalendar.name());
    }

    public void testScheduleCalendarEntry() throws Exception {

        Calendar calendar = this.calendarAggregate();

        DomainRegistry.calendarRepository().save(calendar);

        CalendarCommandResult result = new CalendarCommandResult() {
            @Override
            public void resultingCalendarId(String aCalendarId) {
                calendarId = aCalendarId;
            }
            @Override
            public void resultingCalendarEntryId(String aCalendarEntryId) {
                calendarEntryId = aCalendarEntryId;
            }
        };

        Date now = new Date();
        Date nextWeek = new Date(now.getTime() + (86400000L * 7L));
        Date nextWeekPlusOneHour = new Date(nextWeek.getTime() + (1000 * 60 * 60));

        calendarApplicationService
            .scheduleCalendarEntry(
                    calendar.tenant().id(),
                    calendar.calendarId().id(),
                    "My annual checkup appointment",
                    "Family Health Offices",
                    "owner1",
                    nextWeek,
                    nextWeekPlusOneHour,
                    "DoesNotRepeat",
                    nextWeekPlusOneHour,
                    "Hours",
                    8,
                    new HashSet<String>(0),
                    result);

        CalendarEntry calendarEntry =
                DomainRegistry
                    .calendarEntryRepository()
                    .calendarEntryOfId(
                            calendar.tenant(),
                            new CalendarEntryId(calendarEntryId));

        assertNotNull(calendarEntry);
        assertEquals("My annual checkup appointment", calendarEntry.description());
        assertEquals("Family Health Offices", calendarEntry.location());
View Full Code Here

        assertEquals("owner1", calendarEntry.owner().identity());
    }

    public void testShareCalendarWith() throws Exception {

        Calendar calendar = this.calendarAggregate();

        DomainRegistry.calendarRepository().save(calendar);

        Set<String> sharerWith = new HashSet<String>(0);
        sharerWith.add("participant1");
        sharerWith.add("participant2");

        calendarApplicationService
            .shareCalendarWith(
                    calendar.tenant().id(),
                    calendar.calendarId().id(),
                    sharerWith);

        Calendar sharedCalendar =
                DomainRegistry
                    .calendarRepository()
                    .calendarOfId(
                            calendar.tenant(),
                            calendar.calendarId());

        assertNotNull(sharedCalendar);
        assertEquals(2, sharedCalendar.allSharedWith().size());

        for (CalendarSharer sharer : sharedCalendar.allSharedWith()) {
            assertTrue(sharer.participant().identity().equals("participant1") ||
                       sharer.participant().identity().equals("participant2"));
        }
    }
View Full Code Here

        }
    }

    public void testUnshareCalendarWith() throws Exception {

        Calendar calendar = this.calendarAggregate();

        DomainRegistry.calendarRepository().save(calendar);

        Set<String> sharerWith = new HashSet<String>(0);
        sharerWith.add("participant1");
        sharerWith.add("participant2");
        sharerWith.add("participant3");

        calendarApplicationService
            .shareCalendarWith(
                    calendar.tenant().id(),
                    calendar.calendarId().id(),
                    sharerWith);

        Calendar sharedCalendar =
                DomainRegistry
                    .calendarRepository()
                    .calendarOfId(
                            calendar.tenant(),
                            calendar.calendarId());

        assertNotNull(sharedCalendar);
        assertEquals(3, sharedCalendar.allSharedWith().size());

        Set<String> unsharerWith = new HashSet<String>(sharerWith);
        assertTrue(unsharerWith.remove("participant2"));

        calendarApplicationService
            .unshareCalendarWith(
                    calendar.tenant().id(),
                    calendar.calendarId().id(),
                    unsharerWith);

        sharedCalendar =
                DomainRegistry
                    .calendarRepository()
                    .calendarOfId(
                            calendar.tenant(),
                            calendar.calendarId());

        assertEquals(1, sharedCalendar.allSharedWith().size());
        assertEquals("participant2", sharedCalendar.allSharedWith().iterator().next().participant().identity());
    }
View Full Code Here

            assertFalse(calendarData.getSharers().isEmpty());
        }
    }

    public void testQueryCalendar() throws Exception {
        Calendar calendar = this.calendarAggregate();

        CalendarSharer sharerZoe = new CalendarSharer(
                new Participant("zoe", "Zoe Doe", "zoe@saasovation.com"));

        calendar.shareCalendarWith(sharerZoe);

        CalendarSharer sharerJoe = new CalendarSharer(
                new Participant("joe", "Joe Smith", "joe@saasovation.com"));

        calendar.shareCalendarWith(sharerJoe);

        DomainRegistry.calendarRepository().save(calendar);

        CalendarData calendarData =
                calendarQueryService.calendarDataOfId(
                        calendar.tenant().id(),
                        calendar.calendarId().id());

        assertNotNull(calendarData);
        assertEquals(calendar.calendarId().id(), calendarData.getCalendarId());
        assertEquals(calendar.description(), calendarData.getDescription());
        assertEquals(calendar.name(), calendarData.getName());
        assertEquals(calendar.owner().emailAddress(), calendarData.getOwnerEmailAddress());
        assertEquals(calendar.owner().identity(), calendarData.getOwnerIdentity());
        assertEquals(calendar.owner().name(), calendarData.getOwnerName());
        assertEquals(calendar.tenant().id(), calendarData.getTenantId());
        assertNotNull(calendarData.getSharers());
        assertFalse(calendarData.getSharers().isEmpty());
        assertEquals(2, calendarData.getSharers().size());

        for (CalendarSharerData sharer : calendarData.getSharers()) {
            if (sharer.getParticipantIdentity().equals("zoe")) {
                assertEquals(calendar.calendarId().id(), sharer.getCalendarId());
                assertEquals(sharerZoe.participant().emailAddress(), sharer.getParticipantEmailAddress());
                assertEquals(sharerZoe.participant().identity(), sharer.getParticipantIdentity());
                assertEquals(sharerZoe.participant().name(), sharer.getParticipantName());
            } else {
                assertEquals(calendar.calendarId().id(), sharer.getCalendarId());
                assertEquals(sharerJoe.participant().emailAddress(), sharer.getParticipantEmailAddress());
                assertEquals(sharerJoe.participant().identity(), sharer.getParticipantIdentity());
                assertEquals(sharerJoe.participant().name(), sharer.getParticipantName());
            }
        }
View Full Code Here

TOP

Related Classes of com.saasovation.collaboration.domain.model.calendar.Calendar

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.