@Test public void should_create_entity_dao() throws Exception { PropertyMeta idMeta = PropertyMetaTestBuilder // .completeBean(Void.class, Long.class) .field("id") .build(); EntityMeta entityMeta = new EntityMeta(); entityMeta.setClusteredEntity(false); entityMeta.setTableName("cf"); entityMeta.setIdMeta(idMeta); entityMeta.setIdClass(Long.class); entityMeta.setPropertyMetas(new HashMap<String, PropertyMeta>()); factory.createDaosForEntity( cluster, keyspace, configContext, entityMeta, entityDaosMap, wideRowDaosMap); ThriftGenericEntityDao entityDao = entityDaosMap.get("cf"); assertThat(entityDao).isNotNull(); assertThat(entityDao.getColumnFamily()).isEqualTo("cf"); assertThat(Whitebox.getInternalState(entityDao, "policy")).isSameAs(consistencyPolicy); assertThat(Whitebox.getInternalState(entityDao, "cluster")).isSameAs(cluster); assertThat(Whitebox.getInternalState(entityDao, "keyspace")).isSameAs(keyspace); assertThat(Whitebox.getInternalState(entityDao, "columnNameSerializer")) .isSameAs(COMPOSITE_SRZ); Pair<Class<Long>, Class<String>> rowAndValueClases = Whitebox.getInternalState(entityDao, "rowkeyAndValueClasses"); assertThat(rowAndValueClases.left).isSameAs(Long.class); assertThat(rowAndValueClases.right).isSameAs(String.class); }
@Test public void should_build_entity_dao() throws Exception { PropertyMeta idMeta = PropertyMetaTestBuilder // .completeBean(Void.class, Long.class) .field("id") .build(); EntityMeta entityMeta = new EntityMeta(); entityMeta.setClusteredEntity(false); entityMeta.setTableName("cf"); entityMeta.setIdMeta(idMeta); entityMeta.setIdClass(Long.class); entityMeta.setPropertyMetas(new HashMap<String, PropertyMeta>()); entityMetaMap.put(CompleteBean.class, entityMeta); builder.buildDao(cluster, keyspace, entityMetaMap, configContext, false); verify(daoFactory) .createDaosForEntity( eq(cluster), eq(keyspace), eq(configContext), eq(entityMeta), any(Map.class), any(Map.class)); }