Search in sources :

Example 21 with UserDevfileImpl

use of org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl in project devspaces-images by redhat-developer.

the class UserDevfileTckModule method configure.

@Override
protected void configure() {
    H2DBTestServer server = H2DBTestServer.startDefault();
    install(new PersistTestModuleBuilder().setDriver(Driver.class).runningOn(server).addEntityClasses(AccountImpl.class, UserImpl.class, WorkspaceImpl.class, WorkspaceConfigImpl.class, ProjectConfigImpl.class, EnvironmentImpl.class, MachineConfigImpl.class, SourceStorageImpl.class, ServerConfigImpl.class, CommandImpl.class, RecipeImpl.class, VolumeImpl.class, // devfile
    UserDevfileImpl.class, UserDevfilePermissionImpl.class, ActionImpl.class, org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl.class, ComponentImpl.class, DevfileImpl.class, EndpointImpl.class, EntrypointImpl.class, EnvImpl.class, ProjectImpl.class, SourceImpl.class, org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl.class).addEntityClass("org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute").addClass(SerializableConverter.class).setExceptionHandler(H2ExceptionHandler.class).build());
    bind(DBInitializer.class).asEagerSingleton();
    bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
    bind(TckResourcesCleaner.class).toInstance(new H2JpaCleaner(server));
    bind(new TypeLiteral<TckRepository<UserDevfileImpl>>() {
    }).toInstance(new JpaTckRepository<>(UserDevfileImpl.class));
    bind(new TypeLiteral<TckRepository<UserImpl>>() {
    }).toInstance(new JpaTckRepository<>(UserImpl.class));
    bind(new TypeLiteral<TckRepository<UserDevfilePermissionImpl>>() {
    }).toInstance(new JpaTckRepository<>(UserDevfilePermissionImpl.class));
    bind(new TypeLiteral<AbstractPermissionsDomain<UserDevfilePermissionImpl>>() {
    }).to(UserDevfilePermissionDaoTest.TestDomain.class);
    bind(UserDevfilePermissionDao.class).to(JpaUserDevfilePermissionDao.class);
    bind(AccountDao.class).to(JpaAccountDao.class);
    bind(new TypeLiteral<TckRepository<AccountImpl>>() {
    }).toInstance(new JpaTckRepository<>(AccountImpl.class));
}
Also used : TckResourcesCleaner(org.eclipse.che.commons.test.tck.TckResourcesCleaner) WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) JpaUserDevfilePermissionDao(org.eclipse.che.multiuser.permission.devfile.server.spi.jpa.JpaUserDevfilePermissionDao) UserDevfilePermissionDao(org.eclipse.che.multiuser.permission.devfile.server.spi.UserDevfilePermissionDao) AccountImpl(org.eclipse.che.account.spi.AccountImpl) Driver(org.h2.Driver) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) ComponentImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl) H2JpaCleaner(org.eclipse.che.commons.test.db.H2JpaCleaner) UserDevfilePermissionDaoTest(org.eclipse.che.multiuser.permission.devfile.server.spi.tck.UserDevfilePermissionDaoTest) SchemaInitializer(org.eclipse.che.core.db.schema.SchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) TypeLiteral(com.google.inject.TypeLiteral) DBInitializer(org.eclipse.che.core.db.DBInitializer) UserDevfileImpl(org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) UserDevfileImpl(org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) WorkspaceConfigImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl) UserDevfilePermissionImpl(org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl) CommandImpl(org.eclipse.che.api.workspace.server.model.impl.CommandImpl) EntrypointImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.EntrypointImpl) H2DBTestServer(org.eclipse.che.commons.test.db.H2DBTestServer) ProjectImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl) EndpointImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl) EnvImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl) AccountDao(org.eclipse.che.account.spi.AccountDao) JpaAccountDao(org.eclipse.che.account.spi.jpa.JpaAccountDao) SourceStorageImpl(org.eclipse.che.api.workspace.server.model.impl.SourceStorageImpl) PersistTestModuleBuilder(org.eclipse.che.commons.test.db.PersistTestModuleBuilder) SerializableConverter(org.eclipse.che.api.workspace.server.devfile.SerializableConverter) MachineConfigImpl(org.eclipse.che.api.workspace.server.model.impl.MachineConfigImpl) SourceImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl) RecipeImpl(org.eclipse.che.api.workspace.server.model.impl.RecipeImpl) VolumeImpl(org.eclipse.che.api.workspace.server.model.impl.VolumeImpl) ActionImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ActionImpl) ProjectConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl)

