/** @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); }
/** @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)))); }
/** @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())); }
/** 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); }
/** @throws Exception */ @Test public void createModelMetaWhenGWT() throws Exception { ModelMeta<?> modelMeta = DatastoreUtil.getModelMeta(Ccc.class); assertThat(modelMeta, is(notNullValue())); }
/** @throws Exception */ @Test(expected = IllegalArgumentException.class) public void getModelMetaWhenModelMetaIsNotFound() throws Exception { DatastoreUtil.getModelMeta(getClass()); }