Fix Exec store breakage following change to new config format

This commit is contained in:
Max Dor
2019-02-13 21:08:56 +01:00
parent e39d6bfa10
commit e133e120d7
10 changed files with 78 additions and 152 deletions

View File

@@ -56,32 +56,32 @@ public class ExecDirectoryStoreTest extends ExecStoreTest {
}));
}
private ExecConfig.Directory getCfg() {
ExecConfig.Directory cfg = new ExecConfig().build().getDirectory();
private ExecConfig getCfg() {
ExecConfig cfg = new ExecConfig().build();
assertFalse(cfg.isEnabled());
cfg.setEnabled(true);
assertTrue(cfg.isEnabled());
cfg.getSearch().getByName().getOutput().setType(ExecStore.JsonType);
cfg.getDirectory().getSearch().getByName().getOutput().setType(ExecStore.JsonType);
return cfg;
}
private ExecDirectoryStore getStore(ExecConfig.Directory cfg) {
private ExecDirectoryStore getStore(ExecConfig cfg) {
ExecDirectoryStore store = new ExecDirectoryStore(cfg, getMatrixCfg());
store.setExecutorSupplier(this::build);
return store;
}
private ExecDirectoryStore getStore(String command) {
ExecConfig.Directory cfg = getCfg();
cfg.getSearch().getByName().setCommand(command);
cfg.getSearch().getByThreepid().setCommand(command);
ExecConfig cfg = getCfg();
cfg.getDirectory().getSearch().getByName().setCommand(command);
cfg.getDirectory().getSearch().getByThreepid().setCommand(command);
return getStore(cfg);
}
@Test
public void byNameNoCommandDefined() {
ExecConfig.Directory cfg = getCfg();
assertTrue(StringUtils.isEmpty(cfg.getSearch().getByName().getCommand()));
ExecConfig cfg = getCfg();
assertTrue(StringUtils.isEmpty(cfg.getDirectory().getSearch().getByName().getCommand()));
ExecDirectoryStore store = getStore(cfg);
UserDirectorySearchResult result = store.searchByDisplayName("user");

View File

@@ -62,17 +62,17 @@ public class ExecIdentityStoreTest extends ExecStoreTest {
}));
}
private ExecConfig.Identity getCfg() {
ExecConfig.Identity cfg = new ExecConfig().build().getIdentity();
private ExecConfig getCfg() {
ExecConfig cfg = new ExecConfig().build();
assertFalse(cfg.isEnabled());
cfg.setEnabled(true);
assertTrue(cfg.isEnabled());
cfg.getLookup().getSingle().getOutput().setType(ExecStore.JsonType);
cfg.getLookup().getBulk().getOutput().setType(ExecStore.JsonType);
cfg.getIdentity().getLookup().getSingle().getOutput().setType(ExecStore.JsonType);
cfg.getIdentity().getLookup().getBulk().getOutput().setType(ExecStore.JsonType);
return cfg;
}
private ExecIdentityStore getStore(ExecConfig.Identity cfg) {
private ExecIdentityStore getStore(ExecConfig cfg) {
ExecIdentityStore store = new ExecIdentityStore(cfg, getMatrixCfg());
store.setExecutorSupplier(this::build);
assertTrue(store.isLocal());
@@ -80,9 +80,9 @@ public class ExecIdentityStoreTest extends ExecStoreTest {
}
private ExecIdentityStore getStore(String command) {
ExecConfig.Identity cfg = getCfg();
cfg.getLookup().getSingle().setCommand(command);
cfg.getLookup().getBulk().setCommand(command);
ExecConfig cfg = getCfg();
cfg.getIdentity().getLookup().getSingle().setCommand(command);
cfg.getIdentity().getLookup().getBulk().setCommand(command);
return getStore(cfg);
}

View File

@@ -70,28 +70,28 @@ public class ExecProfileStoreTest extends ExecStoreTest {
}
private ExecConfig.Profile getCfg() {
ExecConfig.Profile cfg = new ExecConfig().build().getProfile();
private ExecConfig getCfg() {
ExecConfig cfg = new ExecConfig().build();
assertFalse(cfg.isEnabled());
cfg.setEnabled(true);
assertTrue(cfg.isEnabled());
cfg.getDisplayName().getOutput().setType(ExecStore.JsonType);
cfg.getThreePid().getOutput().setType(ExecStore.JsonType);
cfg.getRole().getOutput().setType(ExecStore.JsonType);
cfg.getProfile().getDisplayName().getOutput().setType(ExecStore.JsonType);
cfg.getProfile().getThreePid().getOutput().setType(ExecStore.JsonType);
cfg.getProfile().getRole().getOutput().setType(ExecStore.JsonType);
return cfg;
}
private ExecProfileStore getStore(ExecConfig.Profile cfg) {
private ExecProfileStore getStore(ExecConfig cfg) {
ExecProfileStore store = new ExecProfileStore(cfg);
store.setExecutorSupplier(this::build);
return store;
}
private ExecProfileStore getStore(String command) {
ExecConfig.Profile cfg = getCfg();
cfg.getDisplayName().setCommand(command);
cfg.getThreePid().setCommand(command);
cfg.getRole().setCommand(command);
ExecConfig cfg = getCfg();
cfg.getProfile().getDisplayName().setCommand(command);
cfg.getProfile().getThreePid().setCommand(command);
cfg.getProfile().getRole().setCommand(command);
return getStore(cfg);
}