Example 22 with UserDevfileImpl

use of org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl in project devspaces-images by redhat-developer.

the class JpaTckModule method configure.

@Override
protected void configure() {
    H2DBTestServer server = H2DBTestServer.startDefault();
    install(new PersistTestModuleBuilder().setDriver(Driver.class).runningOn(server).addEntityClasses(AccountImpl.class, UserImpl.class, UserDevfilePermissionImpl.class, // devfile
    ActionImpl.class, org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl.class, ComponentImpl.class, DevfileImpl.class, EndpointImpl.class, EntrypointImpl.class, EnvImpl.class, ProjectImpl.class, SourceImpl.class, UserDevfileImpl.class, org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl.class).addClass(SerializableConverter.class).setExceptionHandler(H2ExceptionHandler.class).build());
    bind(new TypeLiteral<AbstractPermissionsDomain<UserDevfilePermissionImpl>>() {
    }).to(UserDevfilePermissionDaoTest.TestDomain.class);
    bind(UserDevfilePermissionDao.class).to(JpaUserDevfilePermissionDao.class);
    bind(AccountDao.class).to(JpaAccountDao.class);
    bind(new TypeLiteral<TckRepository<UserDevfilePermission>>() {
    }).toInstance(new JpaTckRepository<>(UserDevfilePermission.class));
    bind(new TypeLiteral<TckRepository<UserImpl>>() {
    }).toInstance(new JpaTckRepository<>(UserImpl.class));
    bind(new TypeLiteral<TckRepository<UserDevfileImpl>>() {
    }).toInstance(new JpaTckRepository<>(UserDevfileImpl.class));
    bind(new TypeLiteral<TckRepository<AccountImpl>>() {
    }).toInstance(new JpaTckRepository<>(AccountImpl.class));
    bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
    bind(DBInitializer.class).asEagerSingleton();
    bind(TckResourcesCleaner.class).toInstance(new H2JpaCleaner(server));
}
Also used : TckResourcesCleaner(org.eclipse.che.commons.test.tck.TckResourcesCleaner) H2DBTestServer(org.eclipse.che.commons.test.db.H2DBTestServer) UserDevfilePermissionDao(org.eclipse.che.multiuser.permission.devfile.server.spi.UserDevfilePermissionDao) AccountImpl(org.eclipse.che.account.spi.AccountImpl) AccountDao(org.eclipse.che.account.spi.AccountDao) JpaAccountDao(org.eclipse.che.account.spi.jpa.JpaAccountDao) H2JpaCleaner(org.eclipse.che.commons.test.db.H2JpaCleaner) UserDevfilePermission(org.eclipse.che.multiuser.permission.devfile.server.model.UserDevfilePermission) UserDevfilePermissionDaoTest(org.eclipse.che.multiuser.permission.devfile.server.spi.tck.UserDevfilePermissionDaoTest) PersistTestModuleBuilder(org.eclipse.che.commons.test.db.PersistTestModuleBuilder) SchemaInitializer(org.eclipse.che.core.db.schema.SchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) SerializableConverter(org.eclipse.che.api.workspace.server.devfile.SerializableConverter) TypeLiteral(com.google.inject.TypeLiteral) DBInitializer(org.eclipse.che.core.db.DBInitializer) UserDevfileImpl(org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) UserDevfilePermissionImpl(org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl)

Example 23 with UserDevfileImpl

use of org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl in project devspaces-images by redhat-developer.

the class DevfileServiceTest method shouldCreateUserDevfileFromJson.

