Examples of CouchErrorContent


Examples of com.couchace.core.api.response.CouchErrorContent

@Test
public class CouchErrorContentTest {

    public void parseValidJsonTest() {
        String json = "{\"error\":\"some error\",\"reason\":\"some reason\"}";
        CouchErrorContent errorContent = CouchErrorContent.parseJson(json);
        assertEquals(errorContent.getError(), "some error");
        assertEquals(errorContent.getReason(), "some reason");
        assertFalse(errorContent.isNoError());

        json = "{\"error\":\"some error\"}";
        errorContent = CouchErrorContent.parseJson(json);
        assertEquals(errorContent.getError(), "some error");
        assertNull(errorContent.getReason());
        assertFalse(errorContent.isNoError());

        json = "{\"reason\":\"some reason\"}";
        errorContent = CouchErrorContent.parseJson(json);
        assertNull(errorContent.getError());
        assertEquals(errorContent.getReason(), "some reason");
        assertFalse(errorContent.isNoError());
    }
View Full Code Here

Examples of com.couchace.core.api.response.CouchErrorContent

        assertEquals(errorContent.getReason(), "some reason");
        assertFalse(errorContent.isNoError());
    }

    public void parseInvalidJsonTest() {
        CouchErrorContent errorContent = CouchErrorContent.parseJson("junk");
        assertEquals(errorContent.getError(), "junk");
        assertEquals(errorContent.getReason(), "junk");
        assertFalse(errorContent.isNoError());

        errorContent = CouchErrorContent.parseJson("{junk}");
        assertEquals(errorContent.getError(), "{junk}");
        assertEquals(errorContent.getReason(), "{junk}");
        assertFalse(errorContent.isNoError());

        errorContent = CouchErrorContent.parseJson("");
        assertEquals(errorContent, CouchErrorContent.noError);
        assertEquals(errorContent.getError(), "none");
        assertEquals(errorContent.getReason(), "No error");
        assertTrue(errorContent.isNoError());

        errorContent = CouchErrorContent.parseJson(null);
        assertEquals(errorContent, CouchErrorContent.noError);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.