Renamed properties to attributes in Machine model object (#7687)

CHE-6803 Rename properties to attributes in Machine model object

It also contain removing outdated WsAgentPingRequestFactoryTest
6.19.x
Sergii Leshchenko 2017-12-04 11:25:31 +02:00 committed by GitHub
parent acbbebeb35
commit 760fbea420
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 41 additions and 132 deletions

View File

@ -42,7 +42,7 @@ public interface MachineConfig {
/** Returns environment variables of machine. */
Map<String, String> getEnv();
/** Returns attributes of resources of machine. */
/** Returns attributes of machine. */
Map<String, String> getAttributes();
/** Returns volumes of machine */

View File

@ -19,8 +19,8 @@ import java.util.Map;
*/
public interface Machine {
/** Returns machine specific properties. */
Map<String, String> getProperties();
/** Returns machine specific attributes. */
Map<String, String> getAttributes();
/**
* Returns mapping of exposed ports to {@link Server}.

View File

@ -355,7 +355,7 @@ declare namespace che {
}
export interface IWorkspaceRuntimeMachine {
properties: { [propName: string]: string };
attributes: { [propName: string]: string };
servers: { [serverName: string]: IWorkspaceRuntimeMachineServer };
}

View File

@ -21,13 +21,13 @@ import org.eclipse.che.api.core.model.workspace.runtime.Server;
public class MachineImpl implements Machine {
private String name;
private Map<String, String> properties;
private Map<String, String> attributes;
private Map<String, ServerImpl> servers;
public MachineImpl(
String name, Map<String, String> properties, Map<String, ? extends Server> servers) {
String name, Map<String, String> attributes, Map<String, ? extends Server> servers) {
this.name = name;
this.properties = new HashMap<>(properties);
this.attributes = new HashMap<>(attributes);
if (servers != null) {
this.servers =
servers
@ -42,7 +42,7 @@ public class MachineImpl implements Machine {
}
public MachineImpl(String name, Machine machine) {
this(name, machine.getProperties(), machine.getServers());
this(name, machine.getAttributes(), machine.getServers());
}
public String getName() {
@ -50,11 +50,11 @@ public class MachineImpl implements Machine {
}
@Override
public Map<String, String> getProperties() {
if (properties == null) {
properties = new HashMap<>();
public Map<String, String> getAttributes() {
if (attributes == null) {
attributes = new HashMap<>();
}
return properties;
return attributes;
}
@Override
@ -74,17 +74,17 @@ public class MachineImpl implements Machine {
if (this == o) return true;
if (!(o instanceof MachineImpl)) return false;
MachineImpl that = (MachineImpl) o;
return Objects.equals(getProperties(), that.getProperties())
return Objects.equals(getAttributes(), that.getAttributes())
&& Objects.equals(getServers(), that.getServers());
}
@Override
public int hashCode() {
return Objects.hash(getProperties(), getServers());
return Objects.hash(getAttributes(), getServers());
}
@Override
public String toString() {
return "MachineImpl{" + "properties=" + properties + ", servers=" + servers + '}';
return "MachineImpl{" + "attributes=" + attributes + ", servers=" + servers + '}';
}
}

View File

@ -50,7 +50,7 @@ public class RuntimeImpl implements Runtime {
entry ->
new MachineImpl(
entry.getKey(),
entry.getValue().getProperties(),
entry.getValue().getAttributes(),
entry.getValue().getServers())));
}
this.owner = owner;

View File

@ -60,7 +60,7 @@ public class DevMachineHostNameMacro implements Macro {
Optional<MachineImpl> devMachine = wsAgentServerUtil.getWsAgentServerMachine();
if (devMachine.isPresent()) {
String hostName = devMachine.get().getProperties().get("config.hostname");
String hostName = devMachine.get().getAttributes().get("config.hostname");
if (hostName != null) {
value = hostName;

View File

@ -501,7 +501,7 @@ public class ProcessesPanelPresenter extends BasePresenter
// user
final String userName;
String user = machine.get().getProperties().get("config.user");
String user = machine.get().getAttributes().get("config.user");
if (isNullOrEmpty(user)) {
userName = "root";
} else {

View File

@ -70,7 +70,7 @@ public class DockerMachine implements Machine {
}
@Override
public Map<String, String> getProperties() {
public Map<String, String> getAttributes() {
return Collections.emptyMap();
}

View File

@ -62,7 +62,7 @@ public class OpenShiftMachine implements Machine {
}
@Override
public Map<String, String> getProperties() {
public Map<String, String> getAttributes() {
return emptyMap();
}

View File

@ -109,7 +109,7 @@ public class GdbConfigurationPagePresenter
private void setHosts(List<MachineImpl> machines) {
Map<String, String> hosts = new HashMap<>();
for (MachineImpl machine : machines) {
String host = machine.getProperties().get("network.ipAddress");
String host = machine.getAttributes().get("network.ipAddress");
if (host == null) {
continue;
}

View File

@ -94,7 +94,7 @@ public class KeysInjector {
return;
}
final String containerId = machine.getRuntime().getProperties().get("id");
final String containerId = machine.getRuntime().getAttributes().get("id");
StringBuilder command = new StringBuilder("mkdir ~/.ssh/ -p");
for (String publicKey : publicKeys) {
command.append("&& echo '")

View File

@ -74,7 +74,7 @@ public class KeysInjectorTest {
// public void setUp() throws Exception {
// final Map<String, String> metadataProperties = new HashMap<>();
// metadataProperties.put("id", CONTAINER_ID);
// when(machineRuntime.getProperties()).thenReturn(metadataProperties);
// when(machineRuntime.getAttributes()).thenReturn(metadataProperties);
//
// when(environmentEngine.getMachine(WORKSPACE_ID, MACHINE_ID)).thenReturn(instance);
// when(instance.getOwner()).thenReturn(OWNER);

View File

@ -19,9 +19,9 @@ import org.eclipse.che.dto.shared.DTO;
public interface MachineDto extends Machine {
@Override
Map<String, String> getProperties();
Map<String, String> getAttributes();
MachineDto withProperties(Map<String, String> properties);
MachineDto withAttributes(Map<String, String> attributes);
@Override
Map<String, ServerDto> getServers();

View File

@ -279,7 +279,7 @@ public final class DtoConverter {
/** Converts {@link Machine} to {@link MachineDto}. */
public static MachineDto asDto(Machine machine) {
MachineDto machineDto = newDto(MachineDto.class).withProperties(machine.getProperties());
MachineDto machineDto = newDto(MachineDto.class).withAttributes(machine.getAttributes());
if (machine.getServers() != null) {
machineDto.withServers(
machine

View File

@ -23,16 +23,16 @@ import org.eclipse.che.api.core.model.workspace.runtime.Server;
*/
public class MachineImpl implements Machine {
private Map<String, String> properties;
private Map<String, String> attributes;
private Map<String, ServerImpl> servers;
public MachineImpl(Machine machineRuntime) {
this(machineRuntime.getProperties(), machineRuntime.getServers());
this(machineRuntime.getAttributes(), machineRuntime.getServers());
}
public MachineImpl(Map<String, String> properties, Map<String, ? extends Server> servers) {
public MachineImpl(Map<String, String> attributes, Map<String, ? extends Server> servers) {
this(servers);
this.properties = new HashMap<>(properties);
this.attributes = new HashMap<>(attributes);
}
public MachineImpl(Map<String, ? extends Server> servers) {
@ -49,11 +49,11 @@ public class MachineImpl implements Machine {
}
@Override
public Map<String, String> getProperties() {
if (properties == null) {
properties = new HashMap<>();
public Map<String, String> getAttributes() {
if (attributes == null) {
attributes = new HashMap<>();
}
return properties;
return attributes;
}
@Override
@ -69,17 +69,17 @@ public class MachineImpl implements Machine {
if (this == o) return true;
if (!(o instanceof MachineImpl)) return false;
MachineImpl machine = (MachineImpl) o;
return Objects.equals(getProperties(), machine.getProperties())
return Objects.equals(getAttributes(), machine.getAttributes())
&& Objects.equals(getServers(), machine.getServers());
}
@Override
public int hashCode() {
return Objects.hash(getProperties(), getServers());
return Objects.hash(getAttributes(), getServers());
}
@Override
public String toString() {
return "MachineImpl{" + "properties=" + properties + ", servers=" + servers + '}';
return "MachineImpl{" + "attributes=" + attributes + ", servers=" + servers + '}';
}
}

View File

@ -77,7 +77,7 @@ public abstract class InternalRuntime<T extends RuntimeContext> implements Runti
Map.Entry::getKey,
e ->
new MachineImpl(
e.getValue().getProperties(),
e.getValue().getAttributes(),
rewriteExternalServers(e.getValue().getServers()))));
}

View File

@ -1,91 +0,0 @@
/*
* Copyright (c) 2012-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.api.agent.server;
import org.mockito.testng.MockitoTestNGListener;
import org.testng.annotations.Listeners;
@Listeners(value = {MockitoTestNGListener.class})
public class WsAgentPingRequestFactoryTest {
// private final static int WS_AGENT_PING_CONNECTION_TIMEOUT_MS = 20;
// private final static String WS_AGENT_URL_IS_NOT_VALID = "URL of Workspace Agent is
// null or empty.";
// private static final String WS_AGENT_SERVER_NOT_FOUND_ERROR = "Workspace agent server
// not found in dev machine.";
// private final static String WS_AGENT_SERVER_URL = "ws_agent";
//
// @Mock
// private HttpJsonRequestFactory httpJsonRequestFactory;
// @Mock
// private HttpJsonRequest httpJsonRequest;
// @Mock
// private OldMachine devMachine;
// @Mock
// private OldServer server;
// @Mock
// private Machine machineRuntimeInfo;
// @Mock
// private ServerProperties serverProperties;
//
// private Map<String, OldServer> servers = new HashMap<>(1);
//
// private WsAgentPingRequestFactory factory;
//
// @BeforeMethod
// public void setUp() throws Exception {
// factory = new WsAgentPingRequestFactory(httpJsonRequestFactory,
// WS_AGENT_PING_CONNECTION_TIMEOUT_MS);
//
// servers.put(WS_AGENT_SERVER_URL, server);
// servers.put(WS_AGENT_PORT, server);
//
// when(httpJsonRequestFactory.fromUrl(anyString())).thenReturn(httpJsonRequest);
// when(httpJsonRequest.setMethod(HttpMethod.GET)).thenReturn(httpJsonRequest);
// when(server.getProperties()).thenReturn(serverProperties);
// when(serverProperties.getInternalUrl()).thenReturn(WS_AGENT_SERVER_URL);
// when(devMachine.getRuntime()).thenReturn(machineRuntimeInfo);
// doReturn(servers).when(machineRuntimeInfo).getServers();
// }
//
//
// @Test(expectedExceptions = ServerException.class, expectedExceptionsMessageRegExp =
// WS_AGENT_SERVER_NOT_FOUND_ERROR)
// public void throwsServerExceptionWhenWsAgentIsNull() throws Exception {
// servers.clear();
//
// factory.createRequest(devMachine);
// }
//
// @Test(expectedExceptions = ServerException.class, expectedExceptionsMessageRegExp =
// WS_AGENT_URL_IS_NOT_VALID)
// public void throwsServerExceptionWhenWsServerUrlIsNull() throws Exception {
// when(serverProperties.getInternalUrl()).thenReturn(null);
//
// factory.createRequest(devMachine);
// }
//
// @Test(expectedExceptions = ServerException.class, expectedExceptionsMessageRegExp =
// WS_AGENT_URL_IS_NOT_VALID)
// public void throwsServerExceptionWhenWsServerUrlIsEmpty() throws Exception {
// when(serverProperties.getInternalUrl()).thenReturn("");
//
// factory.createRequest(devMachine);
// }
//
// @Test
// public void pingRequestShouldBeCreated() throws Exception {
// factory.createRequest(devMachine);
//
// verify(httpJsonRequestFactory).fromUrl(WS_AGENT_SERVER_URL + '/');
// verify(httpJsonRequest).setMethod(javax.ws.rs.HttpMethod.GET);
// verify(httpJsonRequest).setTimeout(WS_AGENT_PING_CONNECTION_TIMEOUT_MS);
// }
}

View File

@ -399,7 +399,7 @@ public class InternalRuntimeTest {
assertEquals(actualMachines.size(), expectedMachinesAmount);
assertTrue(actualMachines.containsKey(expectedMachineName));
Machine actualMachine = actualMachines.get(expectedMachineName);
assertEquals(actualMachine.getProperties().size(), expectedMachinePropsSize);
assertEquals(actualMachine.getAttributes().size(), expectedMachinePropsSize);
assertEquals(actualMachine.getServers().size(), expectedMachineServersSize);
assertTrue(actualMachine.getServers().containsKey(expectedServerName));
assertEquals(
@ -419,7 +419,7 @@ public class InternalRuntimeTest {
originInternalMachines.put("newM", createMachine());
MachineImpl originMachine = originInternalMachines.get(machineToModify);
// change properties of origin server
originMachine.getProperties().put("new_prop", "new_value");
originMachine.getAttributes().put("new_prop", "new_value");
// add new server in origin machine
originMachine.getServers().put("newS", createServer(RUNNING));
ServerImpl originServer = originMachine.getServers().get(serverToModify);
@ -445,7 +445,7 @@ public class InternalRuntimeTest {
machine1.getServers().put(badServerName, failingRewritingServer);
internalMachines.put("m1", machine1);
internalMachines.put("m2", machine2);
expectedMachines.put("m1", new MachineImpl(machine1.getProperties(), expectedServers));
expectedMachines.put("m1", new MachineImpl(machine1.getAttributes(), expectedServers));
expectedMachines.put("m2", machine2);
List<WarningImpl> expectedWarnings = new ArrayList<>();
expectedWarnings.add(