-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TaskContext to tasks to be track e2e instant transfer information (…
- Loading branch information
1 parent
0864b81
commit fc9c7d1
Showing
19 changed files
with
404 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
version=1.42.0 | ||
version=1.43.0 | ||
org.gradle.internal.http.socketTimeout=120000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
integration-tests/src/test/java/com/transferwise/tasks/testapp/TaskInterceptionIntTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.transferwise.tasks.testapp; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import com.transferwise.common.baseutils.UuidUtils; | ||
import com.transferwise.tasks.BaseIntTest; | ||
import com.transferwise.tasks.ITasksService.AddTaskRequest; | ||
import com.transferwise.tasks.TasksService; | ||
import org.awaitility.Awaitility; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
public class TaskInterceptionIntTest extends BaseIntTest { | ||
|
||
@Autowired | ||
private TasksService tasksService; | ||
|
||
@Test | ||
void jambiTaskIsInterceptedCorrectly() { | ||
testTasksService.resetAndDeleteTasksWithTypes("test"); | ||
tasksService.addTask(new AddTaskRequest().setTaskId(UuidUtils.generatePrefixCombUuid()).setType("test").setSubType("Jambi")); | ||
tasksService.addTask(new AddTaskRequest().setTaskId(UuidUtils.generatePrefixCombUuid()).setType("test").setSubType("Jambi")); | ||
Awaitility.await().until(() -> testTasksService.getFinishedTasks("test", "Jambi").size() == 2); | ||
assertEquals(2, meterRegistry.counter("tool", "song", "eulogy").count()); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...on-tests/src/test/java/com/transferwise/tasks/testapp/testbeans/JambiTaskInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.transferwise.tasks.testapp.testbeans; | ||
|
||
import com.transferwise.tasks.domain.Task; | ||
import com.transferwise.tasks.processing.ITaskProcessingInterceptor; | ||
import io.micrometer.core.instrument.MeterRegistry; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class JambiTaskInterceptor implements ITaskProcessingInterceptor { | ||
|
||
private final MeterRegistry meterRegistry; | ||
|
||
@Override | ||
public void doProcess(Task task, Runnable processor) { | ||
if ("Jambi".equals(task.getSubType())) { | ||
if (task.getTaskContext() != null) { | ||
var name = task.getTaskContext().get("adam-jones", String.class); | ||
meterRegistry.counter("tool", "song", name).increment(); | ||
} | ||
} | ||
processor.run(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...rc/test/java/com/transferwise/tasks/testapp/testbeans/JambiTaskRegistrationDecorator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.transferwise.tasks.testapp.testbeans; | ||
|
||
import com.transferwise.tasks.ITasksService.AddTaskRequest; | ||
import com.transferwise.tasks.domain.TaskContext; | ||
import com.transferwise.tasks.processing.ITaskRegistrationDecorator; | ||
import java.util.Map; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class JambiTaskRegistrationDecorator implements ITaskRegistrationDecorator { | ||
|
||
@Override | ||
public AddTaskRequest decorate(AddTaskRequest request) { | ||
if ("Jambi".equals(request.getSubType())) { | ||
return request.setTaskContext(new TaskContext().setContextMap(Map.of("adam-jones", "eulogy"))); | ||
} | ||
return request; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.