Search in sources :

Example 6 with FreeResourcesLimit

use of org.eclipse.che.multiuser.resource.model.FreeResourcesLimit in project che-server by eclipse-che.

the class FreeResourcesLimitServiceTest method shouldStoreResourcesLimit.

@Test
public void shouldStoreResourcesLimit() throws Exception {
    FreeResourcesLimit toCreate = new FreeResourcesLimitImpl("account123", singletonList(new ResourceImpl(TEST_RESOURCE_TYPE, 1000, "unit")));
    FreeResourcesLimit created = new FreeResourcesLimitImpl("account123", singletonList(new ResourceImpl(TEST_RESOURCE_TYPE, 1000, "unit")));
    when(freeResourcesLimitManager.store(any())).thenReturn(created);
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").body(DtoConverter.asDto(toCreate)).when().post(SECURE_PATH + "/resource/free");
    assertEquals(response.statusCode(), 201);
    final FreeResourcesLimitDto result = unwrapDto(response, FreeResourcesLimitDto.class);
    assertEquals(DtoConverter.asDto(created), result);
    verify(freeResourcesLimitManager).store(DtoConverter.asDto(toCreate));
    verify(resourcesLimitValidator).check(any());
}
Also used : Response(io.restassured.response.Response) FreeResourcesLimitImpl(org.eclipse.che.multiuser.resource.spi.impl.FreeResourcesLimitImpl) ResourceImpl(org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl) FreeResourcesLimit(org.eclipse.che.multiuser.resource.model.FreeResourcesLimit) FreeResourcesLimitDto(org.eclipse.che.multiuser.resource.shared.dto.FreeResourcesLimitDto) Test(org.testng.annotations.Test)

Example 7 with FreeResourcesLimit

use of org.eclipse.che.multiuser.resource.model.FreeResourcesLimit in project che-server by eclipse-che.

the class FreeResourcesLimitServiceTest method shouldReturnResourcesLimitForGivenAccount.

@Test
public void shouldReturnResourcesLimitForGivenAccount() throws Exception {
    FreeResourcesLimit resourcesLimit = new FreeResourcesLimitImpl("account123", singletonList(new ResourceImpl(TEST_RESOURCE_TYPE, 1000, "unit")));
    when(freeResourcesLimitManager.get("account123")).thenReturn(resourcesLimit);
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").when().get(SECURE_PATH + "/resource/free/account123");
    assertEquals(response.statusCode(), 200);
    final FreeResourcesLimitDto fetchedLimit = unwrapDto(response, FreeResourcesLimitDto.class);
    assertEquals(fetchedLimit, DtoConverter.asDto(resourcesLimit));
    verify(freeResourcesLimitManager).get("account123");
}
Also used : Response(io.restassured.response.Response) FreeResourcesLimitImpl(org.eclipse.che.multiuser.resource.spi.impl.FreeResourcesLimitImpl) ResourceImpl(org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl) FreeResourcesLimit(org.eclipse.che.multiuser.resource.model.FreeResourcesLimit) FreeResourcesLimitDto(org.eclipse.che.multiuser.resource.shared.dto.FreeResourcesLimitDto) Test(org.testng.annotations.Test)

Example 8 with FreeResourcesLimit

use of org.eclipse.che.multiuser.resource.model.FreeResourcesLimit in project che-server by eclipse-che.

the class FreeResourceManagerTest method shouldReturnFreeResourcesLimitForSpecifiedAccount.

@Test
public void shouldReturnFreeResourcesLimitForSpecifiedAccount() throws Exception {
    // given
    ResourceImpl resource = new ResourceImpl(TEST_RESOURCE_TYPE, 1, "unit");
    FreeResourcesLimitImpl resourcesLimitImpl = new FreeResourcesLimitImpl("account123", singletonList(resource));
    when(freeResourcesLimitDao.get(any())).thenReturn(resourcesLimitImpl);
    // when
    FreeResourcesLimit fetchedLimit = manager.get("account123");
    // then
    assertEquals(fetchedLimit, resourcesLimitImpl);
    verify(freeResourcesLimitDao).get("account123");
}
Also used : FreeResourcesLimitImpl(org.eclipse.che.multiuser.resource.spi.impl.FreeResourcesLimitImpl) ResourceImpl(org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl) FreeResourcesLimit(org.eclipse.che.multiuser.resource.model.FreeResourcesLimit) Test(org.testng.annotations.Test)

