Search in sources :

Example 21 with ActionMessage

use of com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage in project intellij-redhat-telemetry by redhat-developer.

the class TelemetryMessageBuilderTest method send_should_NOT_set_result_if_result_exists.

@Test
public void send_should_NOT_set_result_if_result_exists() throws InterruptedException {
    // given
    ActionMessage message = builder.action("jolly jumper");
    String result = "spits like a cowboy";
    message.result(result);
    // when
    TelemetryEvent event = message.send();
    // then dont override existing result
    assertThat(event.getProperties().get(PROP_RESULT)).isEqualTo(result);
}
Also used : ActionMessage(com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage) Test(org.junit.jupiter.api.Test)

Example 22 with ActionMessage

use of com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage in project intellij-redhat-telemetry by redhat-developer.

the class TelemetryMessageBuilderTest method error_should_anonymize_email.

@Test
public void error_should_anonymize_email() {
    // given
    ActionMessage message = builder.action("the simpsons");
    String email = "bart@simpsons.com";
    // when
    message.error(email + " caused a nuclear plant emergency");
    // then
    assertThat(message.getError()).doesNotContain(email);
}
Also used : ActionMessage(com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage) Test(org.junit.jupiter.api.Test)

Example 23 with ActionMessage

use of com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage in project intellij-redhat-telemetry by redhat-developer.

the class TelemetryMessageBuilderTest method error_should_anonymize_username.

@Test
public void error_should_anonymize_username() {
    // given
    ActionMessage message = builder.action("the simpsons");
    // when
    String username = AnonymizeUtils.USER_NAME;
    message.error(username + " caused a nuclear plant emergency");
    // then
    assertThat(message.getError()).doesNotContain(username);
}
Also used : ActionMessage(com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage) Test(org.junit.jupiter.api.Test)

Example 24 with ActionMessage

use of com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage in project intellij-redhat-telemetry by redhat-developer.

the class TelemetryMessageBuilderTest method error_should_clear_result.

@Test
public void error_should_clear_result() {
    // given
    ActionMessage message = builder.action("the simpsons").result("went skateboarding");
    // when
    message.error("nuclear plant emergency");
    // then
    assertThat(message.getResult()).isNull();
}
Also used : ActionMessage(com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage) Test(org.junit.jupiter.api.Test)

Example 25 with ActionMessage

use of com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage in project intellij-redhat-telemetry by redhat-developer.

the class TelemetryMessageBuilderTest method finished_should_set_duration_btw_given_start_and_finished_when_finished_is_in_new_year.

@Test
public void finished_should_set_duration_btw_given_start_and_finished_when_finished_is_in_new_year() {
    // given
    ActionMessage message = builder.action("the daltons break out");
    LocalDateTime started = LocalDateTime.of(LocalDate.now(), LocalTime.of(23, 0));
    message.started(started);
    Duration duration = Duration.of(2, ChronoUnit.HOURS).plusDays(356 + 30);
    LocalDateTime stopped = started.plus(duration);
    // when local time is next year
    message.finished(stopped);
    // then
    assertThat(TimeUtils.toDuration(message.getDuration())).isEqualTo(duration);
}
Also used : LocalDateTime(java.time.LocalDateTime) ActionMessage(com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage) Duration(java.time.Duration) Test(org.junit.jupiter.api.Test)

Aggregations

ActionMessage (com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage)39 Test (org.junit.jupiter.api.Test)26 IOException (java.io.IOException)11 ParentableNode (com.redhat.devtools.intellij.tektoncd.tree.ParentableNode)6 Notification (com.intellij.notification.Notification)3 PipelineRunNode (com.redhat.devtools.intellij.tektoncd.tree.PipelineRunNode)3 TaskRunNode (com.redhat.devtools.intellij.tektoncd.tree.TaskRunNode)3 Tkn (com.redhat.devtools.intellij.tektoncd.tkn.Tkn)2 PipelineNode (com.redhat.devtools.intellij.tektoncd.tree.PipelineNode)2 TektonTreeStructure (com.redhat.devtools.intellij.tektoncd.tree.TektonTreeStructure)2 Duration (java.time.Duration)2 LocalDateTime (java.time.LocalDateTime)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 YAMLMapper (com.fasterxml.jackson.dataformat.yaml.YAMLMapper)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 Project (com.intellij.openapi.project.Project)1 Messages (com.intellij.openapi.ui.Messages)1 GenericResource (com.redhat.devtools.intellij.common.model.GenericResource)1 ExecHelper (com.redhat.devtools.intellij.common.utils.ExecHelper)1 UIHelper (com.redhat.devtools.intellij.common.utils.UIHelper)1