use of org.eclipse.che.api.workspace.activity.WorkspaceActivity in project devspaces-images by redhat-developer.
the class WorkspaceActivityTckModule method configure.
@Override
protected void configure() {
H2DBTestServer server = H2DBTestServer.startDefault();
install(new PersistTestModuleBuilder().setDriver(Driver.class).runningOn(server).addEntityClasses(WorkspaceActivity.class, AccountImpl.class, WorkspaceImpl.class, WorkspaceConfigImpl.class, ProjectConfigImpl.class, EnvironmentImpl.class, RecipeImpl.class, MachineConfigImpl.class, SourceStorageImpl.class, ServerConfigImpl.class, CommandImpl.class, RecipeImpl.class, VolumeImpl.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, 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(WorkspaceActivityDao.class).to(JpaWorkspaceActivityDao.class);
bind(new TypeLiteral<TckRepository<AccountImpl>>() {
}).toInstance(new JpaTckRepository<>(AccountImpl.class));
bind(new TypeLiteral<TckRepository<WorkspaceActivity>>() {
}).toInstance(new JpaTckRepository<>(WorkspaceActivity.class));
bind(new TypeLiteral<TckRepository<WorkspaceImpl>>() {
}).toInstance(new WorkspaceRepository());
}
use of org.eclipse.che.api.workspace.activity.WorkspaceActivity in project devspaces-images by redhat-developer.
the class WorkspaceActivityDaoTest method createdTimeMustSetLastStopped.
@Test
public void createdTimeMustSetLastStopped() throws TckRepositoryException, ServerException {
// given new workspace with created activity
AccountImpl newAccount = new AccountImpl("new_account", "new_account", "test");
WorkspaceImpl workspace = createWorkspace("new_ws", newAccount, "new_ws");
accountTckRepository.createAll(singletonList(newAccount));
wsTckRepository.createAll(singletonList(workspace));
Page<String> stopped = workspaceActivityDao.findInStatusSince(Instant.now().toEpochMilli(), STOPPED, 100, 0);
assertTrue(stopped.isEmpty());
// when created workspace activity
workspaceActivityDao.setCreatedTime("new_ws", Instant.now().toEpochMilli());
// then find STOPPED must return it and activity must have set last_stopped timestamp
stopped = workspaceActivityDao.findInStatusSince(Instant.now().toEpochMilli(), STOPPED, 100, 0);
assertFalse(stopped.isEmpty());
assertEquals(stopped.getItemsCount(), 1);
WorkspaceActivity activity = workspaceActivityDao.findActivity("new_ws");
assertNotNull(activity.getLastStopped());
}
use of org.eclipse.che.api.workspace.activity.WorkspaceActivity in project devspaces-images by redhat-developer.
the class WorkspaceActivityDaoTest method createWorkspaceActivitiesWithStatuses.
/**
* Helper function that creates workspaces that are in the RUNNING and STOPPED state for
* shouldExpireWorkspaceThatExceedsRunTimeout
*
* @return A list of WorkspaceActivity objects
*/
private List<WorkspaceActivity> createWorkspaceActivitiesWithStatuses() {
WorkspaceActivity[] a = new WorkspaceActivity[3];
a[0] = new WorkspaceActivity();
a[0].setWorkspaceId("ws0");
a[0].setStatus(WorkspaceStatus.RUNNING);
a[0].setCreated(1_000_000);
a[0].setLastStarting(1_000_000);
a[0].setLastRunning(1_000_100);
a[0].setLastStopped(0);
a[0].setLastStopping(0);
a[0].setExpiration(1_100_000L);
a[1] = new WorkspaceActivity();
a[1].setWorkspaceId("ws1");
a[1].setStatus(WorkspaceStatus.RUNNING);
a[1].setCreated(7_000_000);
a[1].setLastStarting(7_000_000);
a[1].setLastRunning(7_100_000);
a[1].setLastStopped(0);
a[1].setLastStopping(0);
a[1].setExpiration(8_000_000L);
a[2] = new WorkspaceActivity();
a[2].setWorkspaceId("ws2");
a[2].setStatus(WorkspaceStatus.STOPPED);
a[2].setCreated(1_000_200);
a[2].setLastStarting(1_000_200);
a[2].setLastRunning(1_000_300);
a[2].setLastStopped(1_000_400);
a[2].setLastStopping(1_000_350);
return asList(a);
}
Aggregations