Search in sources :

Example 6 with UserDevfileImpl

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

the class UserDevfileManagerTest method shouldSendDevfileUpdatedEventOnUpdateDevfile.

@Test
public void shouldSendDevfileUpdatedEventOnUpdateDevfile() 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(eventService).publish(devfileUpdatedEventCaptor.capture());
    assertEquals(userDevfile, devfileUpdatedEventCaptor.getValue().getUserDevfile());
}
Also used : UserDevfileImpl(org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl) Test(org.testng.annotations.Test)

Example 7 with UserDevfileImpl

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

the class UserDevfileManagerTest method shouldSendDevfileCreatedEventOnCreation.

@Test
public void shouldSendDevfileCreatedEventOnCreation() 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 expected = userDevfileManager.createDevfile(userDevfile);
    // then
    verify(eventService).publish(devfileCreatedEventCaptor.capture());
    assertEquals(expected, devfileCreatedEventCaptor.getValue().getUserDevfile());
}
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)

Example 8 with UserDevfileImpl

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

the class UserDevfileTckModule method configure.

@Override
protected void configure() {
    H2DBTestServer server = H2DBTestServer.startDefault();
    install(new PersistTestModuleBuilder().setDriver(Driver.class).runningOn(server).addEntityClasses(UserImpl.class, AccountImpl.class, UserDevfileImpl.class, DevfileImpl.class, ActionImpl.class, CommandImpl.class, ComponentImpl.class, DevfileImpl.class, EndpointImpl.class, EntrypointImpl.class, EnvImpl.class, ProjectImpl.class, SourceImpl.class, VolumeImpl.class).addClass(SerializableConverter.class).setExceptionHandler(H2ExceptionHandler.class).setProperty("eclipselink.logging.level", "OFF").build());
    bind(DBInitializer.class).asEagerSingleton();
    bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
    bind(TckResourcesCleaner.class).toInstance(new H2JpaCleaner(server));
    bind(UserDevfileDao.class).to(JpaUserDevfileDao.class);
    bind(AccountDao.class).to(JpaAccountDao.class);
    bind(new TypeLiteral<TckRepository<UserDevfileImpl>>() {
    }).toInstance(new JpaTckRepository<>(UserDevfileImpl.class));
    bind(new TypeLiteral<TckRepository<UserImpl>>() {
    }).toInstance(new JpaTckRepository<>(UserImpl.class));
    bind(new TypeLiteral<TckRepository<AccountImpl>>() {
    }).toInstance(new JpaTckRepository<>(AccountImpl.class));
}
Also used : TckResourcesCleaner(org.eclipse.che.commons.test.tck.TckResourcesCleaner) H2ExceptionHandler(org.eclipse.che.core.db.h2.jpa.eclipselink.H2ExceptionHandler) AccountImpl(org.eclipse.che.account.spi.AccountImpl) Driver(org.h2.Driver) ComponentImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl) H2JpaCleaner(org.eclipse.che.commons.test.db.H2JpaCleaner) UserDevfileDao(org.eclipse.che.api.devfile.server.spi.UserDevfileDao) 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) CommandImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.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) PersistTestModuleBuilder(org.eclipse.che.commons.test.db.PersistTestModuleBuilder) SourceImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl) ActionImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ActionImpl) VolumeImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl)

Example 9 with UserDevfileImpl

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

the class UserDevfileDaoTest method shouldNotUpdateWorkspaceWhichDoesNotExist.

@Test
public void shouldNotUpdateWorkspaceWhichDoesNotExist() throws Exception {
    // given
    final UserDevfileImpl userDevfile = devfiles[0];
    userDevfile.setId("non-existing-devfile");
    // when
    Optional<UserDevfile> result = userDevfileDaoDao.update(userDevfile);
    // then
    assertFalse(result.isPresent());
}
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)

Example 10 with UserDevfileImpl

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

the class UserDevfileDaoTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    accounts = new AccountImpl[COUNT_OF_ACCOUNTS];
    for (int i = 0; i < COUNT_OF_ACCOUNTS; i++) {
        accounts[i] = new AccountImpl("accountId" + i, "accountName" + i, "test");
    }
    devfiles = new UserDevfileImpl[ENTRY_COUNT];
    for (int i = 0; i < ENTRY_COUNT; i++) {
        AccountImpl account = accounts[i / 2];
        devfiles[i] = createUserDevfile(NameGenerator.generate("id-" + i + "-", 6), account, NameGenerator.generate("devfileName-" + i, 6));
    }
    accountRepo.createAll(Stream.of(accounts).map(AccountImpl::new).collect(toList()));
    devfileTckRepository.createAll(Stream.of(devfiles).map(UserDevfileImpl::new).collect(toList()));
}
Also used : UserDevfileImpl(org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl) AccountImpl(org.eclipse.che.account.spi.AccountImpl) BeforeMethod(org.testng.annotations.BeforeMethod)

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