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));
}
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));
}
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));
}
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));
}
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);
}
Aggregations