public void update_cache_inconsistent_model() throws Exception {
ImportBean bean = createBean();
Map<String, ImportTargetTableBean> targetTable = new HashMap<String, ImportTargetTableBean>();
final ImportTargetTableBean tb1 = new ImportTargetTableBean();
tb1.setCacheId("tb1");
tb1.setDfsFilePath("tb1");
tb1.setImportTargetType(ImportTarget1.class);
tb1.setImportTargetColumns(Arrays.asList("A"));
tb1.setSearchCondition("");
targetTable.put("__TG_TEST1", tb1);
Connection conn = DBConnection.getConnection();
try {
LocalCacheInfoRepository repo = new LocalCacheInfoRepository(conn);
repo.putCacheInfo(new LocalCacheInfo(
tb1.getCacheId(),
null,
null,
"__TG_TEST1",
tb1.getDfsFilePath()));
} finally {
DBConnection.closeConn(conn);
}
bean.setTargetTable(targetTable);
ImportProtocolDecide service = new ImportProtocolDecide() {
@Override
protected Map<String, CacheInfo> collectRemoteCacheInfo(ImportBean _)
throws BulkLoaderSystemException {
return Collections.singletonMap("tb1", new CacheInfo(
CacheInfo.FEATURE_VERSION,
tb1.getCacheId(),
offset(-1),
"__TG_TEST1",
tb1.getImportTargetColumns(),
tb1.getImportTargetType().getName(),
new ImportTarget1().__tgc__DataModelVersion() + 1));
}
};
service.execute(bean);
assertThat(tb1.getImportProtocol().getKind(), is(FileProtocol.Kind.CREATE_CACHE));
}