Package com.webobjects.eocontrol

Examples of com.webobjects.eocontrol.EOEditingContext.unlock()


            Car c = Car.cars().objectAtIndex(0);
            ERXRestFormat format = new ERXRestFormat("json", new ERXXmlRestParser(), new ERXXmlRestWriter(), new ERXRestFormatDelegate("CUSTOMID", "type", "nil", true, true, true, true, true));
            assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<car CUSTOMID=\"Cooper S\" type=\"car\">\n" + "  <name>Cooper S</name>\n" + "</car>\n", format.toString(c, ERXKeyFilter.filterWithAttributes(), new ERXRestContext(editingContext)));
        }
        finally {
            editingContext.unlock();
            editingContext.dispose();
        }
    }

    public void testCustomNilAndTypeKeysFormat() {
View Full Code Here


            assertEquals("Mike", parsedPerson.name());
            assertNull(parsedPerson.age());
            assertNull(parsedPerson.salary());
        }
        finally {
            editingContext.unlock();
            editingContext.dispose();
        }
    }

    public void testUnderscoreNamesFormat() {
View Full Code Here

            ERXKeyFilter filter = ERXKeyFilter.filterWithAttributes();
            filter.include("nonModelAttribute");
            assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<companies type=\"array\">\n" + "  <company type=\"company\">\n" + "    <name>Mike</name>\n" + "    <revenue nil=\"true\"/>\n" + "    <non_model_attribute>NonModelAttribute</non_model_attribute>\n" + "  </company>\n" + "</companies>\n", format.toString(EOClassDescription.classDescriptionForEntityName(Company.ENTITY_NAME), cs, filter, new ERXRestContext(editingContext)));
        }
        finally {
            editingContext.unlock();
            editingContext.dispose();
        }
    }

    public void testNoNilKeysFormat() {
View Full Code Here

            ERXKeyFilter filter = ERXKeyFilter.filterWithAttributes();
            filter.include("nonModelAttribute");
            assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<companies type=\"array\">\n" + "  <company type=\"company\">\n" + "    <name>Mike</name>\n" + "    <revenue/>\n" + "    <non_model_attribute>NonModelAttribute</non_model_attribute>\n" + "  </company>\n" + "</companies>\n", format.toString(EOClassDescription.classDescriptionForEntityName(Company.ENTITY_NAME), cs, filter, new ERXRestContext(editingContext)));
        }
        finally {
            editingContext.unlock();
            editingContext.dispose();
        }
    }

    public void testNoArrayTypeFormat() {
View Full Code Here

            ERXKeyFilter filter = ERXKeyFilter.filterWithAttributes();
            filter.include("nonModelAttribute");
            assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<companies type=\"company\">\n" + "  <company type=\"company\">\n" + "    <name>Mike</name>\n" + "    <revenue/>\n" + "    <non_model_attribute>NonModelAttribute</non_model_attribute>\n" + "  </company>\n" + "</companies>\n", format.toString(EOClassDescription.classDescriptionForEntityName(Company.ENTITY_NAME), cs, filter, new ERXRestContext(editingContext)));
        }
        finally {
            editingContext.unlock();
            editingContext.dispose();
        }
    }

    public void testNoTypeKeysFormat() {
View Full Code Here

            ERXKeyFilter filter = ERXKeyFilter.filterWithAttributes();
            filter.include("nonModelAttribute");
            assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<companies>\n" + "  <company>\n" + "    <name>Mike</name>\n" + "    <revenue/>\n" + "    <non_model_attribute>NonModelAttribute</non_model_attribute>\n" + "  </company>\n" + "</companies>\n", format.toString(EOClassDescription.classDescriptionForEntityName(Company.ENTITY_NAME), cs, filter, new ERXRestContext(editingContext)));
        }
        finally {
            editingContext.unlock();
            editingContext.dispose();
        }
    }

    public void testUnsavedEOs() {
View Full Code Here

            p.setCompanyRelationship(c);
            assertEquals("{\"type\":\"Person\",\"age\":25,\"name\":\"Mike\",\"salary\":null,\"company\":{\"type\":\"Company\",\"name\":\"Company\",\"revenue\":null,\"employees\":[{\"type\":\"Person\"}]}}\n", ERXRestFormat.json().toString(p));
            assertEquals("{\"type\":\"Company\",\"name\":\"Company\",\"revenue\":null,\"employees\":[{\"type\":\"Person\",\"age\":25,\"name\":\"Mike\",\"salary\":null,\"company\":{\"type\":\"Company\"}}]}\n", ERXRestFormat.json().toString(c));
        }
        finally {
            editingContext.unlock();
            editingContext.dispose();
        }
    }

    public void testSimpleEO() {
View Full Code Here

        try {
            Company c = Company.createCompany(editingContext, "Company");
            assertEquals("{\"type\":\"Company\",\"name\":\"Company\",\"revenue\":null,\"employees\":[]}\n", ERXRestFormat.json().toString(c));
        }
        finally {
            editingContext.unlock();
            editingContext.dispose();
        }
    }

    public void testNonEntity() {
View Full Code Here

            ERXKeyFilter filter = ERXKeyFilter.filterWithAll();
            filter.include("nonModelAttribute");
            assertEquals("{\"type\":\"Company\",\"name\":\"Company\",\"revenue\":null,\"employees\":[],\"nonModelAttribute\":\"NonModelAttribute\"}\n", ERXRestFormat.json().toString(c, filter));
        }
        finally {
            editingContext.unlock();
            editingContext.dispose();
        }
    }

    public void testEOAndNonModelRelationship() {
View Full Code Here

            filter.include("nonModelAttribute");
            filter.include("manufacturers");
            assertEquals("{\"type\":\"Company\",\"name\":\"Company\",\"revenue\":null,\"employees\":[],\"nonModelAttribute\":\"NonModelAttribute\",\"manufacturers\":[{\"id\":\"Mini\",\"type\":\"Manufacturer\"},{\"id\":\"Porsche\",\"type\":\"Manufacturer\"},{\"id\":\"Toyota\",\"type\":\"Manufacturer\"}]}\n", ERXRestFormat.json().toString(c, filter));
        }
        finally {
            editingContext.unlock();
            editingContext.dispose();
        }
    }

    public void testCreateEO() {
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.