Search in sources :

Example 46 with UserDevfileImpl

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

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 47 with UserDevfileImpl

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

the class UserDevfileManagerTest method shouldThrowNotFoundIfUserDevfileIsNotFoundOnUpdate.

@Test(expectedExceptions = NotFoundException.class)
public void shouldThrowNotFoundIfUserDevfileIsNotFoundOnUpdate() throws Exception {
    // given
    final UserDevfileImpl userDevfile = createUserDevfile();
    Mockito.doReturn(Optional.empty()).when(userDevfileDao).update(any(UserDevfileImpl.class));
    // when
    userDevfileManager.updateUserDevfile(userDevfile);
}
Also used : UserDevfileImpl(org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl) Test(org.testng.annotations.Test)

Example 48 with UserDevfileImpl

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

the class UserDevfileDaoTest method shouldGetUserDevfileById.

@Test
public void shouldGetUserDevfileById() throws Exception {
    final UserDevfileImpl devfile = devfiles[0];
    assertEquals(userDevfileDaoDao.getById(devfile.getId()), Optional.of(devfile));
}
Also used : UserDevfileImpl(org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl) Test(org.testng.annotations.Test)

Example 49 with UserDevfileImpl

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

the class UserDevfileDaoTest method shouldUpdateUserDevfile.

@Test
public void shouldUpdateUserDevfile() throws Exception {
    // given
    DevfileImpl newDevfile = TestObjectGenerator.createDevfile("newUpdate");
    newDevfile.setApiVersion("V15.0");
    newDevfile.setProjects(ImmutableList.of(new ProjectImpl("projectUp2", new SourceImpl("typeUp2", "http://location", "branch2", "point2", "tag2", "commit2", "sparseCheckoutDir2"), "path2")));
    newDevfile.setComponents(ImmutableList.of(new ComponentImpl("type3", "id54")));
    newDevfile.setCommands(ImmutableList.of(new CommandImpl(new CommandImpl("cmd1", Collections.singletonList(new ActionImpl("exe44", "compo2nent2", "run.sh", "/home/user/2", null, null)), Collections.singletonMap("attr1", "value1"), null))));
    newDevfile.setAttributes(ImmutableMap.of("key2", "val34"));
    newDevfile.setMetadata(new MetadataImpl("myNewName"));
    final UserDevfileImpl update = devfiles[0];
    update.setDevfile(newDevfile);
    // when
    userDevfileDaoDao.update(update);
    // then
    assertEquals(userDevfileDaoDao.getById(update.getId()), Optional.of(update));
}
Also used : CommandImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl) MetadataImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.MetadataImpl) UserDevfileImpl(org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) ProjectImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl) SourceImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl) UserDevfileImpl(org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl) ActionImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ActionImpl) ComponentImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl) Test(org.testng.annotations.Test)

Example 50 with UserDevfileImpl

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

the class UserDevfileDaoTest method shouldCreateUserDevfileWithEmptyMataName.

@Test
public void shouldCreateUserDevfileWithEmptyMataName() throws Exception {
    // given
    final UserDevfileImpl devfile = createUserDevfile(accounts[0]);
    DevfileImpl newDevfile = new DevfileImpl(devfile.getDevfile());
    MetadataImpl newMeta = new MetadataImpl();
    newMeta.setGenerateName("gener-");
    newDevfile.setMetadata(newMeta);
    devfile.setDevfile(newDevfile);
    // when
    userDevfileDaoDao.create(devfile);
    Optional<UserDevfile> devfileOptional = userDevfileDaoDao.getById(devfile.getId());
    assertTrue(devfileOptional.isPresent());
    UserDevfile actual = devfileOptional.get();
    assertNull(actual.getDevfile().getMetadata().getName());
    assertNotNull(actual.getDevfile().getMetadata().getGenerateName());
    assertEquals(devfileOptional, Optional.of(new UserDevfileImpl(devfile)));
}
Also used : MetadataImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.MetadataImpl) 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) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) 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