Search in sources :

Example 26 with FactoryDto

use of org.eclipse.che.api.factory.shared.dto.FactoryDto in project che by eclipse.

the class FactoryBaseValidatorTest method shouldNotValidateIfOpenWelcomePageActionInsufficientParams.

@Test(expectedExceptions = BadRequestException.class)
public void shouldNotValidateIfOpenWelcomePageActionInsufficientParams() throws Exception {
    //given
    validator = new TesterFactoryBaseValidator();
    List<IdeActionDto> actions = singletonList(newDto(IdeActionDto.class).withId("openWelcomePage"));
    IdeDto ide = newDto(IdeDto.class).withOnAppLoaded((newDto(OnAppLoadedDto.class).withActions(actions)));
    FactoryDto factoryWithAccountId = requireNonNull(getInstance().clone(factory)).withIde(ide);
    //when
    validator.validateProjectActions(factoryWithAccountId);
}
Also used : OnAppLoadedDto(org.eclipse.che.api.factory.shared.dto.OnAppLoadedDto) IdeActionDto(org.eclipse.che.api.factory.shared.dto.IdeActionDto) IdeDto(org.eclipse.che.api.factory.shared.dto.IdeDto) FactoryDto(org.eclipse.che.api.factory.shared.dto.FactoryDto) Test(org.testng.annotations.Test)

Example 27 with FactoryDto

use of org.eclipse.che.api.factory.shared.dto.FactoryDto in project che by eclipse.

the class FactoryBaseValidatorTest method shouldValidateFindReplaceAction.

@Test
public void shouldValidateFindReplaceAction() throws Exception {
    //given
    validator = new TesterFactoryBaseValidator();
    Map<String, String> params = new HashMap<>();
    params.put("in", "pom.xml");
    params.put("find", "123");
    params.put("replace", "456");
    List<IdeActionDto> actions = singletonList(newDto(IdeActionDto.class).withId("findReplace").withProperties(params));
    IdeDto ide = newDto(IdeDto.class).withOnProjectsLoaded(newDto(OnProjectsLoadedDto.class).withActions(actions));
    FactoryDto factoryWithAccountId = requireNonNull(getInstance().clone(factory)).withIde(ide);
    //when
    validator.validateProjectActions(factoryWithAccountId);
}
Also used : IdeActionDto(org.eclipse.che.api.factory.shared.dto.IdeActionDto) IdeDto(org.eclipse.che.api.factory.shared.dto.IdeDto) HashMap(java.util.HashMap) FactoryDto(org.eclipse.che.api.factory.shared.dto.FactoryDto) Test(org.testng.annotations.Test)

Example 28 with FactoryDto

use of org.eclipse.che.api.factory.shared.dto.FactoryDto in project che by eclipse.

the class FactoryBaseValidatorTest method shouldNotValidateIfFindReplaceActionInsufficientParams.

@Test(expectedExceptions = BadRequestException.class)
public void shouldNotValidateIfFindReplaceActionInsufficientParams() throws Exception {
    //given
    validator = new TesterFactoryBaseValidator();
    Map<String, String> params = new HashMap<>();
    params.put("in", "pom.xml");
    // find is missing!
    params.put("replace", "123");
    List<IdeActionDto> actions = singletonList(newDto(IdeActionDto.class).withId("findReplace").withProperties(params));
    IdeDto ide = newDto(IdeDto.class).withOnProjectsLoaded(newDto(OnProjectsLoadedDto.class).withActions(actions));
    FactoryDto factoryWithAccountId = requireNonNull(getInstance().clone(factory)).withIde(ide);
    //when
    validator.validateProjectActions(factoryWithAccountId);
}
Also used : IdeActionDto(org.eclipse.che.api.factory.shared.dto.IdeActionDto) IdeDto(org.eclipse.che.api.factory.shared.dto.IdeDto) HashMap(java.util.HashMap) FactoryDto(org.eclipse.che.api.factory.shared.dto.FactoryDto) Test(org.testng.annotations.Test)

Example 29 with FactoryDto

use of org.eclipse.che.api.factory.shared.dto.FactoryDto in project che by eclipse.

the class FactoryBaseValidatorTest method shouldNotValidateIfOpenfileActionInsufficientParams.

@Test(expectedExceptions = BadRequestException.class)
public void shouldNotValidateIfOpenfileActionInsufficientParams() throws Exception {
    //given
    validator = new TesterFactoryBaseValidator();
    List<IdeActionDto> actions = singletonList(newDto(IdeActionDto.class).withId("openFile"));
    IdeDto ide = newDto(IdeDto.class).withOnProjectsLoaded(newDto(OnProjectsLoadedDto.class).withActions(actions));
    FactoryDto factoryWithAccountId = requireNonNull(getInstance().clone(factory)).withIde(ide);
    //when
    validator.validateProjectActions(factoryWithAccountId);
}
Also used : IdeActionDto(org.eclipse.che.api.factory.shared.dto.IdeActionDto) IdeDto(org.eclipse.che.api.factory.shared.dto.IdeDto) FactoryDto(org.eclipse.che.api.factory.shared.dto.FactoryDto) Test(org.testng.annotations.Test)

Example 30 with FactoryDto

use of org.eclipse.che.api.factory.shared.dto.FactoryDto in project che by eclipse.

the class MavenModelImporter method onFactoryAccepted.

@Override
public void onFactoryAccepted(FactoryAcceptedEvent event) {
    final FactoryDto factory = event.getFactory();
    final List<ProjectConfigDto> projects = factory.getWorkspace().getProjects();
    final List<String> paths = new ArrayList<>();
    for (ProjectConfigDto project : projects) {
        if (MavenAttributes.MAVEN_ID.equals(project.getType())) {
            paths.add(project.getPath());
        }
    }
    if (!paths.isEmpty()) {
        reimport(paths);
    }
}
Also used : FactoryDto(org.eclipse.che.api.factory.shared.dto.FactoryDto) ProjectConfigDto(org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto) ArrayList(java.util.ArrayList)

Aggregations

FactoryDto (org.eclipse.che.api.factory.shared.dto.FactoryDto)30 Test (org.testng.annotations.Test)21 Response (com.jayway.restassured.response.Response)11 DtoFactory (org.eclipse.che.dto.server.DtoFactory)11 Factory (org.eclipse.che.api.core.model.factory.Factory)10 IdeActionDto (org.eclipse.che.api.factory.shared.dto.IdeActionDto)8 IdeDto (org.eclipse.che.api.factory.shared.dto.IdeDto)8 InputStream (java.io.InputStream)6 HashMap (java.util.HashMap)5 BadRequestException (org.eclipse.che.api.core.BadRequestException)4 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)4 JsonSyntaxException (com.google.gson.JsonSyntaxException)3 ApiOperation (io.swagger.annotations.ApiOperation)3 ApiResponses (io.swagger.annotations.ApiResponses)3 IOException (java.io.IOException)3 HashSet (java.util.HashSet)3 Produces (javax.ws.rs.Produces)3 Matchers.anyString (org.mockito.Matchers.anyString)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 List (java.util.List)2