Search in sources :

Example 36 with OrganizationImpl

use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.

the class OrganizationDaoTest method shouldRemoveOrganization.

@Test(dependsOnMethods = "shouldThrowNotFoundExceptionOnGettingNonExistingOrganizationById")
public void shouldRemoveOrganization() throws Exception {
    // given
    final OrganizationImpl organization = organizations[0];
    // when
    organizationDao.remove(organization.getId());
    // then
    assertNull(notFoundToNull(() -> organizationDao.getById(organization.getId())));
}
Also used : OrganizationImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl) Test(org.testng.annotations.Test)

Example 37 with OrganizationImpl

use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.

the class OrganizationDaoTest method shouldUpdateOrganization.

@Test
public void shouldUpdateOrganization() throws Exception {
    final OrganizationImpl toUpdate = new OrganizationImpl(organizations[0].getId(), "new-name", null);
    organizationDao.update(toUpdate);
    final OrganizationImpl updated = organizationDao.getById(toUpdate.getId());
    assertEquals(toUpdate, updated);
}
Also used : OrganizationImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl) Test(org.testng.annotations.Test)

Example 38 with OrganizationImpl

use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.

the class OrganizationDaoTest method setUp.

@BeforeMethod
private void setUp() throws TckRepositoryException {
    organizations = new OrganizationImpl[2];
    organizations[0] = new OrganizationImpl(NameGenerator.generate("organization", 10), "test1", null);
    organizations[1] = new OrganizationImpl(NameGenerator.generate("organization", 10), "test2", null);
    tckRepository.createAll(asList(organizations));
}
Also used : OrganizationImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 39 with OrganizationImpl

use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.

the class OrganizationDaoTest method shouldGetSuborganizations.

@Test
public void shouldGetSuborganizations() throws Exception {
    final OrganizationImpl parent = organizations[0];
    final OrganizationImpl child1 = new OrganizationImpl("child1", parent.getQualifiedName() + "/childTest1", parent.getId());
    final OrganizationImpl child2 = new OrganizationImpl("child2", child1.getQualifiedName() + "/childTest2", child1.getId());
    final OrganizationImpl child3 = new OrganizationImpl("child3", parent.getQualifiedName() + "/childTest3", parent.getId());
    tckRepository.createAll(asList(child1, child2, child3));
    final List<OrganizationImpl> suborganizations = Pages.stream((maxItems, skipCount) -> organizationDao.getSuborganizations(parent.getQualifiedName(), maxItems, skipCount), 1).collect(Collectors.toList());
    assertEquals(suborganizations.size(), 3);
}
Also used : Listeners(org.testng.annotations.Listeners) Assert.assertNull(org.testng.Assert.assertNull) TckRepository(org.eclipse.che.commons.test.tck.repository.TckRepository) Page(org.eclipse.che.api.core.Page) BeforeMethod(org.testng.annotations.BeforeMethod) Assert.assertEquals(org.testng.Assert.assertEquals) Callable(java.util.concurrent.Callable) Test(org.testng.annotations.Test) TckRepositoryException(org.eclipse.che.commons.test.tck.repository.TckRepositoryException) AfterMethod(org.testng.annotations.AfterMethod) Collectors(java.util.stream.Collectors) NotFoundException(org.eclipse.che.api.core.NotFoundException) OrganizationImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl) Inject(javax.inject.Inject) List(java.util.List) TckListener(org.eclipse.che.commons.test.tck.TckListener) OrganizationDao(org.eclipse.che.multiuser.organization.spi.OrganizationDao) Arrays.asList(java.util.Arrays.asList) Assert.assertTrue(org.testng.Assert.assertTrue) ConflictException(org.eclipse.che.api.core.ConflictException) Pages(org.eclipse.che.api.core.Pages) NameGenerator(org.eclipse.che.commons.lang.NameGenerator) EventService(org.eclipse.che.api.core.notification.EventService) OrganizationImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl) Test(org.testng.annotations.Test)

Example 40 with OrganizationImpl

use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.

the class OrganizationDaoTest method shouldCreateOrganization.

@Test
public void shouldCreateOrganization() throws Exception {
    final OrganizationImpl organization = new OrganizationImpl("organization123", "Test", null);
    organizationDao.create(organization);
    assertEquals(organizationDao.getById(organization.getId()), organization);
}
Also used : OrganizationImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl) Test(org.testng.annotations.Test)

Aggregations

OrganizationImpl (org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl)100 Test (org.testng.annotations.Test)56 Transactional (com.google.inject.persist.Transactional)18 BeforeMethod (org.testng.annotations.BeforeMethod)16 EntityManager (javax.persistence.EntityManager)14 MemberImpl (org.eclipse.che.multiuser.organization.spi.impl.MemberImpl)14 Organization (org.eclipse.che.multiuser.organization.shared.model.Organization)13 Response (io.restassured.response.Response)12 Page (org.eclipse.che.api.core.Page)10 ServerException (org.eclipse.che.api.core.ServerException)8 UserImpl (org.eclipse.che.api.user.server.model.impl.UserImpl)8 OrganizationDao (org.eclipse.che.multiuser.organization.spi.OrganizationDao)8 OrganizationDistributedResourcesImpl (org.eclipse.che.multiuser.organization.spi.impl.OrganizationDistributedResourcesImpl)7 TypeLiteral (com.google.inject.TypeLiteral)6 JpaPersistModule (com.google.inject.persist.jpa.JpaPersistModule)6 NotFoundException (org.eclipse.che.api.core.NotFoundException)6 OrganizationDto (org.eclipse.che.multiuser.organization.shared.dto.OrganizationDto)6 UserDevfilePermissionImpl (org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl)6 TckResourcesCleaner (org.eclipse.che.commons.test.tck.TckResourcesCleaner)5 DBInitializer (org.eclipse.che.core.db.DBInitializer)5