use of io.fabric8.api.scr.ValidationSupport in project fabric8 by jboss-fuse.
the class GitDataStoreImplProfilesIT method init.
@Before
public void init() throws NoSuchFieldException, IllegalAccessException, IOException, GitAPIException {
File repo = new File("target/fabric-git");
FileUtils.deleteDirectory(repo);
repo.mkdirs();
git = Git.init().setDirectory(repo).setGitDir(new File(repo, ".git")).call();
git.commit().setMessage("init").call();
git.tag().setName(GitHelpers.ROOT_TAG).call();
dataStore = mock(DataStore.class);
when(dataStore.getDefaultVersion()).thenReturn("1.0");
gitService = mock(GitService.class);
when(gitService.getGit()).thenReturn(git);
runtimeProperties = mock(RuntimeProperties.class);
when(runtimeProperties.getRuntimeIdentity()).thenReturn("root");
curator = mock(CuratorFramework.class);
pullPushPolicy = mock(PullPushPolicy.class);
PullPushPolicy.PushPolicyResult ppResult = mock(PullPushPolicy.PushPolicyResult.class);
when(ppResult.getPushResults()).thenReturn(new ArrayList<PushResult>());
when(pullPushPolicy.doPush(any(GitContext.class), any(CredentialsProvider.class))).thenReturn(ppResult);
mockStatic(ZooKeeperUtils.class);
PowerMockito.when(ZooKeeperUtils.generateContainerToken(runtimeProperties, curator)).thenReturn("token");
gdsi = new GitDataStoreImpl();
this.<ValidationSupport>getField(gdsi, "active", ValidationSupport.class).setValid();
this.<ValidatingReference<DataStore>>getField(gdsi, "dataStore", ValidatingReference.class).bind(dataStore);
this.<ValidatingReference<GitService>>getField(gdsi, "gitService", ValidatingReference.class).bind(gitService);
this.<ValidatingReference<RuntimeProperties>>getField(gdsi, "runtimeProperties", ValidatingReference.class).bind(runtimeProperties);
this.<ValidatingReference<CuratorFramework>>getField(gdsi, "curator", ValidatingReference.class).bind(curator);
setField(gdsi, "dataStoreProperties", Map.class, new HashMap<String, Object>());
setField(gdsi, "pullPushPolicy", PullPushPolicy.class, pullPushPolicy);
profileRegistry = gdsi;
}
Aggregations