use of org.eclipse.che.api.workspace.server.event.WorkspaceCreatedEvent in project che by eclipse.
the class WorkspaceManager method doCreateWorkspace.
private WorkspaceImpl doCreateWorkspace(WorkspaceConfig config, Account account, Map<String, String> attributes, boolean isTemporary) throws NotFoundException, ServerException, ConflictException {
final WorkspaceImpl workspace = WorkspaceImpl.builder().generateId().setConfig(config).setAccount(account).setAttributes(attributes).setTemporary(isTemporary).build();
workspace.getAttributes().put(CREATED_ATTRIBUTE_NAME, Long.toString(currentTimeMillis()));
workspaceDao.create(workspace);
LOG.info("Workspace '{}/{}' with id '{}' created by user '{}'", account.getName(), workspace.getConfig().getName(), workspace.getId(), sessionUserNameOr("undefined"));
eventService.publish(new WorkspaceCreatedEvent(workspace));
return workspace;
}
use of org.eclipse.che.api.workspace.server.event.WorkspaceCreatedEvent in project che by eclipse.
the class WorkspaceSshKeysTest method shouldGenerateSshKeyPairWhenWorkspaceIsCreated.
/**
* Ensure that when a new workspace is created, a new default ssh keypair is generated by asking sshManager
*/
@Test
public void shouldGenerateSshKeyPairWhenWorkspaceIsCreated() throws Exception {
// given
workspaceCreatedEventEventSubscriber.onEvent(new WorkspaceCreatedEvent(this.workspace));
// then
verify(sshManager).generatePair(eq(USER_ID), eq("workspace"), eq(WORKSPACE_ID));
}
Aggregations