use of org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl in project che-server by eclipse-che.
the class MySqlTckModule method configure.
@Override
protected void configure() {
final String dbUrl = System.getProperty("jdbc.url");
final String dbUser = System.getProperty("jdbc.user");
final String dbPassword = System.getProperty("jdbc.password");
waitConnectionIsEstablished(dbUrl, dbUser, dbPassword);
// jpa
install(new PersistTestModuleBuilder().setDriver(com.mysql.cj.jdbc.Driver.class).setUrl(dbUrl).setUser(dbUser).setPassword(dbPassword).setExceptionHandler(MySqlExceptionHandler.class).addEntityClasses(AccountImpl.class, UserImpl.class, ProfileImpl.class, PreferenceEntity.class, WorkspaceImpl.class, WorkspaceConfigImpl.class, ProjectConfigImpl.class, EnvironmentImpl.class, RecipeImpl.class, MachineConfigImpl.class, SourceStorageImpl.class, ServerConfigImpl.class, CommandImpl.class, SshPairImpl.class, WorkspaceActivity.class, VolumeImpl.class, SignatureKeyImpl.class, SignatureKeyPairImpl.class, // devfile
UserDevfileImpl.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, // k8s-runtimes
KubernetesRuntimeState.class, KubernetesRuntimeCommandImpl.class, KubernetesMachineImpl.class, KubernetesMachineImpl.MachineId.class, KubernetesServerImpl.class, KubernetesServerImpl.ServerId.class).addEntityClass("org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute").addClass(SerializableConverter.class).build());
bind(TckResourcesCleaner.class).to(JpaCleaner.class);
// db initialization
bind(DBInitializer.class).asEagerSingleton();
final com.mysql.cj.jdbc.MysqlDataSource dataSource = new com.mysql.cj.jdbc.MysqlDataSource();
dataSource.setUser(dbUser);
dataSource.setPassword(dbPassword);
dataSource.setUrl(dbUrl);
bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(dataSource, "che-schema"));
// account
bind(AccountDao.class).to(JpaAccountDao.class);
bind(new TypeLiteral<TckRepository<AccountImpl>>() {
}).toInstance(new JpaTckRepository<>(AccountImpl.class));
// user
bind(UserDao.class).to(JpaUserDao.class);
bind(ProfileDao.class).to(JpaProfileDao.class);
bind(PreferenceDao.class).to(JpaPreferenceDao.class);
bind(new TypeLiteral<TckRepository<UserImpl>>() {
}).to(UserRepo.class);
bind(new TypeLiteral<TckRepository<Pair<String, Map<String, String>>>>() {
}).to(PreferencesRepo.class);
bind(new TypeLiteral<TckRepository<ProfileImpl>>() {
}).toInstance(new JpaTckRepository<>(ProfileImpl.class));
bind(PasswordEncryptor.class).to(SHA512PasswordEncryptor.class);
// machine
bind(new TypeLiteral<TckRepository<RecipeImpl>>() {
}).toInstance(new JpaTckRepository<>(RecipeImpl.class));
// ssh
bind(SshDao.class).to(JpaSshDao.class);
bind(new TypeLiteral<TckRepository<SshPairImpl>>() {
}).toInstance(new JpaTckRepository<>(SshPairImpl.class));
// workspace
bind(WorkspaceDao.class).to(JpaWorkspaceDao.class);
bind(WorkspaceActivityDao.class).to(JpaWorkspaceActivityDao.class);
bind(new TypeLiteral<TckRepository<WorkspaceImpl>>() {
}).toInstance(new WorkspaceRepository());
bind(UserDevfileDao.class).to(JpaUserDevfileDao.class);
bind(new TypeLiteral<TckRepository<UserDevfileImpl>>() {
}).toInstance(new JpaTckRepository<>(UserDevfileImpl.class));
// sign keys
bind(SignatureKeyDao.class).to(JpaSignatureKeyDao.class);
bind(new TypeLiteral<TckRepository<SignatureKeyPairImpl>>() {
}).toInstance(new JpaTckRepository<>(SignatureKeyPairImpl.class));
// k8s runtimes
bind(new TypeLiteral<TckRepository<KubernetesRuntimeState>>() {
}).toInstance(new JpaTckRepository<>(KubernetesRuntimeState.class));
bind(new TypeLiteral<TckRepository<KubernetesMachineImpl>>() {
}).toInstance(new JpaTckRepository<>(KubernetesMachineImpl.class));
bind(KubernetesRuntimeStateCache.class).to(JpaKubernetesRuntimeStateCache.class);
bind(KubernetesMachineCache.class).to(JpaKubernetesMachineCache.class);
bind(JpaKubernetesRuntimeStateCache.RemoveKubernetesRuntimeBeforeWorkspaceRemoved.class).asEagerSingleton();
bind(JpaKubernetesMachineCache.RemoveKubernetesMachinesBeforeRuntimesRemoved.class).asEagerSingleton();
}
use of org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl in project che-server by eclipse-che.
the class DevfileServiceTest method shouldBeAbleToUpdateUserDevfile.
@Test
public void shouldBeAbleToUpdateUserDevfile() throws Exception {
// given
final UserDevfileDto devfileDto = TestObjectGenerator.createUserDevfileDto();
final UserDevfileImpl userDevfileImpl = new UserDevfileImpl(devfileDto, TEST_ACCOUNT);
when(userDevfileManager.updateUserDevfile(any(UserDevfile.class))).thenReturn(userDevfileImpl);
// when
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType(APPLICATION_JSON).body(DtoFactory.getInstance().toJson(devfileDto)).when().put(SECURE_PATH + "/devfile/" + devfileDto.getId());
// then
assertEquals(response.getStatusCode(), 200);
assertEquals(new UserDevfileImpl(unwrapDto(response, UserDevfileDto.class), TEST_ACCOUNT), userDevfileImpl);
verify(userDevfileManager).updateUserDevfile(devfileDto);
verify(linksInjector).injectLinks(any(), any());
}
use of org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl in project che-server by eclipse-che.
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);
}
use of org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl in project che-server by eclipse-che.
the class UserDevfileManagerTest method shouldRemoveUserDevfile.
@Test
public void shouldRemoveUserDevfile() throws Exception {
// given
final UserDevfileImpl userDevfile = createUserDevfile();
// when
userDevfileManager.removeUserDevfile(userDevfile.getId());
// then
verify(userDevfileDao).remove(userDevfile.getId());
}
use of org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl in project che-server by eclipse-che.
the class UserDevfileManagerTest method shouldBeAbleToGetUserDevfilesAvailableToUser.
@Test
public void shouldBeAbleToGetUserDevfilesAvailableToUser() throws ServerException {
// given
final UserDevfileImpl userDevfile = createUserDevfile();
final UserDevfileImpl userDevfile2 = createUserDevfile();
when(userDevfileDao.getDevfiles(2, 30, Collections.emptyList(), Collections.emptyList())).thenReturn(new Page<>(asList(userDevfile, userDevfile2), 0, 2, 2));
// when
Page<UserDevfile> actual = userDevfileManager.getUserDevfiles(2, 30, Collections.emptyList(), Collections.emptyList());
// then
assertEquals(actual.getItems().size(), 2);
}
Aggregations