Search in sources :

Example 1 with ValidationSupport

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;
}
Also used : ValidatingReference(io.fabric8.api.scr.ValidatingReference) ValidationSupport(io.fabric8.api.scr.ValidationSupport) PullPushPolicy(io.fabric8.git.PullPushPolicy) PushResult(org.eclipse.jgit.transport.PushResult) CredentialsProvider(org.eclipse.jgit.transport.CredentialsProvider) CuratorFramework(org.apache.curator.framework.CuratorFramework) GitContext(io.fabric8.api.GitContext) DataStore(io.fabric8.api.DataStore) GitService(io.fabric8.git.GitService) File(java.io.File) RuntimeProperties(io.fabric8.api.RuntimeProperties) Before(org.junit.Before)

Aggregations

DataStore (io.fabric8.api.DataStore)1 GitContext (io.fabric8.api.GitContext)1 RuntimeProperties (io.fabric8.api.RuntimeProperties)1 ValidatingReference (io.fabric8.api.scr.ValidatingReference)1 ValidationSupport (io.fabric8.api.scr.ValidationSupport)1 GitService (io.fabric8.git.GitService)1 PullPushPolicy (io.fabric8.git.PullPushPolicy)1 File (java.io.File)1 CuratorFramework (org.apache.curator.framework.CuratorFramework)1 CredentialsProvider (org.eclipse.jgit.transport.CredentialsProvider)1 PushResult (org.eclipse.jgit.transport.PushResult)1 Before (org.junit.Before)1