Package org.camelcookbook.transformation.csv.model

Examples of org.camelcookbook.transformation.csv.model.BookModel


    public void testCsvMarshal() throws Exception {
        ArrayList<BookModel> books = new ArrayList<BookModel>();

        final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMM-yyyy");

        BookModel book = new BookModel();
        book.setCategory("PROGRAMMING");
        book.setTitle("Camel in Action");
        book.setTitleLanguage("en");
        book.setAuthor1("Claus Ibsen");
        book.setAuthor2("Jon Anstey");
        book.setPublishDate(simpleDateFormat.parse("Dec-2010"));
        book.setPrice(BigDecimal.valueOf(49.99));

        books.add(book);

        book = new BookModel();
        book.setCategory("PROGRAMMING");
        book.setTitle("Apache Camel Developer's Cookbook");
        book.setTitleLanguage("en");
        book.setAuthor1("Scott Cranton");
        book.setAuthor2("Jakub Korab");
        book.setPublishDate(simpleDateFormat.parse("Dec-2013"));
        book.setPrice(BigDecimal.valueOf(49.99));

        books.add(book);

        final String response = template.requestBody("direct:marshal", books, String.class);
View Full Code Here


    protected List<Map<String, Object>> createCsvModel() throws ParseException {
        final List<Map<String, Object>> books = new ArrayList<Map<String, Object>>();

        final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMM-yyyy");

        BookModel book = new BookModel();
        book.setCategory("PROGRAMMING");
        book.setTitle("Apache Camel Developer's Cookbook");
        book.setTitleLanguage("en");
        book.setAuthor1("Scott Cranton");
        book.setAuthor2("Jakub Korab");
        book.setPublishDate(simpleDateFormat.parse("Dec-2013"));
        book.setPrice(BigDecimal.valueOf(49.99));

        Map<String, Object> bookEntry = new HashMap<String, Object>();
        bookEntry.put(BookModel.class.getCanonicalName(), book);
        books.add(bookEntry);
View Full Code Here

        final List<Map<String, BookModel>> response = CastUtils.cast(template.requestBody("direct:unmarshal", request, List.class));

        final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMM-yyyy");

        BookModel book1 = new BookModel();
        book1.setCategory("PROGRAMMING");
        book1.setTitle("Camel in Action");
        book1.setTitleLanguage("en");
        book1.setAuthor1("Claus Ibsen");
        book1.setAuthor2("Jon Anstey");
        book1.setPublishDate(simpleDateFormat.parse("Dec-2010"));
        book1.setPrice(BigDecimal.valueOf(49.99));

        BookModel book2 = new BookModel();
        book2.setCategory("PROGRAMMING");
        book2.setTitle("Apache Camel Developer's Cookbook");
        book2.setTitleLanguage("en");
        book2.setAuthor1("Scott Cranton");
        book2.setAuthor2("Jakub Korab");
        book2.setPublishDate(simpleDateFormat.parse("Dec-2013"));
        book2.setPrice(BigDecimal.valueOf(49.99));

        Map<String, BookModel> response1 = response.get(0);
        assertEquals(1, response1.size());

        // Map of <class name String>, <Model object value>
View Full Code Here

    public void testCsvMarshal() throws Exception {
        ArrayList<BookModel> books = new ArrayList<BookModel>();

        final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMM-yyyy");

        BookModel book = new BookModel();
        book.setCategory("PROGRAMMING");
        book.setTitle("Camel in Action");
        book.setTitleLanguage("en");
        book.setAuthor1("Claus Ibsen");
        book.setAuthor2("Jon Anstey");
        book.setPublishDate(simpleDateFormat.parse("Dec-2010"));
        book.setPrice(BigDecimal.valueOf(49.99));

        books.add(book);

        book = new BookModel();
        book.setCategory("PROGRAMMING");
        book.setTitle("Apache Camel Developer's Cookbook");
        book.setTitleLanguage("en");
        book.setAuthor1("Scott Cranton");
        book.setAuthor2("Jakub Korab");
        book.setPublishDate(simpleDateFormat.parse("Dec-2013"));
        book.setPrice(BigDecimal.valueOf(49.99));

        books.add(book);

        final String response = template.requestBody("direct:marshal", books, String.class);
View Full Code Here

        final List<Map<String, BookModel>> response = CastUtils.cast(template.requestBody("direct:unmarshal", request, List.class));

        final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMM-yyyy");

        BookModel book1 = new BookModel();
        book1.setCategory("PROGRAMMING");
        book1.setTitle("Camel in Action");
        book1.setTitleLanguage("en");
        book1.setAuthor1("Claus Ibsen");
        book1.setAuthor2("Jon Anstey");
        book1.setPublishDate(simpleDateFormat.parse("Dec-2010"));
        book1.setPrice(BigDecimal.valueOf(49.99));

        BookModel book2 = new BookModel();
        book2.setCategory("PROGRAMMING");
        book2.setTitle("Apache Camel Developer's Cookbook");
        book2.setTitleLanguage("en");
        book2.setAuthor1("Scott Cranton");
        book2.setAuthor2("Jakub Korab");
        book2.setPublishDate(simpleDateFormat.parse("Dec-2013"));
        book2.setPrice(BigDecimal.valueOf(49.99));

        Map<String, BookModel> response1 = response.get(0);
        assertEquals(1, response1.size());

        // Map of <class name String>, <Model object value>
View Full Code Here

        for (Map<String, Object> bookEntry : books) {
            final Book book = new Book();
            final Book.Title title = new Book.Title();

            final BookModel bookModel = (BookModel) bookEntry.get(BookModel.class.getCanonicalName());

            book.setCategory(bookModel.getCategory());

            title.setLang(bookModel.getTitleLanguage());
            title.setValue(bookModel.getTitle());
            book.setTitle(title);

            book.getAuthor().add(bookModel.getAuthor1());

            final String author2 = bookModel.getAuthor2();
            if ((author2 != null) && !author2.isEmpty()) {
                book.getAuthor().add(author2);
            }

            book.setYear(Integer.parseInt(simpleDateFormat.format(bookModel.getPublishDate())));
            book.setPrice(bookModel.getPrice().doubleValue());

            bookstore.getBook().add(book);
        }

        return bookstore;
View Full Code Here

TOP

Related Classes of org.camelcookbook.transformation.csv.model.BookModel

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.