Search in sources :

Example 21 with AgentMetadata

use of com.thoughtworks.go.plugin.access.elastic.models.AgentMetadata in project gocd by gocd.

the class AgentMetadataConverterV4Test method fromDTO_shouldConvertToAgentMetadataFromAgentMetadataDTO.

@Test
public void fromDTO_shouldConvertToAgentMetadataFromAgentMetadataDTO() {
    final AgentMetadataDTO agentMetadataDTO = new AgentMetadataDTO("agent-id", "Idle", "Building", "Enabled");
    final AgentMetadata agentMetadata = new AgentMetadataConverterV4().fromDTO(agentMetadataDTO);
    assertThat(agentMetadata.elasticAgentId(), is("agent-id"));
    assertThat(agentMetadata.agentState(), is("Idle"));
    assertThat(agentMetadata.buildState(), is("Building"));
    assertThat(agentMetadata.configState(), is("Enabled"));
}
Also used : AgentMetadata(com.thoughtworks.go.plugin.access.elastic.models.AgentMetadata) Test(org.junit.jupiter.api.Test)

Example 22 with AgentMetadata

use of com.thoughtworks.go.plugin.access.elastic.models.AgentMetadata in project gocd by gocd.

the class AgentMetadataConverterV5Test method fromDTO_shouldConvertToAgentMetadataFromAgentMetadataDTO.

@Test
public void fromDTO_shouldConvertToAgentMetadataFromAgentMetadataDTO() {
    final com.thoughtworks.go.plugin.access.elastic.v5.AgentMetadataDTO agentMetadataDTO = new com.thoughtworks.go.plugin.access.elastic.v5.AgentMetadataDTO("agent-id", "Idle", "Building", "Enabled");
    final AgentMetadata agentMetadata = new AgentMetadataConverterV5().fromDTO(agentMetadataDTO);
    assertThat(agentMetadata.elasticAgentId(), is("agent-id"));
    assertThat(agentMetadata.agentState(), is("Idle"));
    assertThat(agentMetadata.buildState(), is("Building"));
    assertThat(agentMetadata.configState(), is("Enabled"));
}
Also used : AgentMetadata(com.thoughtworks.go.plugin.access.elastic.models.AgentMetadata) Test(org.junit.jupiter.api.Test)

Example 23 with AgentMetadata

use of com.thoughtworks.go.plugin.access.elastic.models.AgentMetadata in project gocd by gocd.

the class ElasticAgentProcessorConverterV1Test method shouldJsonizeAgentMetadataListConvertAgentMetadataList.

@Test
public void shouldJsonizeAgentMetadataListConvertAgentMetadataList() {
    final List<AgentMetadata> agentMetadataList = Arrays.asList(new AgentMetadata("foo-id", "Idle", "Idle", "Enabled"), new AgentMetadata("bar-id", "Idle", "Building", "Enabled"));
    final String responseBody = elasticAgentProcessorConverterV1.listAgentsResponseBody(agentMetadataList);
    final String expectedStr = "[\n" + "  {\n" + "    \"agent_id\": \"foo-id\",\n" + "    \"agent_state\": \"Idle\",\n" + "    \"build_state\": \"Idle\",\n" + "    \"config_state\": \"Enabled\"\n" + "  },\n" + "  {\n" + "    \"agent_id\": \"bar-id\",\n" + "    \"agent_state\": \"Idle\",\n" + "    \"build_state\": \"Building\",\n" + "    \"config_state\": \"Enabled\"\n" + "  }\n" + "]";
    assertThatJson(expectedStr).isEqualTo(responseBody);
}
Also used : AgentMetadata(com.thoughtworks.go.plugin.access.elastic.models.AgentMetadata) Test(org.junit.jupiter.api.Test)

Aggregations

AgentMetadata (com.thoughtworks.go.plugin.access.elastic.models.AgentMetadata)23 Test (org.junit.Test)12 Test (org.junit.jupiter.api.Test)10 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)7 AgentConfig (com.thoughtworks.go.config.AgentConfig)2 AgentInstance (com.thoughtworks.go.domain.AgentInstance)2 DefaultGoApiRequest (com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest)2 ElasticAgentMetadata (com.thoughtworks.go.server.domain.ElasticAgentMetadata)2