Package com.alibaba.citrus.service.mail.impl

Examples of com.alibaba.citrus.service.mail.impl.MailServiceImpl


        assertNotNull(mailService);
    }

    @Test
    public void importedServices() throws Exception {
        mailService = new MailServiceImpl();

        List<?> importedServices = getFieldValue(mailService, "importedServices", List.class);

        assertNotNull(importedServices);
        assertTrue(importedServices.isEmpty());
View Full Code Here


        }
    }

    @Test
    public void setMails() {
        MailServiceImpl mailService = new MailServiceImpl();

        // miss mail id
        Map<String, MailBuilder> mails = createHashMap();
        mails.put(null, new MailBuilder());

        try {
            mailService.setMails(mails);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("mail id"));
        }

        // miss mail object
        mails = createHashMap();
        mails.put("id", null);

        try {
            mailService.setMails(mails);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("mail builder"));
        }

        // set null
        mailService = new MailServiceImpl();
        mailService.setMails(null);

        // reset mails
        mails = createHashMap();
        mails.put("mail1", new MailBuilder());
        mails.put("mail2", new MailBuilder());
        mailService.setMails(mails);

        assertNotNull(mailService.getMailBuilder("mail1"));
        assertNotNull(mailService.getMailBuilder("mail2"));

        mails = createHashMap();
        mails.put("mail3", new MailBuilder());
        mails.put("mail4", new MailBuilder());
        mailService.setMails(mails);

        try {
            mailService.getMailBuilder("mail1");
            fail();
        } catch (MailNotFoundException e) {
            assertThat(e, exception("Could not find mail builder: mail1"));
        }

        try {
            mailService.getMailBuilder("mail2");
            fail();
        } catch (MailNotFoundException e) {
            assertThat(e, exception("Could not find mail builder: mail2"));
        }

        assertNotNull(mailService.getMailBuilder("mail3"));
        assertNotNull(mailService.getMailBuilder("mail4"));
    }
View Full Code Here

        assertNotNull(mailService.getMailBuilder("mail4"));
    }

    @Test
    public void setMailTransports() {
        MailServiceImpl mailService = new MailServiceImpl();

        // set null
        mailService.setMailTransports(null);

        // reset transports
        Map<String, MailTransport> transports = createHashMap();
        transports.put("transport1", new MailTransport());
        transports.put("transport2", new MailTransport());
        mailService.setMailTransports(transports);

        assertNotNull(mailService.getMailTransport("transport1"));
        assertNotNull(mailService.getMailTransport("transport2"));

        transports = createHashMap();
        transports.put("transport3", new MailTransport());
        transports.put("transport4", new MailTransport());
        mailService.setMailTransports(transports);

        try {
            mailService.getMailTransport("transport1");
            fail();
        } catch (MailTransportNotFoundException e) {
            assertThat(e, exception("Could not find mail transport: transport1"));
        }

        try {
            mailService.getMailTransport("transport2");
            fail();
        } catch (MailTransportNotFoundException e) {
            assertThat(e, exception("Could not find mail transport: transport2"));
        }

        assertNotNull(mailService.getMailTransport("transport3"));
        assertNotNull(mailService.getMailTransport("transport4"));
    }
View Full Code Here

        assertNotNull(mailService.getMailTransport("transport4"));
    }

    @Test
    public void setMailStores() {
        MailServiceImpl mailService = new MailServiceImpl();

        // set null
        mailService.setMailStores(null);

        // reset stores
        Map<String, MailStore> stores = createHashMap();
        stores.put("store1", new MailStore());
        stores.put("store2", new MailStore());
        mailService.setMailStores(stores);

        assertNotNull(mailService.getMailStore("store1"));
        assertNotNull(mailService.getMailStore("store2"));

        stores = createHashMap();
        stores.put("store3", new MailStore());
        stores.put("store4", new MailStore());
        mailService.setMailStores(stores);

        try {
            mailService.getMailStore("store1");
            fail();
        } catch (MailStoreNotFoundException e) {
            assertThat(e, exception("Could not find mail store: store1"));
        }

        try {
            mailService.getMailStore("store2");
            fail();
        } catch (MailStoreNotFoundException e) {
            assertThat(e, exception("Could not find mail store: store2"));
        }

        assertNotNull(mailService.getMailStore("store3"));
        assertNotNull(mailService.getMailStore("store4"));
    }
View Full Code Here

        assertNotNull(mailService.getMailStore("store4"));
    }

    @Test
    public void getTransport() {
        MailServiceImpl mailService = new MailServiceImpl();

        Map<String, MailTransport> transports = createHashMap();
        transports.put("transport1", new MailTransport());
        mailService.setMailTransports(transports);

        // id is null
        try {
            mailService.getMailTransport((String) null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("no mailTransport id"));
        }

        // clone
        MailTransport transport = mailService.getMailTransport("transport1");

        assertNotNull(transport);
        assertNotSame(transport, mailService.getMailTransport("transport1"));
    }
