All pastes #270566 Raw Edit

Untitled

public text v1 · immutable
·published 2006-12-07 14:24 UTC
rendered paste body
    public void testDigestBatch() throws Exception {
        String[] sql = new String[] {
                // fredrik and emma should get a digest
            "insert into personal_notification (id, recipient, received, entityClass, entityId) values (310, 'fredrik', '"+today()+"', 'net.unikum.model.devplan.DevelopmentPlan', 9)",
            "insert into personal_notification (id, recipient, received) values (490, 'gunnar', '2006-10-15 09:12:00')",
            "insert into personal_notification (id, recipient, received) values (491, 'fredrik', '2006-10-10 20:20:20')",
            "insert into personal_notification (id, recipient, received, entityClass, entityId) values (492, 'emma', '"+today()+"', 'net.unikum.model.devplan.DevelopmentPlan', 9)",
            "insert into personal_notification (id, recipient, received, entityClass, entityId) values (493, 'fredrik', '"+today()+"', 'net.unikum.model.devplan.DevelopmentPlan', 19)",
            "insert into personal_notification (id, recipient, received, entityClass, entityId) values (494, 'emma', '"+today()+"', 'net.unikum.model.devplan.OwnedObjective', 29)",
            "insert into personal_notification (id, recipient, received, actedUpOn, entityClass, entityId) values (495, 'fredrik', '"+today()+"', true, 'net.unikum.model.devplan.DevelopmentPlan', 99)",
            "insert into personal_notification (id, recipient, received) values (496, 'enrique', '2006-10-15 09:12:00')",
            "insert into personal_notification (id, recipient, received, entityClass, entityId) values (497, 'fredrik', '"+today()+"', 'net.unikum.model.devplan.OwnedObjective', 9)",
        };
        jdbcTemplate.batchUpdate(sql);

        Message message1 = new Message();
        Message message2 = new Message();

        // this is really whack
        MockObjectTestCase mo = new MockObjectTestCase(){};

        messageManagerMock.expects(mo.once()).method("createMessage")
                .with(mo.eq("mailtemplates/nightlydigest.vm"), mo.isA(Map.class))
                .will(mo.returnValue(message1));
        messageManagerMock.expects(mo.once()).method("sendMessage")
                .with(mo.eq(message1), mo.eq(new Recipient("emma@slaskpost.se")));


        messageManagerMock.expects(mo.once()).method("createMessage")
                .with(mo.eq("mailtemplates/nightlydigest.vm"), mo.isA(Map.class))
                .will(mo.returnValue(message2));
        messageManagerMock.expects(mo.once()).method("sendMessage")
                .with(mo.eq(message2), mo.eq(new Recipient("fredrik@lillaskolan.se")));


        notificationManager.digestBatch();
        
        messageManagerMock.verify();
    }