Package test.model

Examples of test.model.Nomination


    {

        final Date nominationDate = DateUtils.setMilliseconds(DateUtils.addDays(new Date(), -7), 0);
        final Date voteDate = new Date();

        final Nomination  nomination = new Nomination(UUID.randomUUID().toString(), "Test Agent", "Department of Testing", "https://sandbox.demo.socrata.com", nominationDate, null, false, false);
        final Nomination  nominationUpdate = new Nomination(nomination.getName(), "Test Agent", "Department of Testing", "https://sandbox.demo.socrata.com", nominationDate, voteDate, true, false);

        final Soda2Producer producer= createProducer();

        final Meta objectMetadata = producer.addObject(UPDATE_DATA_SET, nomination);
        final Nomination createdNomination = producer.getById(UPDATE_DATA_SET, objectMetadata.getId(), Nomination.class);
        TestCase.assertTrue(EqualsBuilder.reflectionEquals(nomination, createdNomination));

        final Meta updateMeta= producer.update(UPDATE_DATA_SET, objectMetadata.getId(), nominationUpdate);
        TestCase.assertEquals(objectMetadata.getId(), updateMeta.getId());

        TestCase.assertEquals(objectMetadata.getCreatedAt(), updateMeta.getCreatedAt());
        TestCase.assertEquals(objectMetadata.getCreatedMeta(), updateMeta.getCreatedMeta());
        TestCase.assertFalse(objectMetadata.getCreatedAt().after(updateMeta.getUpdatedAt()));

        final Nomination updatedNomination = producer.getById(UPDATE_DATA_SET, objectMetadata.getId(), Nomination.class);

        //UNDONE(willpugh) -- Turn back on when bug 7102 is fixed.
        //TestCase.assertTrue(EqualsBuilder.reflectionEquals(nominationUpdate, updatedNomination));

        List l = Lists.newArrayList(new DeleteRecord(objectMetadata.getId(), true));
        ObjectMapper m = new ObjectMapper();
        System.out.println(m.writeValueAsString(l));
        UpsertResult result = producer.upsert(UPDATE_DATA_SET, l);
        try {
            final Nomination deletedNomination = producer.getById(UPDATE_DATA_SET, objectMetadata.getId(), Nomination.class);
            TestCase.fail();
        } catch (DoesNotExistException e) {
            //Expected Condition
        }
View Full Code Here


            TestCase.assertEquals(2, retVal.size());
            TestCase.assertEquals("Name, Test", ((Map)retVal.get(0)).get("name"));
            TestCase.assertEquals("TEST (http://www.test.com)", ((Map) retVal.get(0)).get("agency_website"));

            //Test an update that will fail because of a PK constraint
            Nomination duplicatePk = new Nomination("Name, Test", "New Position", "This Agency", "http://foo.bar", new Date(), new Date(), false, false);

            producer.addObject(createdView.getId(), duplicatePk);
            //Verify the existing record was updated, rather than a new one being created
            retVal =  consumer.query(createdView.getId(), sortByNameQuery, Soda2Consumer.HASH_RETURN_TYPE);
            TestCase.assertEquals(2, retVal.size());
View Full Code Here

    @Test
    public void readmeProducerExamples() throws Exception {

        //This is the White Nomination Java Bean, that I want to add
        final Nomination NOMINATION_TO_ADD = new Nomination(
                "New, User", "Imaginary Friend", "Department of Imagination", null, new Date(), null, null, null
        );

        //This is the White Nomination Java Bean, that I want to update to
        final Nomination NOMINATION_TO_UPDATE = new Nomination(
                "New, User", "Imaginary Friend", "Department of Imagination", null, new Date(), new Date(), true, null
        );


        //Get the producer class to allow updates of the data set.
View Full Code Here

TOP

Related Classes of test.model.Nomination

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.