Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
IoannisPanagiotas committed Aug 20, 2024
1 parent 25013be commit 37553d9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,29 @@
package org.neo4j.gds.applications.algorithms.machinery;

import org.junit.jupiter.api.Test;
import org.neo4j.gds.Algorithm;
import org.neo4j.gds.core.utils.progress.tasks.ProgressTracker;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;

class AlgorithmMachineryTest {

@Test
void shouldRunAlgorithm() {
var algorithmMachinery = new AlgorithmMachinery();

var progressTracker = mock(ProgressTracker.class);

var algo = mock(Algorithm.class);
when(algo.compute()).thenReturn("Hello, world!");

var result = algorithmMachinery.runAlgorithmsAndManageProgressTracker(
new RegurgitatingAlgorithm("Hello, world!"),
algo,
progressTracker,
false
);
Expand All @@ -50,8 +57,12 @@ void shouldReleaseProgressTrackerWhenAsked() {
var algorithmMachinery = new AlgorithmMachinery();

var progressTracker = mock(ProgressTracker.class);

var algo = mock(Algorithm.class);
when(algo.compute()).thenReturn("Dodgers win world series!");

var result = algorithmMachinery.runAlgorithmsAndManageProgressTracker(
new RegurgitatingAlgorithm("Dodgers win world series!"),
algo,
progressTracker,
true
);
Expand All @@ -67,9 +78,13 @@ void shouldMarkProgressTracker() {

var progressTracker = mock(ProgressTracker.class);
var exception = new RuntimeException("Whoops!");

var algo = mock(Algorithm.class);
when(algo.compute()).thenThrow(exception);

try {
algorithmMachinery.runAlgorithmsAndManageProgressTracker(
new FailingAlgorithm(exception),
algo,
progressTracker,
false
);
Expand All @@ -87,9 +102,13 @@ void shouldMarkProgressTrackerAndReleaseIt() {

var progressTracker = mock(ProgressTracker.class);
var exception = new RuntimeException("Yeah, no...");

var algo = mock(Algorithm.class);
when(algo.compute()).thenThrow(exception);

try {
algorithmMachinery.runAlgorithmsAndManageProgressTracker(
new FailingAlgorithm(exception),
algo,
progressTracker,
true
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,4 @@
*/
package org.neo4j.gds.applications.algorithms.machinery;

class ExampleResult {
String foo;

int bar;

boolean baz;
}
class ExampleResult {}

This file was deleted.

This file was deleted.

0 comments on commit 37553d9

Please sign in to comment.