Skip to content

Commit

Permalink
test fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Feb 8, 2022
1 parent 9aeb3c9 commit c1dcf14
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions src/test/java/io/cryostat/recordings/RecordingTargetHelperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,25 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;

import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.stubbing.Answer;
import org.openjdk.jmc.common.unit.IConstrainedMap;
import org.openjdk.jmc.common.unit.IQuantity;
import org.openjdk.jmc.common.unit.QuantityConversionException;
import org.openjdk.jmc.flightrecorder.configuration.events.EventOptionID;
import org.openjdk.jmc.flightrecorder.configuration.recording.RecordingOptionsBuilder;
import org.openjdk.jmc.rjmx.services.jfr.IFlightRecorderService;
import org.openjdk.jmc.rjmx.services.jfr.IRecordingDescriptor;
import org.openjdk.jmc.rjmx.services.jfr.IRecordingDescriptor.RecordingState;

import io.cryostat.core.log.Logger;
import io.cryostat.core.net.JFRConnection;
Expand All @@ -77,18 +89,6 @@
import io.cryostat.net.web.http.HttpMimeType;
import io.cryostat.recordings.RecordingTargetHelper.SnapshotCreationException;

import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.stubbing.Answer;

@ExtendWith(MockitoExtension.class)
public class RecordingTargetHelperTest {
RecordingTargetHelper recordingTargetHelper;
Expand Down Expand Up @@ -516,11 +516,10 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
Mockito.when(connection.getService()).thenReturn(service);
IRecordingDescriptor descriptor = Mockito.mock(IRecordingDescriptor.class);
Mockito.when(descriptor.getName()).thenReturn("someRecording");
Mockito.when(descriptor.getState()).thenReturn(RecordingState.RUNNING);
Mockito.when(service.getAvailableRecordings()).thenReturn(List.of(descriptor));

recordingTargetHelper
.stopRecording(new ConnectionDescriptor("fooTarget"), "someRecording")
.get();
recordingTargetHelper.stopRecording(new ConnectionDescriptor("fooTarget"), "someRecording");

Mockito.verify(service).stop(descriptor);
}
Expand All @@ -541,15 +540,14 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
Mockito.when(connection.getService()).thenReturn(service);
Mockito.when(service.getAvailableRecordings()).thenReturn(List.of());

ExecutionException ee =
RecordingNotFoundException ee =
Assertions.assertThrows(
ExecutionException.class,
RecordingNotFoundException.class,
() ->
recordingTargetHelper
.stopRecording(
new ConnectionDescriptor("fooTarget"),
"someRecording")
.get());
"someRecording"));
MatcherAssert.assertThat(
ee.getCause(), Matchers.instanceOf(RecordingNotFoundException.class));
}
Expand Down

0 comments on commit c1dcf14

Please sign in to comment.