Search in sources :

Example 1 with GetConfigResponse1

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

the class AgentServiceImplTest method should_return_enabled_publishers_when_below_agent_limit_no_trial_period.

@Test
public void should_return_enabled_publishers_when_below_agent_limit_no_trial_period() {
    // given
    when(jdbcTemplate.queryForObject(anyString(), eq(Integer.class), anyLong(), any(), anyString())).thenReturn(1);
    // when
    GetConfigResponse1 response = service.getConfig(request);
    // then
    assertThat(response.getCodeBasePublisherName(), is("http"));
    assertThat(response.getCodeBasePublisherConfig(), is("enabled=true"));
    assertThat(response.getInvocationDataPublisherName(), is("http"));
    assertThat(response.getInvocationDataPublisherConfig(), is("enabled=true"));
}
Also used : GetConfigResponse1(io.codekvast.javaagent.model.v1.rest.GetConfigResponse1) Test(org.junit.Test)

Example 2 with GetConfigResponse1

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

the class AgentServiceImplTest method should_return_disabled_publishers_when_below_agent_limit_after_trial_period_has_expired.

@Test
public void should_return_disabled_publishers_when_below_agent_limit_after_trial_period_has_expired() {
    // given
    Instant now = Instant.now();
    setupCustomerData(now.minus(10, DAYS), now.minus(1, DAYS));
    when(jdbcTemplate.queryForObject(anyString(), eq(Integer.class), anyLong(), any(), anyString())).thenReturn(1);
    // when
    GetConfigResponse1 response = service.getConfig(request);
    // then
    assertThat(response.getCodeBasePublisherName(), is("http"));
    assertThat(response.getCodeBasePublisherConfig(), is("enabled=false"));
    assertThat(response.getInvocationDataPublisherName(), is("http"));
    assertThat(response.getInvocationDataPublisherConfig(), is("enabled=false"));
}
Also used : Instant(java.time.Instant) GetConfigResponse1(io.codekvast.javaagent.model.v1.rest.GetConfigResponse1) Test(org.junit.Test)

Example 3 with GetConfigResponse1

use of io.codekvast.javaagent.model.v1.rest.GetConfigResponse1 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 4 with GetConfigResponse1

use of io.codekvast.javaagent.model.v1.rest.GetConfigResponse1 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 5 with GetConfigResponse1

use of io.codekvast.javaagent.model.v1.rest.GetConfigResponse1 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)

Aggregations

GetConfigResponse1 (io.codekvast.javaagent.model.v1.rest.GetConfigResponse1)12 Test (org.junit.Test)6 Test (org.junit.jupiter.api.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 Sql (org.springframework.test.context.jdbc.Sql)3 Instant (java.time.Instant)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1