Package com.stoyanr.todo.client.presenter

Examples of com.stoyanr.todo.client.presenter.JsonSerializer


        Object[] args = inv.getArguments();
        return stored.get((String) args[0]);
    }

    public static JsonSerializer createMockSerializer() {
        JsonSerializer ser = mock(JsonSerializer.class);
        // @formatter:off
        when(ser.toString(any(Document.class))).thenAnswer(new Answer<String>() {
            public String answer(InvocationOnMock inv) {
                Document doc = (Document) inv.getArguments()[0];
                serialized.put(doc.getUserId(), doc);
                return doc.getUserId();
            }
        });
        when(ser.toString(any(Item.class))).thenAnswer(new Answer<String>() {
            public String answer(InvocationOnMock inv) {
                Item item = (Item) inv.getArguments()[0];
                String key = String.valueOf(item.getId());
                serialized.put(key, item);
                return key;
            }
        });
        when(ser.getDocument(anyString())).thenAnswer(new Answer<Document>() {
            public Document answer(InvocationOnMock inv) {
                String key = (String) inv.getArguments()[0];
                return (Document) serialized.get(key);
            }
        });
        when(ser.getItem(anyString())).thenAnswer(new Answer<Item>() {
            public Item answer(InvocationOnMock inv) {
                String key = (String) inv.getArguments()[0];
                return (Item) serialized.get(key);
            }
        });
View Full Code Here


        public void onSuccess() {
            ItemsView<Item> view = getItemsView();
            Document doc = new Document(userAccount.getUserId(), view.getData(),
                new Date(0));
            DocumentData data = new DocumentData(doc,
                new LocalStorage(storage), new JsonSerializer());
            new DocumentPresenter(itemsSvc, data, view).go(container);
        }
View Full Code Here

TOP

Related Classes of com.stoyanr.todo.client.presenter.JsonSerializer

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.