use of org.testng.annotations.BeforeMethod in project che by eclipse.
the class SnapshotDaoTest method createSnapshots.
@BeforeMethod
private void createSnapshots() throws TckRepositoryException {
// one account for all the workspaces
final AccountImpl account = new AccountImpl("account1", "name", "type");
// workspaces
workspaces = new TestWorkspace[SNAPSHOTS_SIZE / 3];
for (int i = 0; i < workspaces.length; i++) {
workspaces[i] = new TestWorkspace("workspace-" + i, account.getId());
}
// snapshots
snapshots = new SnapshotImpl[SNAPSHOTS_SIZE];
for (int i = 0; i < SNAPSHOTS_SIZE; i++) {
snapshots[i] = createSnapshot("snapshot-" + i, // 3 snapshot share the same workspace id
workspaces[i / 3].getId(), // 2 snapshots share the same env name
"environment-" + i / 2, "machine-" + i);
}
accountRepo.createAll(singletonList(account));
workspaceRepo.createAll(asList(workspaces));
snaphotRepo.createAll(asList(snapshots));
}
use of org.testng.annotations.BeforeMethod in project che by eclipse.
the class RecipeServiceTest method setUpUriInfo.
@BeforeMethod
public void setUpUriInfo() throws NoSuchFieldException, IllegalAccessException {
when(uriInfo.getBaseUriBuilder()).thenReturn(new UriBuilderImpl());
final Field uriField = service.getClass().getSuperclass().getDeclaredField("uriInfo");
uriField.setAccessible(true);
uriField.set(service, uriInfo);
}
use of org.testng.annotations.BeforeMethod in project che by eclipse.
the class CheEnvironmentEngineTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
engine = spy(new CheEnvironmentEngine(snapshotDao, machineInstanceProviders, System.getProperty("java.io.tmpdir"), DEFAULT_MACHINE_MEM_LIMIT_MB, eventService, environmentParser, new DefaultServicesStartStrategy(), machineProvider, infrastructureProvisioner, API_ENDPOINT, recipeDownloader, containerNameGenerator, agentRegistry, sharedPool));
when(machineInstanceProviders.getProvider("docker")).thenReturn(instanceProvider);
when(instanceProvider.getRecipeTypes()).thenReturn(Collections.singleton("dockerfile"));
when(agentRegistry.getAgent(any(AgentKey.class))).thenReturn(agent);
EnvironmentContext.getCurrent().setSubject(new SubjectImpl("name", "id", "token", false));
}
use of org.testng.annotations.BeforeMethod in project che by eclipse.
the class SshDaoTest method setUp.
@BeforeMethod
public void setUp() throws TckRepositoryException {
UserImpl[] users = new UserImpl[COUNT_OF_USERS];
for (int i = 0; i < COUNT_OF_USERS; i++) {
users[i] = new UserImpl("owner" + i, "owner" + i + "@eclipse.org", "owner" + i, "password", emptyList());
}
pairs = new SshPairImpl[COUNT_OF_PAIRS];
for (int i = 0; i < COUNT_OF_PAIRS; i++) {
pairs[i] = new // 3 each pairs share the same owner
SshPairImpl(// 3 each pairs share the same owner
"owner" + i / 3, // each 2 pairs share the same service
"service" + i / 2, "name" + i, NameGenerator.generate("publicKey-", 20), NameGenerator.generate("privateKey-", 20));
}
userRepository.createAll(Arrays.asList(users));
sshRepository.createAll(Arrays.asList(pairs));
}
use of org.testng.annotations.BeforeMethod in project che by eclipse.
the class DownloadFileResponseFilterTest method before.
/**
* Setup env for launching requests
* @throws Exception
*/
@BeforeMethod
public void before() throws Exception {
//set up launcher
final ResourceBinderImpl resources = new ResourceBinderImpl();
resources.addResource(MyJaxRSService.class, null);
final DependencySupplierImpl dependencies = new DependencySupplierImpl();
final ApplicationProviderBinder providers = new ApplicationProviderBinder();
providers.addExceptionMapper(ApiExceptionMapper.class);
providers.addResponseFilter(EverrestDownloadFileResponseFilter.class);
final URI uri = new URI(BASE_URI);
final ContainerRequest req = new ContainerRequest(null, uri, uri, null, null, null);
final ApplicationContext context = anApplicationContext().withRequest(req).withProviders(providers).withDependencySupplier(dependencies).build();
ApplicationContext.setCurrent(context);
final EverrestProcessor processor = new EverrestProcessor(new EverrestConfiguration(), dependencies, new RequestHandlerImpl(new RequestDispatcher(resources), providers), null);
resourceLauncher = new ResourceLauncher(processor);
}
Aggregations