Skip to content

Commit

Permalink
Removed accountid from environment context
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergii Kabashniuk committed May 6, 2016
1 parent b48c15e commit 87d3a54
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public static void reset() {

private boolean workspaceTemporary;

private String accountId;

public EnvironmentContext() {
}
Expand All @@ -65,7 +64,6 @@ public EnvironmentContext(EnvironmentContext other) {
setUser(other.getUser());
setWorkspaceName(other.getWorkspaceName());
setWorkspaceId(other.getWorkspaceId());
setAccountId(other.getAccountId());
setWorkspaceTemporary(other.isWorkspaceTemporary());
}

Expand Down Expand Up @@ -94,14 +92,6 @@ public void setWorkspaceId(String workspaceId) {
this.workspaceId = workspaceId;
}

public String getAccountId() {
return accountId;
}

public void setAccountId(String accountId) {
this.accountId = accountId;
}

public boolean isWorkspaceTemporary() {
return workspaceTemporary;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@
import org.eclipse.che.commons.user.UserImpl;
import org.testng.annotations.Test;

import static org.testng.Assert.*;

import java.util.Collections;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;

public class EnvironmentContextTest {

@Test
public void shouldBeAbleToSetEnvContextInSameThread() {
//given
EnvironmentContext expected = EnvironmentContext.getCurrent();
expected.setAccountId("acc1");
expected.setWorkspaceId("ws1");
expected.setWorkspaceTemporary(true);
expected.setUser(new UserImpl("user", "id", "token", Collections.singleton("role"), false));

EnvironmentContext actual = EnvironmentContext.getCurrent();
assertEquals(actual.getAccountId(), "acc1");
assertEquals(actual.getWorkspaceId(), "ws1");
assertTrue(actual.isWorkspaceTemporary());
User actualUser = actual.getUser();
Expand All @@ -45,7 +45,6 @@ public void shouldBeAbleToSetEnvContextInSameThread() {
public void shouldNotBeAbleToSeeContextInOtherThread() {
//given
final EnvironmentContext expected = EnvironmentContext.getCurrent();
expected.setAccountId("acc1");
expected.setWorkspaceId("ws1");
expected.setWorkspaceTemporary(true);
expected.setUser(new UserImpl("user", "id", "token", Collections.singleton("role"), false));
Expand All @@ -61,4 +60,4 @@ public void run() {

}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,9 @@ protected void validateProjects(Factory factory) throws BadRequestException {
*/
protected void validateAccountId(Factory factory) throws ServerException, ForbiddenException {
// TODO do we need check if user is temporary?
final String accountId = factory.getCreator() != null ? emptyToNull(factory.getCreator().getAccountId()) : null;
final String userId = factory.getCreator() != null ? factory.getCreator().getUserId() : null;

if (accountId == null || userId == null) {
if (userId == null) {
return;
}

Expand Down

0 comments on commit 87d3a54

Please sign in to comment.