View Full Code Here

        assertNotSame(transport, mailService.getMailTransport("transport1"));
    }

    @Test
    public void getDefaultTransport() {
        MailServiceImpl mailService = new MailServiceImpl();

        // 1 transport
        Map<String, MailTransport> transports = createHashMap();
        transports.put("transport1", new MailTransport());
        mailService.setMailTransports(transports);

        assertNotNull(mailService.getMailTransport()); // the only transport is the default transport

        // 2 transports
        transports.put("transport2", new MailTransport());
        mailService.setMailTransports(transports);

        try {
            mailService.getMailTransport();
            fail();
        } catch (MailTransportNotFoundException e) {
            assertThat(e, exception("Could not find mail transport: _DEFAULT_"));
        }

        // with default transport
        MailTransport transport3 = new MailTransport();
        transport3.setDefault(true);
        transports.put("transport3", transport3);
        mailService.setMailTransports(transports);

        assertNotNull(mailService.getMailTransport());
        assertNotNull(mailService.getMailTransport("transport3"));

        // 2 default transports
        MailTransport transport4 = new MailTransport();
        transport4.setDefault(true);
        transports.put("transport4", transport4);

        try {
            mailService.setMailTransports(transports);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("more than 1 default transports"));
        }
    }
View Full Code Here

        }
    }

    @Test
    public void getStore() {
        MailServiceImpl mailService = new MailServiceImpl();

        Map<String, MailStore> stores = createHashMap();
        stores.put("store1", new MailStore());
        mailService.setMailStores(stores);

        // id is null
        try {
            mailService.getMailStore((String) null);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("no mailStore id"));
        }

        // clone
        MailStore store = mailService.getMailStore("store1");

        assertNotNull(store);
        assertNotSame(store, mailService.getMailStore("store1"));
    }
View Full Code Here

        assertNotSame(store, mailService.getMailStore("store1"));
    }

    @Test
    public void getDefaultStore() {
        MailServiceImpl mailService = new MailServiceImpl();

        // 1 store
        Map<String, MailStore> stores = createHashMap();
        stores.put("store1", new MailStore());
        mailService.setMailStores(stores);

        assertNotNull(mailService.getMailStore()); // the only store is the default store

        // 2 stores
        stores.put("store2", new MailStore());
        mailService.setMailStores(stores);

        try {
            mailService.getMailStore();
            fail();
        } catch (MailStoreNotFoundException e) {
            assertThat(e, exception("Could not find mail store: _DEFAULT_"));
        }

        // with default store
        MailStore store3 = new MailStore();
        store3.setDefault(true);
        stores.put("store3", store3);
        mailService.setMailStores(stores);

        assertNotNull(mailService.getMailStore());
        assertNotNull(mailService.getMailStore("store3"));

        // 2 default stores
        MailStore store4 = new MailStore();
        store4.setDefault(true);
        stores.put("store4", store4);

        try {
            mailService.setMailStores(stores);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("more than 1 default stores"));
        }
    }
View Full Code Here

        assertNotNull(mailService);
    }

    @Test
    public void importedServices() throws Exception {
        mailService = new MailServiceImpl();

        List<?> importedServices = getFieldValue(mailService, "importedServices", List.class);

        assertNotNull(importedServices);
        assertTrue(importedServices.isEmpty());
View Full Code Here

        }
    }

    @Test
    public void setMails() {
        MailServiceImpl mailService = new MailServiceImpl();

        // miss mail id
        Map<String, MailBuilder> mails = createHashMap();
        mails.put(null, new MailBuilder());

        try {
            mailService.setMails(mails);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("mail id"));
        }

        // miss mail object
        mails = createHashMap();
        mails.put("id", null);

        try {
            mailService.setMails(mails);
            fail();
        } catch (IllegalArgumentException e) {
            assertThat(e, exception("mail builder"));
        }

        // set null
        mailService = new MailServiceImpl();
        mailService.setMails(null);

        // reset mails
        mails = createHashMap();
        mails.put("mail1", new MailBuilder());
        mails.put("mail2", new MailBuilder());
        mailService.setMails(mails);

        assertNotNull(mailService.getMailBuilder("mail1"));
        assertNotNull(mailService.getMailBuilder("mail2"));

        mails = createHashMap();
        mails.put("mail3", new MailBuilder());
        mails.put("mail4", new MailBuilder());
        mailService.setMails(mails);

        try {
            mailService.getMailBuilder("mail1");
            fail();
        } catch (MailNotFoundException e) {
            assertThat(e, exception("Could not find mail builder: mail1"));
        }

        try {
            mailService.getMailBuilder("mail2");
            fail();
        } catch (MailNotFoundException e) {
            assertThat(e, exception("Could not find mail builder: mail2"));
        }

        assertNotNull(mailService.getMailBuilder("mail3"));
        assertNotNull(mailService.getMailBuilder("mail4"));
    }
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.service.mail.impl.MailServiceImpl

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.