Search in sources :

Example 1 with ADMIN_USER_NAME

use of org.everrest.assured.JettyHttpServer.ADMIN_USER_NAME in project che by eclipse.

the class FactoryServiceTest method shouldReturnFactoryListByCreatorAttribute.

@Test
public void shouldReturnFactoryListByCreatorAttribute() throws Exception {
    final Factory factory1 = createNamedFactory("factory1");
    final Factory factory2 = createNamedFactory("factory2");
    when(factoryManager.getByAttribute(2, 0, ImmutableList.of(Pair.of("factory.creator.name", user.getName())))).thenReturn(ImmutableList.of(factory1, factory2));
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType(APPLICATION_JSON).when().expect().statusCode(200).get(SERVICE_PATH + "/find?maxItems=2&skipCount=0&factory.creator.name=" + user.getName());
    final Set<FactoryDto> res = unwrapDtoList(response, FactoryDto.class).stream().map(f -> f.withLinks(emptyList())).collect(toSet());
    assertEquals(res.size(), 2);
    assertTrue(res.containsAll(ImmutableList.of(asDto(factory1, user), asDto(factory2, user))));
}
Also used : Response(com.jayway.restassured.response.Response) WorkspaceConfig(org.eclipse.che.api.core.model.workspace.WorkspaceConfig) SourceStorageImpl(org.eclipse.che.api.workspace.server.model.impl.SourceStorageImpl) Arrays(java.util.Arrays) Listeners(org.testng.annotations.Listeners) Matchers.anySetOf(org.mockito.Matchers.anySetOf) WorkspaceConfigImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl) Test(org.testng.annotations.Test) RestAssured.given(com.jayway.restassured.RestAssured.given) Thread.currentThread(java.lang.Thread.currentThread) ServerConf2Impl(org.eclipse.che.api.workspace.server.model.impl.ServerConf2Impl) FactoryDto(org.eclipse.che.api.factory.shared.dto.FactoryDto) Collections.singletonList(java.util.Collections.singletonList) Mockito.doThrow(org.mockito.Mockito.doThrow) PreferenceManager(org.eclipse.che.api.user.server.PreferenceManager) FluentIterable(com.google.common.collect.FluentIterable) Map(java.util.Map) Path(java.nio.file.Path) Mockito.doReturn(org.mockito.Mockito.doReturn) GenericContainerRequest(org.everrest.core.GenericContainerRequest) BAD_REQUEST(javax.ws.rs.core.Response.Status.BAD_REQUEST) WorkspaceManager(org.eclipse.che.api.workspace.server.WorkspaceManager) AuthorImpl(org.eclipse.che.api.factory.server.model.impl.AuthorImpl) Set(java.util.Set) SourceStorageDto(org.eclipse.che.api.workspace.shared.dto.SourceStorageDto) Mockito.doNothing(org.mockito.Mockito.doNothing) Pair(org.eclipse.che.commons.lang.Pair) Matchers.any(org.mockito.Matchers.any) ApiExceptionMapper(org.eclipse.che.api.core.rest.ApiExceptionMapper) BadRequestException(org.eclipse.che.api.core.BadRequestException) UriInfo(javax.ws.rs.core.UriInfo) SubjectImpl(org.eclipse.che.commons.subject.SubjectImpl) ADMIN_USER_NAME(org.everrest.assured.JettyHttpServer.ADMIN_USER_NAME) WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) TEXT_PLAIN(javax.ws.rs.core.MediaType.TEXT_PLAIN) Mock(org.mockito.Mock) ExtendedMachineImpl(org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl) Mockito.spy(org.mockito.Mockito.spy) Matchers.anyString(org.mockito.Matchers.anyString) EnvironmentDto(org.eclipse.che.api.workspace.shared.dto.EnvironmentDto) FactoryParametersResolverHolder(org.eclipse.che.api.factory.server.FactoryService.FactoryParametersResolverHolder) VALIDATE_QUERY_PARAMETER(org.eclipse.che.api.factory.server.FactoryService.VALIDATE_QUERY_PARAMETER) FactoryImpl(org.eclipse.che.api.factory.server.model.impl.FactoryImpl) User(org.eclipse.che.api.core.model.user.User) JsonHelper(org.eclipse.che.commons.json.JsonHelper) DtoConverter.asDto(org.eclipse.che.api.factory.server.DtoConverter.asDto) EverrestJetty(org.everrest.assured.EverrestJetty) EnvironmentRecipeImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl) Files(java.nio.file.Files) IOException(java.io.IOException) Mockito.times(org.mockito.Mockito.times) File(java.io.File) String.valueOf(java.lang.String.valueOf) Paths(java.nio.file.Paths) ProjectConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl) ContentType(com.jayway.restassured.http.ContentType) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) URL(java.net.URL) FactoryBuilder(org.eclipse.che.api.factory.server.builder.FactoryBuilder) Matchers.anyBoolean(org.mockito.Matchers.anyBoolean) Matchers.eq(org.mockito.Matchers.eq) URI(java.net.URI) APPLICATION_JSON(javax.ws.rs.core.MediaType.APPLICATION_JSON) Collectors.toSet(java.util.stream.Collectors.toSet) ImmutableSet(com.google.common.collect.ImmutableSet) MockitoTestNGListener(org.mockito.testng.MockitoTestNGListener) ImmutableMap(com.google.common.collect.ImmutableMap) Collections.emptyList(java.util.Collections.emptyList) BeforeMethod(org.testng.annotations.BeforeMethod) Assert.assertNotNull(org.testng.Assert.assertNotNull) String.format(java.lang.String.format) List(java.util.List) Matchers.equalTo(org.hamcrest.Matchers.equalTo) ProjectConfig(org.eclipse.che.api.core.model.project.ProjectConfig) ServiceError(org.eclipse.che.api.core.rest.shared.dto.ServiceError) CommandDto(org.eclipse.che.api.machine.shared.dto.CommandDto) Assert.assertEquals(org.testng.Assert.assertEquals) SourceStorageParametersValidator(org.eclipse.che.api.factory.server.impl.SourceStorageParametersValidator) HashMap(java.util.HashMap) Response(com.jayway.restassured.response.Response) HashSet(java.util.HashSet) EnvironmentContext(org.eclipse.che.commons.env.EnvironmentContext) ImmutableList(com.google.common.collect.ImmutableList) Matchers.anyMapOf(org.mockito.Matchers.anyMapOf) Collections.singletonMap(java.util.Collections.singletonMap) DtoFactory(org.eclipse.che.dto.server.DtoFactory) Collections.emptySet(java.util.Collections.emptySet) JsonSyntaxException(com.google.gson.JsonSyntaxException) ProjectConfigDto(org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto) WorkspaceStatus(org.eclipse.che.api.core.model.workspace.WorkspaceStatus) Mockito.when(org.mockito.Mockito.when) NotFoundException(org.eclipse.che.api.core.NotFoundException) Filter(org.everrest.core.Filter) Mockito.verify(org.mockito.Mockito.verify) Mockito(org.mockito.Mockito) Factory(org.eclipse.che.api.core.model.factory.Factory) RequestFilter(org.everrest.core.RequestFilter) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) Assert.assertTrue(org.testng.Assert.assertTrue) ADMIN_USER_PASSWORD(org.everrest.assured.JettyHttpServer.ADMIN_USER_PASSWORD) UserManager(org.eclipse.che.api.user.server.UserManager) InputStream(java.io.InputStream) FactoryDto(org.eclipse.che.api.factory.shared.dto.FactoryDto) DtoFactory(org.eclipse.che.dto.server.DtoFactory) Factory(org.eclipse.che.api.core.model.factory.Factory) Test(org.testng.annotations.Test)

Aggregations

FluentIterable (com.google.common.collect.FluentIterable)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 RestAssured.given (com.jayway.restassured.RestAssured.given)1 ContentType (com.jayway.restassured.http.ContentType)1 Response (com.jayway.restassured.response.Response)1 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 String.format (java.lang.String.format)1 String.valueOf (java.lang.String.valueOf)1 Thread.currentThread (java.lang.Thread.currentThread)1 URI (java.net.URI)1 URL (java.net.URL)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 Arrays (java.util.Arrays)1