Search in sources :

Example 6 with ServerConf2

use of org.eclipse.che.api.core.model.workspace.ServerConf2 in project che by eclipse.

the class AgentConfigApplierTest method shouldAddLabels.

@Test
public void shouldAddLabels() throws Exception {
    final ServerConf2 serverConf1 = mock(ServerConf2.class);
    when(serverConf1.getPort()).thenReturn("1111/udp");
    when(serverConf1.getProtocol()).thenReturn("http");
    when(serverConf1.getProperties()).thenReturn(ImmutableMap.of("path", "b"));
    when(sorter.sort(any())).thenReturn(singletonList(AgentKeyImpl.parse("agent1")));
    when(agent1.getServers()).thenAnswer(invocation -> singletonMap("a", serverConf1));
    CheServiceImpl service = new CheServiceImpl();
    agentConfigApplier.apply(new ExtendedMachineImpl(singletonList("agent1"), emptyMap(), emptyMap()), service);
    Map<String, String> labels = service.getLabels();
    assertEquals(labels.size(), 3);
    assertEquals(labels.get("che:server:1111/udp:ref"), "a");
    assertEquals(labels.get("che:server:1111/udp:protocol"), "http");
    assertEquals(labels.get("che:server:1111/udp:path"), "b");
}
Also used : CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) ExtendedMachineImpl(org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl) ServerConf2(org.eclipse.che.api.core.model.workspace.ServerConf2) Test(org.testng.annotations.Test)

Aggregations

ServerConf2 (org.eclipse.che.api.core.model.workspace.ServerConf2)6 Test (org.testng.annotations.Test)3 Map (java.util.Map)2 CheServiceImpl (org.eclipse.che.api.environment.server.model.CheServiceImpl)2 ServerConfImpl (org.eclipse.che.api.machine.server.model.impl.ServerConfImpl)2 ExtendedMachineImpl (org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl)2 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 AgentException (org.eclipse.che.api.agent.server.exception.AgentException)1 AgentImpl (org.eclipse.che.api.agent.shared.model.impl.AgentImpl)1 ServerException (org.eclipse.che.api.core.ServerException)1 Machine (org.eclipse.che.api.core.model.machine.Machine)1 ExtendedMachine (org.eclipse.che.api.core.model.workspace.ExtendedMachine)1 LineConsumer (org.eclipse.che.api.core.util.LineConsumer)1 MachineConfigImpl (org.eclipse.che.api.machine.server.model.impl.MachineConfigImpl)1 Instance (org.eclipse.che.api.machine.server.spi.Instance)1 Matchers.anyString (org.mockito.Matchers.anyString)1