Search in sources :

Example 6 with DataProvider

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) } };
}
Also used : JGitConnectionFactory(org.eclipse.che.git.impl.jgit.JGitConnectionFactory) CredentialsLoader(org.eclipse.che.api.git.CredentialsLoader) SshKeyProvider(org.eclipse.che.plugin.ssh.key.script.SshKeyProvider) GitUserResolver(org.eclipse.che.api.git.GitUserResolver) DataProvider(org.testng.annotations.DataProvider)

Example 7 with DataProvider

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))) } };
}
Also used : EnvironmentDto(org.eclipse.che.api.workspace.shared.dto.EnvironmentDto) FactoryDto(org.eclipse.che.api.factory.shared.dto.FactoryDto) DataProvider(org.testng.annotations.DataProvider)

Example 8 with DataProvider

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 } };
}
Also used : FactoryDto(org.eclipse.che.api.factory.shared.dto.FactoryDto) DataProvider(org.testng.annotations.DataProvider)

Example 9 with DataProvider

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;
}
Also used : JsonObject(com.google.gson.JsonObject) File(java.io.File) URL(java.net.URL) DataProvider(org.testng.annotations.DataProvider)

Example 10 with DataProvider

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()][]);
}
Also used : Listeners(org.testng.annotations.Listeners) MachineInstanceProviders(org.eclipse.che.api.machine.server.MachineInstanceProviders) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) DataProvider(org.testng.annotations.DataProvider) Mock(org.mockito.Mock) DtoConverter(org.eclipse.che.api.workspace.server.DtoConverter) Assert.assertEquals(org.testng.Assert.assertEquals) Test(org.testng.annotations.Test) HashMap(java.util.HashMap) ExtendedMachineImpl(org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl) ServerConfDto(org.eclipse.che.api.machine.shared.dto.ServerConfDto) Mockito.spy(org.mockito.Mockito.spy) ServerConf2Impl(org.eclipse.che.api.workspace.server.model.impl.ServerConf2Impl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) EnvironmentDto(org.eclipse.che.api.workspace.shared.dto.EnvironmentDto) MachineConfigDto(org.eclipse.che.api.machine.shared.dto.MachineConfigDto) Collections.singleton(java.util.Collections.singleton) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) CheServiceBuildContextImpl(org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl) Collections.singletonMap(java.util.Collections.singletonMap) InjectMocks(org.mockito.InjectMocks) Collections.emptyMap(java.util.Collections.emptyMap) EnvironmentRecipeImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl) MockitoTestNGListener(org.mockito.testng.MockitoTestNGListener) MachineSourceDto(org.eclipse.che.api.machine.shared.dto.MachineSourceDto) Collections.emptyList(java.util.Collections.emptyList) Assert.fail(org.testng.Assert.fail) BeforeMethod(org.testng.annotations.BeforeMethod) DtoFactory.newDto(org.eclipse.che.dto.server.DtoFactory.newDto) ExtendedMachineDto(org.eclipse.che.api.workspace.shared.dto.ExtendedMachineDto) Mockito.when(org.mockito.Mockito.when) String.format(java.lang.String.format) Matchers.any(org.mockito.Matchers.any) List(java.util.List) Environment(org.eclipse.che.api.core.model.workspace.Environment) ServerException(org.eclipse.che.api.core.ServerException) CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) Joiner(com.google.common.base.Joiner) EnvironmentDto(org.eclipse.che.api.workspace.shared.dto.EnvironmentDto) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) Arrays.asList(java.util.Arrays.asList) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) Collections.singletonMap(java.util.Collections.singletonMap) Collections.emptyMap(java.util.Collections.emptyMap) ExtendedMachineDto(org.eclipse.che.api.workspace.shared.dto.ExtendedMachineDto) DataProvider(org.testng.annotations.DataProvider)

Aggregations

DataProvider (org.testng.annotations.DataProvider)387 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)99 ArrayList (java.util.ArrayList)92 Test (org.testng.annotations.Test)85 File (java.io.File)74 List (java.util.List)72 Assert (org.testng.Assert)67 URIDetails (com.linkedin.restli.internal.testutils.URIDetails)65 Collectors (java.util.stream.Collectors)61 HashMap (java.util.HashMap)57 IntStream (java.util.stream.IntStream)54 Random (java.util.Random)50 RealMatrix (org.apache.commons.math3.linear.RealMatrix)44 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)41 IOException (java.io.IOException)39 ByteString (com.linkedin.data.ByteString)37 Array2DRowRealMatrix (org.apache.commons.math3.linear.Array2DRowRealMatrix)34 Stream (java.util.stream.Stream)31 DoubleStream (java.util.stream.DoubleStream)29 HashSet (java.util.HashSet)28