Skip to content

Commit

Permalink
Remove WsAgent specific classes from che-core-workspace-api (#14528)
Browse files Browse the repository at this point in the history
Signed-off-by: Sergii Leshchenko <sleshche@redhat.com>
  • Loading branch information
sleshchenko authored and musienko-maxim committed Sep 17, 2019
1 parent c5d16fe commit 6a4b1c4
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import org.eclipse.che.api.workspace.server.spi.provision.InstallerConfigProvisioner;
import org.eclipse.che.api.workspace.server.spi.provision.InternalEnvironmentProvisioner;
import org.eclipse.che.api.workspace.server.spi.provision.MachineNameProvisioner;
import org.eclipse.che.api.workspace.server.spi.provision.ProjectsVolumeForWsAgentProvisioner;
import org.eclipse.che.api.workspace.server.spi.provision.env.AgentAuthEnableEnvVarProvider;
import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiEnvVarProvider;
import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiExternalEnvVarProvider;
Expand Down Expand Up @@ -164,7 +163,6 @@ protected void configure() {
internalEnvironmentProvisioners.addBinding().to(InstallerConfigProvisioner.class);
internalEnvironmentProvisioners.addBinding().to(EnvVarEnvironmentProvisioner.class);
internalEnvironmentProvisioners.addBinding().to(LegacyEnvVarEnvironmentProvisioner.class);
internalEnvironmentProvisioners.addBinding().to(ProjectsVolumeForWsAgentProvisioner.class);
internalEnvironmentProvisioners.addBinding().to(MachineNameProvisioner.class);

Multibinder<EnvVarProvider> envVarProviders =
Expand Down
9 changes: 4 additions & 5 deletions infrastructures/docker/environment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-workspace</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-workspace-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-annotations</artifactId>
Expand All @@ -84,11 +88,6 @@
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-workspace-shared</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.api.workspace.server;
package org.eclipse.che.workspace.infrastructure.docker.environment;

import static java.lang.String.format;
import static org.eclipse.che.api.workspace.shared.Constants.SERVER_WS_AGENT_HTTP_REFERENCE;

import java.util.List;
import java.util.Map;
Expand All @@ -23,6 +22,7 @@
import org.eclipse.che.api.installer.server.impl.InstallerFqn;
import org.eclipse.che.api.workspace.server.spi.environment.InternalEnvironment;
import org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig;
import org.eclipse.che.api.workspace.shared.Constants;

/**
* Helps to find machine that has WsAgent server or installer.
Expand Down Expand Up @@ -72,7 +72,7 @@ public static Optional<String> getWsAgentServerMachine(InternalEnvironment envir
* @return true when wsagent server is found in provided machine, false otherwise
*/
public static boolean containsWsAgentServer(InternalMachineConfig machineConfig) {
return machineConfig.getServers().keySet().contains(SERVER_WS_AGENT_HTTP_REFERENCE);
return machineConfig.getServers().keySet().contains(Constants.SERVER_WS_AGENT_HTTP_REFERENCE);
}

/**
Expand All @@ -82,7 +82,7 @@ public static boolean containsWsAgentServer(InternalMachineConfig machineConfig)
* @return true when wsagent server is found in provided machine, false otherwise
*/
public static boolean containsWsAgentServer(Machine machine) {
return machine.getServers().keySet().contains(SERVER_WS_AGENT_HTTP_REFERENCE);
return machine.getServers().keySet().contains(Constants.SERVER_WS_AGENT_HTTP_REFERENCE);
}

/**
Expand All @@ -92,7 +92,7 @@ public static boolean containsWsAgentServer(Machine machine) {
* @return true when wsagent server or installer is found in provided machine, false otherwise
*/
public static boolean containsWsAgentServerOrInstaller(InternalMachineConfig machineConfig) {
return machineConfig.getServers().keySet().contains(SERVER_WS_AGENT_HTTP_REFERENCE)
return machineConfig.getServers().keySet().contains(Constants.SERVER_WS_AGENT_HTTP_REFERENCE)
|| InstallerFqn.idInInstallerList(WS_AGENT_INSTALLER, machineConfig.getInstallers());
}

Expand All @@ -103,7 +103,7 @@ public static boolean containsWsAgentServerOrInstaller(InternalMachineConfig mac
* @return true when wsagent server or installer is found in provided machine, false otherwise
*/
public static boolean containsWsAgentServerOrInstaller(MachineConfig machineConfig) {
return machineConfig.getServers().keySet().contains(SERVER_WS_AGENT_HTTP_REFERENCE)
return machineConfig.getServers().keySet().contains(Constants.SERVER_WS_AGENT_HTTP_REFERENCE)
|| InstallerFqn.idInKeyList(WS_AGENT_INSTALLER, machineConfig.getInstallers());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
import java.util.Map;
import org.eclipse.che.api.core.ValidationException;
import org.eclipse.che.api.installer.server.model.impl.InstallerImpl;
import org.eclipse.che.api.workspace.server.WsAgentMachineFinderUtil;
import org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl;
import org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig;
import org.eclipse.che.api.workspace.shared.Constants;
import org.eclipse.che.workspace.infrastructure.docker.environment.WsAgentMachineFinderUtil;
import org.eclipse.che.workspace.infrastructure.docker.environment.compose.model.BuildContext;
import org.eclipse.che.workspace.infrastructure.docker.environment.compose.model.ComposeService;
import org.mockito.Mock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import javax.inject.Inject;
import javax.inject.Singleton;
import org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity;
import org.eclipse.che.api.workspace.server.WsAgentMachineFinderUtil;
import org.eclipse.che.api.workspace.server.spi.InfrastructureException;
import org.eclipse.che.inject.CheBootstrap;
import org.eclipse.che.workspace.infrastructure.docker.environment.WsAgentMachineFinderUtil;
import org.eclipse.che.workspace.infrastructure.docker.local.server.DockerExtConfBindingProvider;
import org.eclipse.che.workspace.infrastructure.docker.model.DockerContainerConfig;
import org.eclipse.che.workspace.infrastructure.docker.model.DockerEnvironment;
Expand Down
8 changes: 4 additions & 4 deletions selenium/che-selenium-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-user-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-workspace</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-workspace-shared</artifactId>
Expand All @@ -99,6 +95,10 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-lang</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.infrastructure.docker</groupId>
<artifactId>docker-environment</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.multiuser</groupId>
<artifactId>che-multiuser-api-organization-shared</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@

import static java.lang.String.format;
import static java.lang.String.valueOf;
import static org.eclipse.che.api.core.model.workspace.WorkspaceStatus.RUNNING;
import static org.eclipse.che.api.core.model.workspace.WorkspaceStatus.STARTING;
import static org.eclipse.che.api.core.model.workspace.WorkspaceStatus.STOPPED;
import static org.eclipse.che.api.core.model.workspace.WorkspaceStatus.STOPPING;
import static org.eclipse.che.api.workspace.server.WsAgentMachineFinderUtil.containsWsAgentServer;
import static org.eclipse.che.workspace.infrastructure.docker.environment.WsAgentMachineFinderUtil.containsWsAgentServer;

import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
import com.google.inject.assistedinject.AssistedInject;
import org.eclipse.che.api.core.model.workspace.Workspace;
import org.eclipse.che.api.core.rest.HttpJsonRequestFactory;
import org.eclipse.che.api.workspace.server.WsAgentMachineFinderUtil;
import org.eclipse.che.api.workspace.shared.dto.EnvironmentDto;
import org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto;
import org.eclipse.che.api.workspace.shared.dto.WorkspaceDto;
import org.eclipse.che.selenium.core.provider.TestApiEndpointUrlProvider;
import org.eclipse.che.selenium.core.requestfactory.TestUserHttpJsonRequestFactoryCreator;
import org.eclipse.che.selenium.core.user.TestUser;
import org.eclipse.che.selenium.core.workspace.MemoryMeasure;
import org.eclipse.che.workspace.infrastructure.docker.environment.WsAgentMachineFinderUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
8 changes: 4 additions & 4 deletions selenium/che-selenium-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-system-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-workspace</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-workspace-shared</artifactId>
Expand All @@ -99,6 +95,10 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-lang</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.infrastructure.docker</groupId>
<artifactId>docker-environment</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.selenium</groupId>
<artifactId>che-selenium-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
*/
package org.eclipse.che.selenium.core.provider;

import static org.eclipse.che.api.workspace.server.WsAgentMachineFinderUtil.containsWsAgentServer;
import static org.eclipse.che.api.workspace.shared.Constants.SERVER_WS_AGENT_HTTP_REFERENCE;
import static org.eclipse.che.workspace.infrastructure.docker.environment.WsAgentMachineFinderUtil.containsWsAgentServer;

import com.google.inject.Inject;
import com.google.inject.Singleton;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,6 @@ private void validateMachine(String machineName, InternalMachineConfig machineCo
}
}

private static void checkArgument(boolean expression, String error) throws ValidationException {
if (!expression) {
throw new ValidationException(error);
}
}

private static void checkArgument(
boolean expression, String errorMessageTemplate, Object... errorMessageParams)
throws ValidationException {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.eclipse.che.api.core.ValidationException;
import org.eclipse.che.api.core.model.workspace.config.ServerConfig;
import org.eclipse.che.api.installer.server.model.impl.InstallerImpl;
import org.eclipse.che.api.workspace.server.WsAgentMachineFinderUtil;
import org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl;
import org.eclipse.che.api.workspace.shared.Constants;
import org.mockito.testng.MockitoTestNGListener;
Expand Down Expand Up @@ -212,18 +211,6 @@ public Object[][] validServerProtocols() {
return new Object[][] {{"a"}, {"http"}, {"tcp"}, {"tcp2"}};
}

@Test
public void shouldPassIfWsAgentServerAndInstallerAreInTheSameMachine() throws Exception {
// given
InternalMachineConfig machine = machineMock();
when(machine.getServers()).thenReturn(createServers(Constants.SERVER_WS_AGENT_HTTP_REFERENCE));
when(machine.getInstallers())
.thenReturn(createInstallers(WsAgentMachineFinderUtil.WS_AGENT_INSTALLER));

// when
machinesValidator.validate(singletonMap(MACHINE_NAME, machine));
}

private static InternalMachineConfig machineMock() {
InternalMachineConfig machineConfig = mock(InternalMachineConfig.class);
when(machineConfig.getServers()).thenReturn(emptyMap());
Expand Down

0 comments on commit 6a4b1c4

Please sign in to comment.