@Test(dataProvider = "validUserDevfiles")
public void shouldCreateUserDevfileFromJson(UserDevfileDto userDevfileDto) throws Exception {
    final UserDevfileImpl userDevfileImpl = new UserDevfileImpl("id-123123", TEST_ACCOUNT, userDevfileDto);
    when(userDevfileManager.createDevfile(any(UserDevfile.class))).thenReturn(userDevfileImpl);
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").body(DtoFactory.getInstance().toJson(userDevfileDto)).when().post(SECURE_PATH + "/devfile");
    assertEquals(response.getStatusCode(), 201);
    UserDevfileDto dto = unwrapDto(response, UserDevfileDto.class);
    assertEquals(dto.getNamespace(), TEST_ACCOUNT.getName());
    assertEquals(new UserDevfileImpl(dto, TEST_ACCOUNT), userDevfileImpl);
    verify(userDevfileManager).createDevfile(any(UserDevfile.class));
}
Also used : Response(io.restassured.response.Response) UserDevfile(org.eclipse.che.api.core.model.workspace.devfile.UserDevfile) UserDevfileImpl(org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl) UserDevfileDto(org.eclipse.che.api.devfile.shared.dto.UserDevfileDto) Test(org.testng.annotations.Test)

Example 24 with UserDevfileImpl

use of org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl in project devspaces-images by redhat-developer.

the class UserDevfileManagerTest method shouldUpdateUserDevfile.

@Test
public void shouldUpdateUserDevfile() throws Exception {
    // given
    final UserDevfileImpl userDevfile = createUserDevfile();
    when(userDevfileDao.update(any(UserDevfileImpl.class))).thenAnswer(invocationOnMock -> Optional.of(invocationOnMock.getArguments()[0]));
    // when
    userDevfileManager.updateUserDevfile(userDevfile);
    // then
    verify(userDevfileDao).update(eq(userDevfile));
}
Also used : UserDevfileImpl(org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl) Test(org.testng.annotations.Test)

Example 25 with UserDevfileImpl

use of org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl in project devspaces-images by redhat-developer.

the class UserDevfileManagerTest method shouldGenerateUserDevfileIdOnCreation.

@Test
public void shouldGenerateUserDevfileIdOnCreation() throws Exception {
    // given
    final UserDevfileImpl userDevfile = new UserDevfileImpl(null, TEST_ACCOUNT, createUserDevfile());
    when(userDevfileDao.create(any(UserDevfileImpl.class))).thenAnswer(invocationOnMock -> invocationOnMock.getArguments()[0]);
    // when
    UserDevfile actual = userDevfileManager.createDevfile(userDevfile);
    // then
    verify(userDevfileDao).create(userDevfileArgumentCaptor.capture());
    assertFalse(isNullOrEmpty(userDevfileArgumentCaptor.getValue().getId()));
    assertEquals(new UserDevfileImpl(null, TEST_ACCOUNT, actual), userDevfile);
}
Also used : UserDevfile(org.eclipse.che.api.core.model.workspace.devfile.UserDevfile) TestObjectGenerator.createUserDevfile(org.eclipse.che.api.devfile.server.TestObjectGenerator.createUserDevfile) UserDevfileImpl(org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl) Test(org.testng.annotations.Test)

Aggregations

UserDevfileImpl (org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl)74 Test (org.testng.annotations.Test)46 UserDevfile (org.eclipse.che.api.core.model.workspace.devfile.UserDevfile)28 TestObjectGenerator.createUserDevfile (org.eclipse.che.api.devfile.server.TestObjectGenerator.createUserDevfile)18 AccountImpl (org.eclipse.che.account.spi.AccountImpl)16 UserImpl (org.eclipse.che.api.user.server.model.impl.UserImpl)16 TypeLiteral (com.google.inject.TypeLiteral)14 TckResourcesCleaner (org.eclipse.che.commons.test.tck.TckResourcesCleaner)14 DBInitializer (org.eclipse.che.core.db.DBInitializer)14 SchemaInitializer (org.eclipse.che.core.db.schema.SchemaInitializer)14 FlywaySchemaInitializer (org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer)14 AccountDao (org.eclipse.che.account.spi.AccountDao)12 Response (io.restassured.response.Response)10 JpaAccountDao (org.eclipse.che.account.spi.jpa.JpaAccountDao)10 Pair (org.eclipse.che.commons.lang.Pair)10 PersistTestModuleBuilder (org.eclipse.che.commons.test.db.PersistTestModuleBuilder)10 Transactional (com.google.inject.persist.Transactional)8 EntityManager (javax.persistence.EntityManager)8 UserDevfileDto (org.eclipse.che.api.devfile.shared.dto.UserDevfileDto)8 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)8