Example 9 with FreeResourcesLimit

use of org.eclipse.che.multiuser.resource.model.FreeResourcesLimit in project devspaces-images by redhat-developer.

the class FreeResourceManagerTest method shouldReturnFreeResourcesLimitForSpecifiedAccount.

@Test
public void shouldReturnFreeResourcesLimitForSpecifiedAccount() throws Exception {
    // given
    ResourceImpl resource = new ResourceImpl(TEST_RESOURCE_TYPE, 1, "unit");
    FreeResourcesLimitImpl resourcesLimitImpl = new FreeResourcesLimitImpl("account123", singletonList(resource));
    when(freeResourcesLimitDao.get(any())).thenReturn(resourcesLimitImpl);
    // when
    FreeResourcesLimit fetchedLimit = manager.get("account123");
    // then
    assertEquals(fetchedLimit, resourcesLimitImpl);
    verify(freeResourcesLimitDao).get("account123");
}
Also used : FreeResourcesLimitImpl(org.eclipse.che.multiuser.resource.spi.impl.FreeResourcesLimitImpl) ResourceImpl(org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl) FreeResourcesLimit(org.eclipse.che.multiuser.resource.model.FreeResourcesLimit) Test(org.testng.annotations.Test)

Example 10 with FreeResourcesLimit

use of org.eclipse.che.multiuser.resource.model.FreeResourcesLimit in project devspaces-images by redhat-developer.

the class FreeResourcesLimitServiceTest method shouldStoreResourcesLimit.

@Test
public void shouldStoreResourcesLimit() throws Exception {
    FreeResourcesLimit toCreate = new FreeResourcesLimitImpl("account123", singletonList(new ResourceImpl(TEST_RESOURCE_TYPE, 1000, "unit")));
    FreeResourcesLimit created = new FreeResourcesLimitImpl("account123", singletonList(new ResourceImpl(TEST_RESOURCE_TYPE, 1000, "unit")));
    when(freeResourcesLimitManager.store(any())).thenReturn(created);
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").body(DtoConverter.asDto(toCreate)).when().post(SECURE_PATH + "/resource/free");
    assertEquals(response.statusCode(), 201);
    final FreeResourcesLimitDto result = unwrapDto(response, FreeResourcesLimitDto.class);
    assertEquals(DtoConverter.asDto(created), result);
    verify(freeResourcesLimitManager).store(DtoConverter.asDto(toCreate));
    verify(resourcesLimitValidator).check(any());
}
Also used : Response(io.restassured.response.Response) FreeResourcesLimitImpl(org.eclipse.che.multiuser.resource.spi.impl.FreeResourcesLimitImpl) ResourceImpl(org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl) FreeResourcesLimit(org.eclipse.che.multiuser.resource.model.FreeResourcesLimit) FreeResourcesLimitDto(org.eclipse.che.multiuser.resource.shared.dto.FreeResourcesLimitDto) Test(org.testng.annotations.Test)

Aggregations

FreeResourcesLimit (org.eclipse.che.multiuser.resource.model.FreeResourcesLimit)12 ResourceImpl (org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl)12 FreeResourcesLimitImpl (org.eclipse.che.multiuser.resource.spi.impl.FreeResourcesLimitImpl)10 Test (org.testng.annotations.Test)10 FreeResourcesLimitDto (org.eclipse.che.multiuser.resource.shared.dto.FreeResourcesLimitDto)8 Response (io.restassured.response.Response)6 HashMap (java.util.HashMap)2 NotFoundException (org.eclipse.che.api.core.NotFoundException)2 Resource (org.eclipse.che.multiuser.resource.model.Resource)2 ResourceDto (org.eclipse.che.multiuser.resource.shared.dto.ResourceDto)2 ProvidedResourcesImpl (org.eclipse.che.multiuser.resource.spi.impl.ProvidedResourcesImpl)2