Example #1
0
 /** @throws Exception */
 @Test(expected = IllegalArgumentException.class)
 public void getModelMetaWithEntityForIllegalClass() throws Exception {
   AaaMeta aaaMeta = new AaaMeta();
   Entity entity = new Entity("Aaa");
   entity.setProperty(aaaMeta.getClassHierarchyListName(), Arrays.asList(Bbb.class.getName()));
   DatastoreUtil.getModelMeta(meta, entity);
 }
Example #2
0
 /** @throws Exception */
 @SuppressWarnings("unchecked")
 @Test
 public void getModelMeta() throws Exception {
   ModelMeta<Hoge> modelMeta = DatastoreUtil.getModelMeta(Hoge.class);
   assertThat(modelMeta, is(notNullValue()));
   assertThat(modelMeta, is(sameInstance((ModelMeta) Datastore.getModelMeta(Hoge.class))));
 }
Example #3
0
 /** @throws Exception */
 @Test
 public void getModelMetaWithEntity() throws Exception {
   AaaMeta aaaMeta = new AaaMeta();
   Entity entity = new Entity("Aaa");
   entity.setProperty(aaaMeta.getClassHierarchyListName(), Arrays.asList(Bbb.class.getName()));
   ModelMeta<Aaa> modelMeta = DatastoreUtil.getModelMeta(aaaMeta, entity);
   assertThat(modelMeta, is(notNullValue()));
   assertThat(modelMeta.getModelClass().getName(), is(Bbb.class.getName()));
 }
Example #4
0
 /** Constructor. */
 @SuppressWarnings({"unchecked", "rawtypes"})
 public DaoBase() {
   for (Class<?> c = getClass(); c != Object.class; c = c.getSuperclass()) {
     Type type = c.getGenericSuperclass();
     if (type instanceof ParameterizedType) {
       modelClass = ((Class) ((ParameterizedType) type).getActualTypeArguments()[0]);
       break;
     }
   }
   if (modelClass == null) {
     throw new IllegalStateException("No model class is found.");
   }
   m = DatastoreUtil.getModelMeta(modelClass);
 }
Example #5
0
 /** @throws Exception */
 @Test
 public void createModelMetaWhenGWT() throws Exception {
   ModelMeta<?> modelMeta = DatastoreUtil.getModelMeta(Ccc.class);
   assertThat(modelMeta, is(notNullValue()));
 }
Example #6
0
 /** @throws Exception */
 @Test(expected = IllegalArgumentException.class)
 public void getModelMetaWhenModelMetaIsNotFound() throws Exception {
   DatastoreUtil.getModelMeta(getClass());
 }