Package org.slim3.datastore.model

Examples of org.slim3.datastore.model.Hoge


     * @throws Exception
     */
    @Test
    public void compareForCollection() throws Exception {
        InMemoryDescCriterion c = new InMemoryDescCriterion(meta.myIntegerList);
        Hoge hoge = new Hoge();
        hoge.setMyIntegerList(new ArrayList<Integer>());
        Hoge hoge2 = new Hoge();
        hoge2.setMyIntegerList(new ArrayList<Integer>());
        assertThat(c.compare(hoge, hoge2), is(0));

        hoge.getMyIntegerList().add(1);
        assertThat(c.compare(hoge, hoge2), is(-1));
        assertThat(c.compare(hoge2, hoge), is(1));

        hoge2.getMyIntegerList().add(2);
        assertThat(c.compare(hoge, hoge2), is(1));
        assertThat(c.compare(hoge2, hoge), is(-1));
    }
View Full Code Here


     * @throws Exception
     */
    @Test
    public void getModel() throws Exception {
        assertThat(ref.getModel(), is(nullValue()));
        Hoge hoge = new Hoge();
        Datastore.put(hoge);
        ref.setKey(hoge.getKey());
        Hoge hoge2 = ref.getModel();
        assertThat(hoge2, is(notNullValue()));
        assertThat(hoge2, is(sameInstance(ref.getModel())));
    }
View Full Code Here

     * @throws Exception
     */
    @Test
    @SuppressWarnings("deprecation")
    public void getModelInGtx() throws Exception {
        Hoge hoge = new Hoge();
        Datastore.putWithoutTx(hoge);
        GlobalTransaction gtx = Datastore.beginGlobalTransaction();
        Hoge hoge2 = new Hoge();
        gtx.put(hoge2);
        ref.setKey(hoge.getKey());
        assertThat(ref.getModel(), is(notNullValue()));
    }
View Full Code Here

     * @throws Exception
     */
    @Test
    public void refresh() throws Exception {
        assertThat(ref.refresh(), is(nullValue()));
        Hoge hoge = new Hoge();
        Datastore.put(hoge);
        ref.setModel(hoge);
        assertThat(ref.refresh(), is(not(sameInstance(hoge))));
    }
View Full Code Here

    /**
     * @throws Exception
     */
    @Test
    public void setModel() throws Exception {
        Hoge hoge = new Hoge();
        ref.setModel(hoge);
        assertThat(ref.model, is(notNullValue()));
    }
View Full Code Here

     * @throws Exception
     */
    @Test
    public void getKey() throws Exception {
        assertThat(ref.getKey(), is(nullValue()));
        Hoge hoge = new Hoge();
        ref.setModel(hoge);
        assertThat(ref.getKey(), is(nullValue()));
        hoge.setKey(Datastore.createKey(Hoge.class, 1));
        assertThat(ref.getKey(), is(hoge.getKey()));
    }
View Full Code Here

    /**
     * @throws Exception
     */
    @Test(expected = IllegalStateException.class)
    public void setKeyWhenModelIsNotNull() throws Exception {
        Hoge hoge = new Hoge();
        hoge.setKey(Datastore.allocateId(Hoge.class));
        ref.setModel(hoge);
        ref.setKey(hoge.getKey());
    }
View Full Code Here

    /**
     * @throws Exception
     */
    @Test
    public void clear() throws Exception {
        Hoge hoge = new Hoge();
        hoge.setKey(Datastore.allocateId(Hoge.class));
        ref.setModel(hoge);
        ref.clear();
        assertThat(ref.model, is(nullValue()));
        assertThat(ref.key, is(nullValue()));
    }
View Full Code Here

    /**
     * @throws Exception
     */
    @Test
    public void assignKeyIfNecessary() throws Exception {
        Hoge hoge = new Hoge();
        ref.setModel(hoge);
        ref.assignKeyIfNecessary(ds);
        assertThat(ref.getKey(), is(notNullValue()));
        assertThat(hoge.getKey(), is(notNullValue()));
        assertThat(ref.getKey(), is(hoge.getKey()));
    }
View Full Code Here

    /**
     * @throws Exception
     */
    @Test
    public void assignKeyIfNecessaryKeyIsAssigned() throws Exception {
        Hoge hoge = new Hoge();
        hoge.setKey(KeyFactory.createKey("Hoge", 1));
        ref.setModel(hoge);
        ref.assignKeyIfNecessary(ds);
        assertThat(ref.getKey(), is(notNullValue()));
        assertThat(hoge.getKey(), is(notNullValue()));
        assertThat(ref.getKey(), is(hoge.getKey()));
    }
View Full Code Here

TOP

Related Classes of org.slim3.datastore.model.Hoge

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.