Search in sources :

Example 1 with GetConfigRequest1

use of io.codekvast.javaagent.model.v1.rest.GetConfigRequest1 in project codekvast by crispab.

the class AgentControllerIntegrationTest method should_accept_post_to_agentPollConfig.

@Test
public void should_accept_post_to_agentPollConfig() throws Exception {
    GetConfigRequest1 request = GetConfigRequest1.sample();
    mvc.perform(post(V1_POLL_CONFIG).accept(APPLICATION_JSON_UTF8).contentType(APPLICATION_JSON_UTF8).content(objectMapper.writeValueAsString(request))).andExpect(status().isOk());
}
Also used : GetConfigRequest1(io.codekvast.javaagent.model.v1.rest.GetConfigRequest1) Test(org.junit.Test) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)

Example 2 with GetConfigRequest1

use of io.codekvast.javaagent.model.v1.rest.GetConfigRequest1 in project codekvast by crispab.

the class MariadbIntegrationTest method should_getConfig_for_enabled_agent.

@Test
@Sql(scripts = "/sql/base-data.sql")
public void should_getConfig_for_enabled_agent() {
    // given
    new Timestamps().invoke();
    // when
    GetConfigResponse1 response = agentService.getConfig(GetConfigRequest1.sample().toBuilder().jvmUuid("uuid1").licenseKey("").startedAtMillis(Instant.now().minus(2, HOURS).toEpochMilli()).build());
    // then
    assertConfigPollResponse(response, "enabled=true");
    // Assert all dead agents are marked as disabled as well
    assertAgentEnabled("uuid1", TRUE);
    assertAgentEnabled("uuid2", FALSE);
    assertAgentEnabled("uuid3", FALSE);
    assertAgentEnabled("uuid4", FALSE);
}
Also used : GetConfigResponse1(io.codekvast.javaagent.model.v1.rest.GetConfigResponse1) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Sql(org.springframework.test.context.jdbc.Sql)

Example 3 with GetConfigRequest1

use of io.codekvast.javaagent.model.v1.rest.GetConfigRequest1 in project codekvast by crispab.

the class MariadbIntegrationTest method should_getConfig_for_disabled_agent.

@Test
@Sql(scripts = "/sql/base-data.sql")
public void should_getConfig_for_disabled_agent() {
    // given
    new Timestamps().invoke();
    // when
    GetConfigResponse1 response = agentService.getConfig(GetConfigRequest1.sample().toBuilder().jvmUuid("uuid2").licenseKey("").startedAtMillis(Instant.now().minus(2, HOURS).toEpochMilli()).build());
    // then
    assertConfigPollResponse(response, "enabled=false");
    assertAgentEnabled("uuid1", TRUE);
    assertAgentEnabled("uuid2", FALSE);
    assertAgentEnabled("uuid3", FALSE);
    assertAgentEnabled("uuid4", FALSE);
}
Also used : GetConfigResponse1(io.codekvast.javaagent.model.v1.rest.GetConfigResponse1) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Sql(org.springframework.test.context.jdbc.Sql)

Example 4 with GetConfigRequest1

use of io.codekvast.javaagent.model.v1.rest.GetConfigRequest1 in project codekvast by crispab.

the class AgentController method getConfig1.

@RequestMapping(value = V1_POLL_CONFIG)
public GetConfigResponse1 getConfig1(@Valid @RequestBody GetConfigRequest1 request) {
    logger.debug("Received {}", request);
    GetConfigResponse1 response = agentService.getConfig(request);
    logger.debug("Responds with {}", response);
    return response;
}
Also used : GetConfigResponse1(io.codekvast.javaagent.model.v1.rest.GetConfigResponse1)

Example 5 with GetConfigRequest1

use of io.codekvast.javaagent.model.v1.rest.GetConfigRequest1 in project codekvast by crispab.

the class GetConfigRequest1Test method should_serialize_to_from_json.

@Test
public void should_serialize_to_from_json() {
    GetConfigRequest1 req1 = GetConfigRequest1.sample();
    String json = gson.toJson(req1);
    GetConfigRequest1 req2 = gson.fromJson(json, GetConfigRequest1.class);
    assertThat(req1, is(req2));
}
Also used : GetConfigRequest1(io.codekvast.javaagent.model.v1.rest.GetConfigRequest1) Test(org.junit.Test)

Aggregations

GetConfigRequest1 (io.codekvast.javaagent.model.v1.rest.GetConfigRequest1)5 GetConfigResponse1 (io.codekvast.javaagent.model.v1.rest.GetConfigResponse1)4 Test (org.junit.Test)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 Sql (org.springframework.test.context.jdbc.Sql)3 Test (org.junit.jupiter.api.Test)2 LicenseViolationException (io.codekvast.common.customer.LicenseViolationException)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)1