Search in sources :

Example 6 with GetConfigRequest1

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

the class ConfigPollerImplTest method should_serialize_deserialize_getConfigRequest1.

@Test
public void should_serialize_deserialize_getConfigRequest1() throws Exception {
    GetConfigRequest1 request1 = GetConfigRequest1.sample();
    String json = gson.toJson(request1);
    assertThat(json, containsString("\"licenseKey\":\"licenseKey\""));
    GetConfigRequest1 fromJson = gson.fromJson(json, GetConfigRequest1.class);
    assertThat(fromJson, is(request1));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) GetConfigRequest1(io.codekvast.javaagent.model.v1.rest.GetConfigRequest1) Test(org.junit.jupiter.api.Test)

Example 7 with GetConfigRequest1

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

the class GetConfigRequest2Test method should_serialize_to_from_json_1.

@Test
public void should_serialize_to_from_json_1() {
    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.jupiter.api.Test)

Example 8 with GetConfigRequest1

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

the class AgentControllerTest method getConfig1_should_reject_invalid_licenseKey.

@Test
public void getConfig1_should_reject_invalid_licenseKey() throws Exception {
    when(agentService.getConfig(any(GetConfigRequest1.class))).thenThrow(new LicenseViolationException("foobar"));
    mockMvc.perform(post(V1_POLL_CONFIG).content(gson.toJson(GetConfigRequest1.sample())).contentType(APPLICATION_JSON_UTF8)).andExpect(status().isForbidden());
}
Also used : LicenseViolationException(io.codekvast.common.customer.LicenseViolationException) GetConfigRequest1(io.codekvast.javaagent.model.v1.rest.GetConfigRequest1) Test(org.junit.Test)

Example 9 with GetConfigRequest1

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

the class IntakeIntegrationTest method should_getConfig_for_enabled_agent_1.

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

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