use of org.testng.annotations.DataProvider in project che by eclipse.
the class CheEnvironmentValidatorTest method invalidEnvironmentProvider.
@DataProvider
public static Object[][] invalidEnvironmentProvider() {
// InvalidEnvironmentObject | ExceptionMessage
EnvironmentDto env;
Map.Entry<String, ExtendedMachineDto> machineEntry;
List<List<Object>> data = new ArrayList<>();
data.add(asList(createEnv().withRecipe(null), "Environment recipe should not be null"));
env = createEnv();
env.getRecipe().setType("docker");
data.add(asList(env, "Type 'docker' of environment 'env' is not supported. Supported types: compose"));
env = createEnv();
env.getRecipe().withLocation(null).withContent(null);
data.add(asList(env, "Recipe of environment 'env' must contain location or content"));
env = createEnv();
env.getRecipe().withLocation("location").withContent("content");
data.add(asList(env, "Recipe of environment 'env' contains mutually exclusive fields location and content"));
env = createEnv();
env.setMachines(null);
data.add(asList(env, "Environment 'env' doesn't contain machine with 'org.eclipse.che.ws-agent' agent"));
env = createEnv();
env.setMachines(emptyMap());
data.add(asList(env, "Environment 'env' doesn't contain machine with 'org.eclipse.che.ws-agent' agent"));
env = createEnv();
env.getMachines().put("missingInEnvMachine", newDto(ExtendedMachineDto.class).withAgents(singletonList("org.eclipse.che.ws-agent")));
data.add(asList(env, "Environment 'env' contains machines that are missing in environment recipe: missingInEnvMachine"));
env = createEnv();
env.getMachines().entrySet().forEach(entry -> entry.getValue().getAgents().add("org.eclipse.che.ws-agent"));
data.add(asList(env, "Environment 'env' should contain exactly 1 machine with agent 'org.eclipse.che.ws-agent', but contains '" + env.getMachines().size() + "'. " + "All machines with this agent: " + Joiner.on(", ").join(env.getMachines().keySet())));
env = createEnv();
env.getMachines().entrySet().forEach(entry -> entry.getValue().setAgents(null));
data.add(asList(env, "Environment 'env' should contain exactly 1 machine with agent 'org.eclipse.che.ws-agent', but contains '0'. All machines with this agent: "));
env = createEnv();
env.getMachines().entrySet().forEach(entry -> entry.getValue().getAgents().add(null));
data.add(asList(env, "Machine 'machine2' in environment 'env' contains invalid agent 'null'"));
env = createEnv();
env.getMachines().entrySet().forEach(entry -> entry.getValue().getAgents().add(""));
data.add(asList(env, "Machine 'machine2' in environment 'env' contains invalid agent ''"));
env = createEnv();
machineEntry = env.getMachines().entrySet().iterator().next();
machineEntry.getValue().setAttributes(singletonMap("memoryLimitBytes", "0"));
data.add(asList(env, format("Value of attribute 'memoryLimitBytes' of machine '%s' in environment 'env' is illegal", machineEntry.getKey())));
env = createEnv();
machineEntry = env.getMachines().entrySet().iterator().next();
machineEntry.getValue().setAttributes(singletonMap("memoryLimitBytes", "-1"));
data.add(asList(env, format("Value of attribute 'memoryLimitBytes' of machine '%s' in environment 'env' is illegal", machineEntry.getKey())));
env = createEnv();
machineEntry = env.getMachines().entrySet().iterator().next();
machineEntry.getValue().setAttributes(singletonMap("memoryLimitBytes", ""));
data.add(asList(env, format("Value of attribute 'memoryLimitBytes' of machine '%s' in environment 'env' is illegal", machineEntry.getKey())));
return data.stream().map(list -> list.toArray(new Object[list.size()])).toArray(value -> new Object[data.size()][]);
}
use of org.testng.annotations.DataProvider in project che by eclipse.
the class GitConnectionFactoryProvider method createConnection.
@DataProvider(name = "GitConnectionFactory")
public static Object[][] createConnection() throws ServerException, NotFoundException {
GitUserResolver resolver = mock(GitUserResolver.class);
when(resolver.getUser()).thenReturn(GitTestUtil.getTestGitUser());
return new Object[][] { new Object[] { new JGitConnectionFactory(mock(CredentialsLoader.class), mock(SshKeyProvider.class), resolver) } };
}
use of org.testng.annotations.DataProvider in project che by eclipse.
the class FactoryBuilderTest method notValidParamsProvider.
@DataProvider(name = "notValidParamsProvider")
public static Object[][] notValidParamsProvider() throws URISyntaxException, IOException, NoSuchMethodException {
FactoryDto factory = prepareFactory();
EnvironmentDto environmentDto = factory.getWorkspace().getEnvironments().values().iterator().next();
environmentDto.getRecipe().withType(null);
return new Object[][] { { requireNonNull(dto.clone(factory)).withWorkspace(factory.getWorkspace().withDefaultEnv(null)) }, { requireNonNull(dto.clone(factory)).withWorkspace(factory.getWorkspace().withEnvironments(singletonMap("test", environmentDto))) } };
}
use of org.testng.annotations.DataProvider in project che by eclipse.
the class FactoryBaseValidatorTest method invalidParametersFactoryUrlProvider.
@DataProvider(name = "badAdvancedFactoryUrlProvider")
public Object[][] invalidParametersFactoryUrlProvider() throws UnsupportedEncodingException {
FactoryDto adv1 = prepareFactoryWithGivenStorage("notagit", VALID_REPOSITORY_URL, VALID_PROJECT_PATH);
FactoryDto adv2 = prepareFactoryWithGivenStorage("git", null, VALID_PROJECT_PATH);
FactoryDto adv3 = prepareFactoryWithGivenStorage("git", "", VALID_PROJECT_PATH);
return new Object[][] { // invalid vcs
{ adv1 }, // invalid vcsurl
{ adv2 }, // invalid vcsurl
{ adv3 } };
}
use of org.testng.annotations.DataProvider in project che by eclipse.
the class WorkspaceConfigJsonAdapterTest method invalidConfigs.
@DataProvider
public static Object[][] invalidConfigs() throws Exception {
final URL dir = Thread.currentThread().getContextClassLoader().getResource(INVALID_CONFIGS_DIR_NAME);
assertNotNull(dir);
final File[] files = new File(dir.toURI()).listFiles();
assertNotNull(files);
final Object[][] result = new Object[files.length][1];
for (int i = 0; i < files.length; i++) {
result[i][0] = files[i].getName();
}
return result;
}
Aggregations