Package com.vtence.tape.testmodel

Examples of com.vtence.tape.testmodel.Product


    public static Table<Product> products() {
        return new ProductRecord().products;
    }

    public Product hydrate(ResultSet rs) throws SQLException {
        Product product = new Product(number.get(rs), name.get(rs), description.get(rs));
        idOf(product).set(id.get(rs));
        return product;
    }
View Full Code Here


        JDBC.close(connection);
    }

    @Test public void
    insertingANewRecord() throws Exception {
        final Product original = aProduct().withNumber("12345678").named("English Bulldog").describedAs("A muscular heavy dog").build();

        transactor.perform(new UnitOfWork() {
            public void execute() throws Exception {
                int inserted = Insert.into(products, original).execute(connection);
                assertThat("records inserted", inserted, is(1));
            }
        });

        Product record = Select.from(products).first(connection);
        assertThat("inserted record", record, samePropertyValuesAs(original));
    }
View Full Code Here

        assertThat("inserted record", record, samePropertyValuesAs(original));
    }

    @Test public void
    insertingAEntityWillSetItsIdentifier() throws Exception {
        final Product entity = aProduct().build();
        assertThat("orginal id", idOf(entity), nullValue());

        transactor.perform(new UnitOfWork() {
            public void execute() throws Exception {
                Insert.into(products, entity).execute(connection);
View Full Code Here

    }

    @Test public void
    updatingAnExistingRecord() throws Exception {
        persist(aProduct().named("Dalmatian"));
        final Product original = persist(aProduct().withNumber("12345678").named("English Bulldog").describedAs("A muscular heavy dog"));

        original.setName("Labrador Retriever");
        original.setDescription("A fun type of dog");
        transactor.perform(new UnitOfWork() {
            public void execute() throws Exception {
                int updated = Update.set(products, original).where("number = ?", "12345678").execute(connection);
                assertThat("records updated", updated, is(1));
            }
        });

        Product record = Select.from(products).where("name = ?", "Labrador Retriever").first(connection);
        assertThat("updated record", record, samePropertyValuesAs(original));
    }
View Full Code Here

        JDBC.close(connection);
    }

    @Test public void
    retrievingASingleRecordWithAllColumns() throws Exception {
        Product original = persist(aProduct().withNumber("12345678").named("English Bulldog").describedAs("A muscular heavy dog"));

        Product record = Select.from(products).first(connection);
        assertThat("record", record, sameProductAs(original));
    }
View Full Code Here

    @SuppressWarnings("unchecked") @Test public void
    selectingTheFirstInACollectionOfRecords() throws Exception {
        persist(aProduct().named("Bulldog"), aProduct().named("Dalmatian"), aProduct().named("Labrador"));

        Product selection = Select.from(products).first(connection);
        assertThat("selection", selection, is(productNamed("Bulldog")));
    }
View Full Code Here

    @SuppressWarnings("unchecked") @Test public void
    selectingOnlyThoseRecordsThatFulfillASpecifiedCriterion() throws Exception {
        persist(aProduct().named("Bulldog"), aProduct().named("Dalmatian"), aProduct().named("Labrador"));

        Product selection = Select.from(products).where("name = ?", "Labrador").first(connection);
        assertThat("selection", selection, is(productNamed("Labrador")));
    }
View Full Code Here

    extractingRecordsBasedOnMultipleCriteria() throws Exception {
        persist(aProduct().named("English Bulldog").describedAs("female"),
                aProduct().named("French Bulldog").describedAs("male"),
                aProduct().named("Labrador Retriever").describedAs("male"));

        Product selection = Select.from(products).where("name like ? and description = ?", "%Bulldog", "male").first(connection);
        assertThat("selection", selection, is(productNamed("French Bulldog")));
    }
View Full Code Here

        assertThat("selection", selection, hasSize(1));
    }

    @SuppressWarnings("unchecked") @Test public void
    queryingDataFromMultipleTables() throws Exception {
        Product boxer = persist(aProduct().named("Boxer").withNumber("BOXER"));
        persist(a(boxer).priced("1199.00"));
        Product bulldog = persist(aProduct().named("Bulldog").withNumber("BULLDOG"));
        persist(a(bulldog).priced("899.00"));
        persist(a(bulldog).priced("699.00"));

        List<Item> selection = Select.from(items, "item").
                join(products, "product", "item.product_id = product.id").
View Full Code Here

        this.description = description;
        return this;
    }

    public Product build() {
        return new Product(number, name, description);
    }
View Full Code Here

TOP

Related Classes of com.vtence.tape.testmodel.Product

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.