Package com.impetus.client.crud.entities

Examples of com.impetus.client.crud.entities.PersonMongoMTO


    {
        AddressMongoMTO address = new AddressMongoMTO();
        address.setAddressId("a");
        address.setStreet("sector 11");

        PersonMongoMTO person1 = new PersonMongoMTO();
        person1.setPersonId("1");
        person1.setPersonName("Kuldeep");

        PersonMongoMTO person2 = new PersonMongoMTO();
        person2.setPersonId("2");
        person2.setPersonName("vivek");

        person1.setAddress(address);
        person2.setAddress(address);

        em.persist(person1);
        em.persist(person2);

        em = getNewEM();

        PersonMongoMTO foundPerson1 = em.find(PersonMongoMTO.class, "1");
        Assert.assertNotNull(foundPerson1);
        Assert.assertNotNull(foundPerson1.getAddress());
        Assert.assertEquals("1", foundPerson1.getPersonId());
        Assert.assertEquals("Kuldeep", foundPerson1.getPersonName());
        Assert.assertEquals("a", foundPerson1.getAddress().getAddressId());
        Assert.assertEquals("sector 11", foundPerson1.getAddress().getStreet());

        PersonMongoMTO foundPerson2 = em.find(PersonMongoMTO.class, "2");
        Assert.assertNotNull(foundPerson2);
        Assert.assertNotNull(foundPerson2.getAddress());
        Assert.assertEquals("2", foundPerson2.getPersonId());
        Assert.assertEquals("vivek", foundPerson2.getPersonName());
        Assert.assertEquals("a", foundPerson2.getAddress().getAddressId());
        Assert.assertEquals("sector 11", foundPerson2.getAddress().getStreet());

        foundPerson1.setPersonName("KK");

        foundPerson2.setPersonName("vives");

        em.merge(foundPerson1);
        em.merge(foundPerson2);

        em = getNewEM();

        foundPerson1 = em.find(PersonMongoMTO.class, "1");
        Assert.assertNotNull(foundPerson1);
        Assert.assertNotNull(foundPerson1.getAddress());
        Assert.assertEquals("1", foundPerson1.getPersonId());
        Assert.assertEquals("KK", foundPerson1.getPersonName());
        Assert.assertEquals("a", foundPerson1.getAddress().getAddressId());
        Assert.assertEquals("sector 11", foundPerson1.getAddress().getStreet());

        foundPerson2 = em.find(PersonMongoMTO.class, "2");
        Assert.assertNotNull(foundPerson2);
        Assert.assertNotNull(foundPerson2.getAddress());
        Assert.assertEquals("2", foundPerson2.getPersonId());
        Assert.assertEquals("vives", foundPerson2.getPersonName());
        Assert.assertEquals("a", foundPerson2.getAddress().getAddressId());
        Assert.assertEquals("sector 11", foundPerson2.getAddress().getStreet());

        em.remove(foundPerson1);
        em.remove(foundPerson2);

        foundPerson1 = em.find(PersonMongoMTO.class, "1");
View Full Code Here

TOP

Related Classes of com.impetus.client.crud.entities.PersonMongoMTO

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.