forked from j62/ctbrec
Add tests for RecordingPreconditions
This commit is contained in:
parent
12899cac4c
commit
a9536a428f
|
@ -11,7 +11,11 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-15"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-15">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
|
|
|
@ -12,5 +12,5 @@ org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
|||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=15
|
||||
|
|
|
@ -6,7 +6,11 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
|
@ -19,5 +23,10 @@
|
|||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding//src/main/java=UTF-8
|
||||
encoding//src/main/resources=UTF-8
|
||||
encoding//src/test/java=UTF-8
|
||||
encoding/<project>=UTF-8
|
||||
|
|
|
@ -70,16 +70,6 @@
|
|||
<version>3.1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
|
|
|
@ -40,6 +40,7 @@ import ctbrec.recorder.postprocessing.Script;
|
|||
import ctbrec.sites.Site;
|
||||
import ctbrec.sites.cam4.Cam4Model;
|
||||
|
||||
// TODO don't use singleton pattern
|
||||
public class Config {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Config.class);
|
||||
|
@ -56,7 +57,7 @@ public class Config {
|
|||
private boolean savingDisabled = false;
|
||||
public static final String RECORDING_DATE_FORMAT = "yyyy-MM-dd_HH-mm-ss_SSS";
|
||||
|
||||
private Config(List<Site> sites) {
|
||||
public Config(List<Site> sites) {
|
||||
this.sites = sites;
|
||||
if(System.getProperty("ctbrec.config.dir") != null) {
|
||||
configDir = new File(System.getProperty("ctbrec.config.dir"));
|
||||
|
|
|
@ -287,7 +287,7 @@ public class NextGenLocalRecorder implements Recorder {
|
|||
return CompletableFuture.runAsync(() -> {
|
||||
recorderLock.lock();
|
||||
try {
|
||||
preconditions.check(model);
|
||||
preconditions.check(model, config);
|
||||
LOG.info("Starting recording for model {}", model.getName());
|
||||
Download download = createDownload(model);
|
||||
Recording rec = createRecording(download);
|
||||
|
|
|
@ -23,14 +23,17 @@ public class RecordingPreconditions {
|
|||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(RecordingPreconditions.class);
|
||||
|
||||
private Config config;
|
||||
private NextGenLocalRecorder recorder;
|
||||
private long lastPreconditionMessage = 0;
|
||||
|
||||
|
||||
RecordingPreconditions(NextGenLocalRecorder recorder) {
|
||||
this.recorder = recorder;
|
||||
}
|
||||
|
||||
void check(Model model) throws IOException, InvalidKeyException, NoSuchAlgorithmException {
|
||||
void check(Model model, Config config) throws IOException, InvalidKeyException, NoSuchAlgorithmException {
|
||||
this.config = config;
|
||||
LOG.debug("Checking preconditions for model {}", model);
|
||||
ensureRecorderIsActive();
|
||||
ensureModelIsNotSuspended(model);
|
||||
|
@ -133,7 +136,7 @@ public class RecordingPreconditions {
|
|||
}
|
||||
|
||||
private boolean downloadSlotAvailable() {
|
||||
int concurrentRecordings = Config.getInstance().getSettings().concurrentRecordings;
|
||||
int concurrentRecordings = config.getSettings().concurrentRecordings;
|
||||
return concurrentRecordings == 0 || concurrentRecordings > 0 && recorder.getRecordingProcesses().size() < concurrentRecordings;
|
||||
}
|
||||
|
||||
|
@ -168,7 +171,7 @@ public class RecordingPreconditions {
|
|||
}
|
||||
|
||||
private Optional<Model> getModelForUrl(String modelUrl) {
|
||||
return Config.getInstance().getSettings().models.stream()
|
||||
return config.getSettings().models.stream()
|
||||
.filter(m -> Objects.equals(m.getUrl(), modelUrl))
|
||||
.findFirst();
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import okhttp3.Response;
|
|||
public class XloveCamHttpClient extends HttpClient {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(XloveCamHttpClient.class);
|
||||
private static final Pattern CSRF_PATTERN = Pattern.compile("CSRFToken\s*=\s*\"(.*?)\";");
|
||||
private static final Pattern CSRF_PATTERN = Pattern.compile("CSRFToken\\s*=\\s*\"(.*?)\";");
|
||||
private final Random rng = new Random();
|
||||
|
||||
public XloveCamHttpClient() {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package ctbrec;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class VersionTest {
|
||||
class VersionTest {
|
||||
@Test
|
||||
public void testOf() {
|
||||
void testOf() {
|
||||
Version v = Version.of("1.0.0");
|
||||
assertEquals(1, v.major);
|
||||
assertEquals(0, v.minor);
|
||||
|
@ -25,7 +25,7 @@ public class VersionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCompareTo() {
|
||||
void testCompareTo() {
|
||||
Version a = Version.of("1.0.0");
|
||||
Version b = Version.of("1.0.0");
|
||||
assertEquals(0, a.compareTo(b));
|
||||
|
|
|
@ -0,0 +1,331 @@
|
|||
package ctbrec.recorder;
|
||||
|
||||
import static java.time.temporal.ChronoUnit.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.MockedStatic;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.Model;
|
||||
import ctbrec.ModelGroup;
|
||||
import ctbrec.Recording;
|
||||
import ctbrec.Settings;
|
||||
import ctbrec.recorder.download.Download;
|
||||
|
||||
class RecordingPreconditionsTest {
|
||||
|
||||
private Config config;
|
||||
private Settings settings = new Settings();
|
||||
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
config = mock(Config.class);
|
||||
when(config.getSettings()).thenReturn(settings);
|
||||
try (MockedStatic<Config> staticConfigMock = mockStatic(Config.class)) {
|
||||
staticConfigMock.when(Config::getInstance).thenReturn(config);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRecorderNotInRecordingMode() throws InvalidKeyException, NoSuchAlgorithmException, IOException {
|
||||
NextGenLocalRecorder recorder = mock(NextGenLocalRecorder.class);
|
||||
Model model = mock(Model.class);
|
||||
|
||||
RecordingPreconditions preconditions = new RecordingPreconditions(recorder);
|
||||
PreconditionNotMetException ex = assertThrows(PreconditionNotMetException.class, () -> preconditions.check(model, config));
|
||||
assertEquals("Recorder is not in recording mode", ex.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testModelIsSuspended() throws InvalidKeyException, NoSuchAlgorithmException, IOException {
|
||||
NextGenLocalRecorder recorder = mock(NextGenLocalRecorder.class);
|
||||
Model model = mock(Model.class);
|
||||
|
||||
when(recorder.isRecording()).thenReturn(true);
|
||||
when(model.isSuspended()).thenReturn(true);
|
||||
when(model.toString()).thenReturn("Mockita Boobilicious");
|
||||
|
||||
RecordingPreconditions preconditions = new RecordingPreconditions(recorder);
|
||||
PreconditionNotMetException ex = assertThrows(PreconditionNotMetException.class, () -> preconditions.check(model, config));
|
||||
assertEquals("Recording for model Mockita Boobilicious is suspended", ex.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testModelMarkedForLaterRecording() throws InvalidKeyException, NoSuchAlgorithmException, IOException {
|
||||
NextGenLocalRecorder recorder = mock(NextGenLocalRecorder.class);
|
||||
Model model = mock(Model.class);
|
||||
|
||||
when(recorder.isRecording()).thenReturn(true);
|
||||
when(model.isMarkedForLaterRecording()).thenReturn(true);
|
||||
when(model.toString()).thenReturn("Mockita Boobilicious");
|
||||
|
||||
RecordingPreconditions preconditions = new RecordingPreconditions(recorder);
|
||||
PreconditionNotMetException ex = assertThrows(PreconditionNotMetException.class, () -> preconditions.check(model, config));
|
||||
assertEquals("Model Mockita Boobilicious is marked for later recording", ex.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRecordUntil() throws InvalidKeyException, NoSuchAlgorithmException, IOException {
|
||||
NextGenLocalRecorder recorder = mock(NextGenLocalRecorder.class);
|
||||
Model model = mock(Model.class);
|
||||
|
||||
when(recorder.isRecording()).thenReturn(true);
|
||||
when(model.getRecordUntil()).thenReturn(Instant.now().minus(1, HOURS));
|
||||
when(model.toString()).thenReturn("Mockita Boobilicious");
|
||||
|
||||
RecordingPreconditions preconditions = new RecordingPreconditions(recorder);
|
||||
PreconditionNotMetException ex = assertThrows(PreconditionNotMetException.class, () -> preconditions.check(model, config));
|
||||
assertTrue(ex.getMessage().contains("Recording expired at "));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRecordingAlreadyRunning() throws InvalidKeyException, NoSuchAlgorithmException, IOException {
|
||||
NextGenLocalRecorder recorder = mock(NextGenLocalRecorder.class);
|
||||
Model model = mock(Model.class);
|
||||
|
||||
when(recorder.isRecording()).thenReturn(true);
|
||||
Map<Model, Recording> recordingProcesses = new HashMap<>();
|
||||
recordingProcesses.put(model, new Recording());
|
||||
when(recorder.getRecordingProcesses()).thenReturn(recordingProcesses);
|
||||
when(model.getRecordUntil()).thenReturn(Instant.MAX);
|
||||
when(model.toString()).thenReturn("Mockita Boobilicious");
|
||||
|
||||
RecordingPreconditions preconditions = new RecordingPreconditions(recorder);
|
||||
PreconditionNotMetException ex = assertThrows(PreconditionNotMetException.class, () -> preconditions.check(model, config));
|
||||
assertEquals("A recording for model Mockita Boobilicious is already running", ex.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testModelShouldBeRecorded() throws InvalidKeyException, NoSuchAlgorithmException, IOException, ExecutionException, InterruptedException {
|
||||
NextGenLocalRecorder recorder = mock(NextGenLocalRecorder.class);
|
||||
Model model = mock(Model.class);
|
||||
|
||||
when(recorder.isRecording()).thenReturn(true);
|
||||
List<Model> modelsToRecord = new LinkedList<>();
|
||||
when(recorder.getModels()).thenReturn(modelsToRecord);
|
||||
when(model.getRecordUntil()).thenReturn(Instant.MAX);
|
||||
when(model.toString()).thenReturn("Mockita Boobilicious");
|
||||
when(model.isOnline(true)).thenReturn(true);
|
||||
|
||||
RecordingPreconditions preconditions = new RecordingPreconditions(recorder);
|
||||
PreconditionNotMetException ex = assertThrows(PreconditionNotMetException.class, () -> preconditions.check(model, config));
|
||||
assertEquals("Model Mockita Boobilicious has been removed. Restarting of recording cancelled.", ex.getMessage());
|
||||
|
||||
modelsToRecord.add(model);
|
||||
reset(recorder);
|
||||
when(recorder.isRecording()).thenReturn(true);
|
||||
when(recorder.getModels()).thenReturn(modelsToRecord);
|
||||
when(recorder.enoughSpaceForRecording()).thenReturn(true);
|
||||
assertDoesNotThrow(() -> preconditions.check(model, config));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEnoughSpace() throws InvalidKeyException, NoSuchAlgorithmException, IOException, ExecutionException, InterruptedException {
|
||||
Model model = mock(Model.class);
|
||||
when(model.getRecordUntil()).thenReturn(Instant.MAX);
|
||||
when(model.toString()).thenReturn("Mockita Boobilicious");
|
||||
when(model.isOnline(true)).thenReturn(true);
|
||||
|
||||
NextGenLocalRecorder recorder = mock(NextGenLocalRecorder.class);
|
||||
List<Model> modelsToRecord = new LinkedList<>();
|
||||
modelsToRecord.add(model);
|
||||
when(recorder.isRecording()).thenReturn(true);
|
||||
when(recorder.getModels()).thenReturn(modelsToRecord);
|
||||
when(recorder.enoughSpaceForRecording()).thenReturn(false);
|
||||
|
||||
RecordingPreconditions preconditions = new RecordingPreconditions(recorder);
|
||||
PreconditionNotMetException ex = assertThrows(PreconditionNotMetException.class, () -> preconditions.check(model, config));
|
||||
assertEquals("Not enough disk space for recording", ex.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNoOtherFromGroupIsRecording() throws InvalidKeyException, NoSuchAlgorithmException, IOException, ExecutionException, InterruptedException {
|
||||
Model mockita = mock(Model.class);
|
||||
when(mockita.getRecordUntil()).thenReturn(Instant.MAX);
|
||||
when(mockita.toString()).thenReturn("Mockita Boobilicious");
|
||||
when(mockita.isOnline(true)).thenReturn(true);
|
||||
when(mockita.getUrl()).thenReturn("http://localhost/mockita");
|
||||
|
||||
Model theOtherOne = mock(Model.class);
|
||||
when(theOtherOne.getRecordUntil()).thenReturn(Instant.MAX);
|
||||
when(theOtherOne.toString()).thenReturn("The Other One");
|
||||
when(theOtherOne.isOnline(true)).thenReturn(true);
|
||||
when(theOtherOne.getUrl()).thenReturn("http://localhost/theOtherOne");
|
||||
|
||||
ModelGroup group = new ModelGroup();
|
||||
group.add(theOtherOne);
|
||||
group.add(mockita);
|
||||
|
||||
NextGenLocalRecorder recorder = mock(NextGenLocalRecorder.class);
|
||||
List<Model> modelsToRecord = new LinkedList<>();
|
||||
settings.models = modelsToRecord;
|
||||
modelsToRecord.add(theOtherOne);
|
||||
modelsToRecord.add(mockita);
|
||||
when(recorder.isRecording()).thenReturn(true);
|
||||
when(recorder.getModels()).thenReturn(modelsToRecord);
|
||||
when(recorder.enoughSpaceForRecording()).thenReturn(true);
|
||||
when(recorder.getModelGroup(theOtherOne)).thenReturn(Optional.of(group));
|
||||
when(recorder.getModelGroup(mockita)).thenReturn(Optional.of(group));
|
||||
Map<Model, Recording> recordingProcesses = new HashMap<>();
|
||||
recordingProcesses.put(theOtherOne, new Recording());
|
||||
when(recorder.getRecordingProcesses()).thenReturn(recordingProcesses);
|
||||
|
||||
|
||||
RecordingPreconditions preconditions = new RecordingPreconditions(recorder);
|
||||
PreconditionNotMetException ex = assertThrows(PreconditionNotMetException.class, () -> preconditions.check(mockita, config));
|
||||
assertEquals("The Other One from the same group is already recorded", ex.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testModelIsOffline() throws InvalidKeyException, NoSuchAlgorithmException, IOException, ExecutionException, InterruptedException {
|
||||
Model mockita = mock(Model.class);
|
||||
when(mockita.getRecordUntil()).thenReturn(Instant.MAX);
|
||||
when(mockita.getName()).thenReturn("Mockita Boobilicious");
|
||||
when(mockita.toString()).thenReturn("Mockita Boobilicious");
|
||||
when(mockita.isOnline(true)).thenReturn(false);
|
||||
|
||||
NextGenLocalRecorder recorder = mock(NextGenLocalRecorder.class);
|
||||
List<Model> modelsToRecord = new LinkedList<>();
|
||||
settings.models = modelsToRecord;
|
||||
modelsToRecord.add(mockita);
|
||||
when(recorder.isRecording()).thenReturn(true);
|
||||
when(recorder.getModels()).thenReturn(modelsToRecord);
|
||||
when(recorder.enoughSpaceForRecording()).thenReturn(true);
|
||||
|
||||
RecordingPreconditions preconditions = new RecordingPreconditions(recorder);
|
||||
PreconditionNotMetException ex = assertThrows(PreconditionNotMetException.class, () -> preconditions.check(mockita, config));
|
||||
assertEquals("Mockita Boobilicious's room is not public", ex.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testModelIsOnlineWithExpection() throws InvalidKeyException, NoSuchAlgorithmException, IOException, ExecutionException, InterruptedException {
|
||||
Model mockita = mock(Model.class);
|
||||
when(mockita.isOnline(true)).thenThrow(new IOException("Service unavailable"));
|
||||
when(mockita.getRecordUntil()).thenReturn(Instant.MAX);
|
||||
when(mockita.getName()).thenReturn("Mockita Boobilicious");
|
||||
|
||||
NextGenLocalRecorder recorder = mock(NextGenLocalRecorder.class);
|
||||
List<Model> modelsToRecord = new LinkedList<>();
|
||||
settings.models = modelsToRecord;
|
||||
modelsToRecord.add(mockita);
|
||||
when(recorder.isRecording()).thenReturn(true);
|
||||
when(recorder.getModels()).thenReturn(modelsToRecord);
|
||||
when(recorder.enoughSpaceForRecording()).thenReturn(true);
|
||||
|
||||
RecordingPreconditions preconditions = new RecordingPreconditions(recorder);
|
||||
PreconditionNotMetException ex = assertThrows(PreconditionNotMetException.class, () -> preconditions.check(mockita, config));
|
||||
assertEquals("Mockita Boobilicious's room is not public", ex.getMessage());
|
||||
|
||||
reset(mockita);
|
||||
when(mockita.isOnline(true)).thenThrow(new InterruptedException());
|
||||
when(mockita.getRecordUntil()).thenReturn(Instant.MAX);
|
||||
when(mockita.getName()).thenReturn("Mockita Boobilicious");
|
||||
ex = assertThrows(PreconditionNotMetException.class, () -> preconditions.check(mockita, config));
|
||||
assertEquals("Mockita Boobilicious's room is not public", ex.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDownloadSlotsExhausted() throws InvalidKeyException, NoSuchAlgorithmException, IOException, ExecutionException, InterruptedException {
|
||||
settings.concurrentRecordings = 1;
|
||||
|
||||
Model mockita = mock(Model.class);
|
||||
when(mockita.isOnline(true)).thenReturn(true);
|
||||
when(mockita.getRecordUntil()).thenReturn(Instant.MAX);
|
||||
when(mockita.getName()).thenReturn("Mockita Boobilicious");
|
||||
|
||||
Model theOtherOne = mock(Model.class);
|
||||
when(theOtherOne.getRecordUntil()).thenReturn(Instant.MAX);
|
||||
when(theOtherOne.toString()).thenReturn("The Other One");
|
||||
when(theOtherOne.isOnline(true)).thenReturn(true);
|
||||
when(theOtherOne.getUrl()).thenReturn("http://localhost/theOtherOne");
|
||||
|
||||
NextGenLocalRecorder recorder = mock(NextGenLocalRecorder.class);
|
||||
List<Model> modelsToRecord = new LinkedList<>();
|
||||
settings.models = modelsToRecord;
|
||||
modelsToRecord.add(mockita);
|
||||
when(recorder.isRecording()).thenReturn(true);
|
||||
when(recorder.getModels()).thenReturn(modelsToRecord);
|
||||
when(recorder.enoughSpaceForRecording()).thenReturn(true);
|
||||
Map<Model, Recording> recordingProcesses = new HashMap<>();
|
||||
recordingProcesses.put(theOtherOne, new Recording());
|
||||
when(recorder.getRecordingProcesses()).thenReturn(recordingProcesses);
|
||||
|
||||
RecordingPreconditions preconditions = new RecordingPreconditions(recorder);
|
||||
PreconditionNotMetException ex = assertThrows(PreconditionNotMetException.class, () -> preconditions.check(mockita, config));
|
||||
assertEquals("Other models have higher prio, not starting recording for Mockita Boobilicious", ex.getMessage());
|
||||
|
||||
settings.concurrentRecordings = -1;
|
||||
ex = assertThrows(PreconditionNotMetException.class, () -> preconditions.check(mockita, config));
|
||||
assertEquals("Other models have higher prio, not starting recording for Mockita Boobilicious", ex.getMessage());
|
||||
|
||||
settings.concurrentRecordings = 0;
|
||||
assertDoesNotThrow(() -> preconditions.check(mockita, config));
|
||||
|
||||
settings.concurrentRecordings = 1;
|
||||
recordingProcesses.clear();
|
||||
assertDoesNotThrow(() -> preconditions.check(mockita, config));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDownloadSlotFreedUp() throws InvalidKeyException, NoSuchAlgorithmException, IOException, ExecutionException, InterruptedException {
|
||||
settings.concurrentRecordings = 1;
|
||||
|
||||
Model mockita = mock(Model.class);
|
||||
when(mockita.isOnline(true)).thenReturn(true);
|
||||
when(mockita.getRecordUntil()).thenReturn(Instant.MAX);
|
||||
when(mockita.getName()).thenReturn("Mockita Boobilicious");
|
||||
when(mockita.getPriority()).thenReturn(100);
|
||||
|
||||
NextGenLocalRecorder recorder = mock(NextGenLocalRecorder.class);
|
||||
List<Model> modelsToRecord = new LinkedList<>();
|
||||
settings.models = modelsToRecord;
|
||||
modelsToRecord.add(mockita);
|
||||
when(recorder.isRecording()).thenReturn(true);
|
||||
when(recorder.getModels()).thenReturn(modelsToRecord);
|
||||
when(recorder.enoughSpaceForRecording()).thenReturn(true);
|
||||
Map<Model, Recording> recordingProcesses = new HashMap<>();
|
||||
when(recorder.getRecordingProcesses()).thenReturn(recordingProcesses);
|
||||
|
||||
Model theOtherOne = mock(Model.class);
|
||||
when(theOtherOne.getRecordUntil()).thenReturn(Instant.MAX);
|
||||
when(theOtherOne.toString()).thenReturn("The Other One");
|
||||
when(theOtherOne.isOnline(true)).thenReturn(true);
|
||||
when(theOtherOne.getUrl()).thenReturn("http://localhost/theOtherOne");
|
||||
when(theOtherOne.getPriority()).thenReturn(50);
|
||||
recordingProcesses.put(theOtherOne, mockRecordingProcess(theOtherOne));
|
||||
|
||||
Model lowestPrio = mock(Model.class);
|
||||
when(lowestPrio.getRecordUntil()).thenReturn(Instant.MAX);
|
||||
when(lowestPrio.toString()).thenReturn("Lowest");
|
||||
when(lowestPrio.isOnline(true)).thenReturn(true);
|
||||
when(lowestPrio.getUrl()).thenReturn("http://localhost/lowest");
|
||||
when(lowestPrio.getPriority()).thenReturn(1);
|
||||
recordingProcesses.put(theOtherOne, mockRecordingProcess(lowestPrio));
|
||||
|
||||
RecordingPreconditions preconditions = new RecordingPreconditions(recorder);
|
||||
assertDoesNotThrow(() -> preconditions.check(mockita, config));
|
||||
verify(recorder).stopRecordingProcess(lowestPrio);
|
||||
}
|
||||
|
||||
private Recording mockRecordingProcess(Model model) {
|
||||
Download download = mock(Download.class);
|
||||
when(download.getModel()).thenReturn(model);
|
||||
Recording runningRecording = mock(Recording.class);
|
||||
when(runningRecording.getDownload()).thenReturn(download);
|
||||
return runningRecording;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package ctbrec.recorder.postprocessing;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
|
@ -10,20 +10,20 @@ import java.time.ZoneOffset;
|
|||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.Recording;
|
||||
|
||||
public class AbstractPlaceholderAwarePostProcessorTest extends AbstractPpTest {
|
||||
class AbstractPlaceholderAwarePostProcessorTest extends AbstractPpTest {
|
||||
|
||||
Recording rec;
|
||||
Config config;
|
||||
Move placeHolderAwarePp;
|
||||
|
||||
@Override
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws IOException {
|
||||
super.setup();
|
||||
rec = new Recording();
|
||||
|
@ -37,7 +37,7 @@ public class AbstractPlaceholderAwarePostProcessorTest extends AbstractPpTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testModelNameReplacement() {
|
||||
void testModelNameReplacement() {
|
||||
String input = "asdf_${modelName}_asdf";
|
||||
assertEquals("asdf_Mockita Boobilicious_asdf", placeHolderAwarePp.fillInPlaceHolders(input, createPostProcessingContext(rec, null, config)));
|
||||
input = "asdf_${modelDisplayName}_asdf";
|
||||
|
@ -47,7 +47,7 @@ public class AbstractPlaceholderAwarePostProcessorTest extends AbstractPpTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSiteNameReplacement() {
|
||||
void testSiteNameReplacement() {
|
||||
String input = "asdf_${siteName}_asdf";
|
||||
assertEquals("asdf_Chaturbate_asdf", placeHolderAwarePp.fillInPlaceHolders(input, createPostProcessingContext(rec, null, config)));
|
||||
input = "asdf_${siteSanitizedName}_asdf";
|
||||
|
@ -55,7 +55,7 @@ public class AbstractPlaceholderAwarePostProcessorTest extends AbstractPpTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testUtcTimeReplacement() {
|
||||
void testUtcTimeReplacement() {
|
||||
// without user defined pattern
|
||||
String date = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss")
|
||||
.withLocale(Locale.US)
|
||||
|
@ -82,7 +82,7 @@ public class AbstractPlaceholderAwarePostProcessorTest extends AbstractPpTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLocalTimeReplacement() {
|
||||
void testLocalTimeReplacement() {
|
||||
String date = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss")
|
||||
.withLocale(Locale.US)
|
||||
.withZone(ZoneId.systemDefault())
|
||||
|
@ -99,44 +99,44 @@ public class AbstractPlaceholderAwarePostProcessorTest extends AbstractPpTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testEpochReplacement() {
|
||||
void testEpochReplacement() {
|
||||
long epoch = now.toEpochMilli() / 1000;
|
||||
String input = "asdf_${epochSecond}_asdf";
|
||||
assertEquals("asdf_" + epoch + "_asdf", placeHolderAwarePp.fillInPlaceHolders(input, createPostProcessingContext(rec, null, config)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFileSuffixReplacement() {
|
||||
void testFileSuffixReplacement() {
|
||||
String input = "asdf_${fileSuffix}_asdf";
|
||||
assertEquals("asdf_ts_asdf", placeHolderAwarePp.fillInPlaceHolders(input, createPostProcessingContext(rec, null, config)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRecordingsDirReplacement() {
|
||||
void testRecordingsDirReplacement() {
|
||||
String input = "asdf_${recordingsDir}_asdf";
|
||||
assertEquals("asdf_" + recDir.toString() + "_asdf", placeHolderAwarePp.fillInPlaceHolders(input, createPostProcessingContext(rec, null, config)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAbsolutePathReplacement() {
|
||||
void testAbsolutePathReplacement() {
|
||||
String input = "asdf_${absolutePath}_asdf";
|
||||
assertEquals("asdf_" + postProcessed.getAbsolutePath().toString() + "_asdf", placeHolderAwarePp.fillInPlaceHolders(input, createPostProcessingContext(rec, null, config)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAbsoluteParentPathReplacement() {
|
||||
void testAbsoluteParentPathReplacement() {
|
||||
String input = "asdf_${absoluteParentPath}_asdf";
|
||||
assertEquals("asdf_" + postProcessed.getParentFile().toString() + "_asdf", placeHolderAwarePp.fillInPlaceHolders(input, createPostProcessingContext(rec, null, config)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModelNotesReplacement() {
|
||||
void testModelNotesReplacement() {
|
||||
String input = "asdf_${modelNotes}_asdf";
|
||||
assertEquals("asdf_tag,_foo,_bar_asdf", placeHolderAwarePp.fillInPlaceHolders(input, createPostProcessingContext(rec, null, config)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPlaceholderDefaultValues() throws IOException {
|
||||
void testPlaceholderDefaultValues() throws IOException {
|
||||
String input = "asdf_${modelGroupName?${modelSanitizedName?anonymous}}_asdf";
|
||||
PostProcessingContext ctx = createPostProcessingContext(rec, null, config);
|
||||
ctx.getRecording().getModel().setName(null);
|
||||
|
@ -154,7 +154,7 @@ public class AbstractPlaceholderAwarePostProcessorTest extends AbstractPpTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMissingValueForPlaceholder() throws IOException {
|
||||
void testMissingValueForPlaceholder() throws IOException {
|
||||
String input = "asdf_${modelNotes}_asdf";
|
||||
when(config.getModelNotes(any())).thenReturn(null);
|
||||
assertEquals("asdf__asdf", placeHolderAwarePp.fillInPlaceHolders(input, createPostProcessingContext(rec, null, config)));
|
||||
|
|
|
@ -12,8 +12,8 @@ import java.nio.file.Path;
|
|||
import java.time.Instant;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.mockito.MockedStatic;
|
||||
|
||||
import ctbrec.Config;
|
||||
|
@ -37,7 +37,7 @@ public abstract class AbstractPpTest {
|
|||
|
||||
MockedStatic<Config> configStatic;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws IOException {
|
||||
baseDir = Files.createTempDirectory("ctbrec_test_");
|
||||
recDir = baseDir.resolve("recordings");
|
||||
|
@ -52,7 +52,7 @@ public abstract class AbstractPpTest {
|
|||
FileUtils.touch(new File(originalDir, "playlist.m3u8"));
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void teardown() throws IOException {
|
||||
FileUtils.deleteDirectory(baseDir.toFile());
|
||||
if (configStatic != null) {
|
||||
|
@ -63,7 +63,8 @@ public abstract class AbstractPpTest {
|
|||
|
||||
Config mockConfig() {
|
||||
Config config = mock(Config.class);
|
||||
when(config.getSettings()).thenReturn(mockSettings());
|
||||
Settings settings = mockSettings();
|
||||
when(config.getSettings()).thenReturn(settings);
|
||||
when(config.getModelNotes(any())).thenReturn("tag, foo, bar");
|
||||
when(config.getConfigDir()).thenReturn(new File(baseDir.toFile(), "config"));
|
||||
configStatic = mockStatic(Config.class);
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
package ctbrec.recorder.postprocessing;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.Recording;
|
||||
|
||||
public class CopyTest extends AbstractPpTest {
|
||||
class CopyTest extends AbstractPpTest {
|
||||
|
||||
@Test
|
||||
public void testCopySingleFile() throws IOException, InterruptedException {
|
||||
void testCopySingleFile() throws IOException, InterruptedException {
|
||||
Config config = mockConfig();
|
||||
Recording rec = new Recording();
|
||||
rec.setModel(mockModel());
|
||||
|
@ -28,7 +28,7 @@ public class CopyTest extends AbstractPpTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCopyDirectory() throws IOException, InterruptedException {
|
||||
void testCopyDirectory() throws IOException, InterruptedException {
|
||||
Config config = mockConfig();
|
||||
Recording rec = new Recording();
|
||||
rec.setModel(mockModel());
|
||||
|
@ -44,7 +44,7 @@ public class CopyTest extends AbstractPpTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testGetName() {
|
||||
void testGetName() {
|
||||
assertEquals("create a copy", new Copy().getName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
package ctbrec.recorder.postprocessing;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.Recording;
|
||||
|
||||
public class DeleteOriginalTest extends AbstractPpTest {
|
||||
class DeleteOriginalTest extends AbstractPpTest {
|
||||
|
||||
@Test
|
||||
public void testPostProcessWithSingleFile() throws IOException, InterruptedException {
|
||||
void testPostProcessWithSingleFile() throws IOException, InterruptedException {
|
||||
Recording rec = new Recording();
|
||||
rec.setModel(mockModel());
|
||||
rec.setAbsoluteFile(original);
|
||||
|
@ -31,7 +31,7 @@ public class DeleteOriginalTest extends AbstractPpTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testPostProcessWithDirectory() throws IOException, InterruptedException {
|
||||
void testPostProcessWithDirectory() throws IOException, InterruptedException {
|
||||
Recording rec = new Recording();
|
||||
rec.setModel(mockModel());
|
||||
rec.setAbsoluteFile(originalDir);
|
||||
|
@ -50,7 +50,7 @@ public class DeleteOriginalTest extends AbstractPpTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testGetName() {
|
||||
void testGetName() {
|
||||
assertEquals("delete original", new DeleteOriginal().getName());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package ctbrec.recorder.postprocessing;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
|
@ -9,7 +9,7 @@ import java.io.IOException;
|
|||
import java.time.Duration;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.MockedStatic;
|
||||
|
||||
import ctbrec.Config;
|
||||
|
@ -18,15 +18,15 @@ import ctbrec.recorder.RecordingManager;
|
|||
import ctbrec.recorder.download.Download;
|
||||
import ctbrec.recorder.download.VideoLengthDetector;
|
||||
|
||||
public class DeleteTooShortTest extends AbstractPpTest {
|
||||
class DeleteTooShortTest extends AbstractPpTest {
|
||||
|
||||
@Test
|
||||
public void tooShortSingleFileRecShouldBeDeleted() throws IOException, InterruptedException {
|
||||
void tooShortSingleFileRecShouldBeDeleted() throws IOException, InterruptedException {
|
||||
testProcess(original);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tooShortDirectoryRecShouldBeDeleted() throws IOException, InterruptedException {
|
||||
void tooShortDirectoryRecShouldBeDeleted() throws IOException, InterruptedException {
|
||||
testProcess(originalDir);
|
||||
}
|
||||
|
||||
|
@ -52,12 +52,12 @@ public class DeleteTooShortTest extends AbstractPpTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testGetName() {
|
||||
void testGetName() {
|
||||
assertEquals("delete too short", new DeleteTooShort().getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDisabledWithSingleFile() throws IOException, InterruptedException {
|
||||
void testDisabledWithSingleFile() throws IOException, InterruptedException {
|
||||
Recording rec = createRec(original);
|
||||
Config config = mockConfig();
|
||||
RecordingManager recordingManager = new RecordingManager(config, Collections.emptyList());
|
||||
|
@ -74,7 +74,7 @@ public class DeleteTooShortTest extends AbstractPpTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void longEnoughVideoShouldStay() throws IOException, InterruptedException {
|
||||
void longEnoughVideoShouldStay() throws IOException, InterruptedException {
|
||||
Recording rec = createRec(original);
|
||||
Config config = mockConfig();
|
||||
RecordingManager recordingManager = new RecordingManager(config, Collections.emptyList());
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package ctbrec.recorder.postprocessing;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
|
@ -10,16 +10,16 @@ import java.nio.file.Files;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.Model;
|
||||
import ctbrec.Recording;
|
||||
|
||||
public class MoveDirectoryTest extends AbstractPpTest {
|
||||
class MoveDirectoryTest extends AbstractPpTest {
|
||||
|
||||
@Test
|
||||
public void testOriginalFileReplacement() throws IOException {
|
||||
void testOriginalFileReplacement() throws IOException {
|
||||
Config config = mockConfig();
|
||||
Recording rec = new Recording();
|
||||
rec.setModel(mockModel());
|
||||
|
@ -37,7 +37,7 @@ public class MoveDirectoryTest extends AbstractPpTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void absoluteFileShouldKeepBeingOriginalIfFilesDiffer() throws IOException {
|
||||
void absoluteFileShouldKeepBeingOriginalIfFilesDiffer() throws IOException {
|
||||
Model model = mockModel();
|
||||
Recording rec = mock(Recording.class);
|
||||
when(rec.getModel()).thenReturn(model);
|
||||
|
@ -50,6 +50,6 @@ public class MoveDirectoryTest extends AbstractPpTest {
|
|||
Move pp = new Move();
|
||||
Config config = mockConfig();
|
||||
pp.getConfig().put(Move.PATH_TEMPLATE, new File(baseDir.toFile(), Move.DEFAULT).getAbsolutePath());
|
||||
pp.postprocess(createPostProcessingContext(rec, recordingManager, config));
|
||||
assertDoesNotThrow(() -> pp.postprocess(createPostProcessingContext(rec, recordingManager, config)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package ctbrec.recorder.postprocessing;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
|
@ -9,16 +9,16 @@ import java.io.IOException;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.Model;
|
||||
import ctbrec.Recording;
|
||||
|
||||
public class MoveSingleFileTest extends AbstractPpTest {
|
||||
class MoveSingleFileTest extends AbstractPpTest {
|
||||
|
||||
@Test
|
||||
public void testOriginalFileReplacement() throws IOException {
|
||||
void testOriginalFileReplacement() throws IOException {
|
||||
Config config = mockConfig();
|
||||
Recording rec = new Recording();
|
||||
rec.setModel(mockModel());
|
||||
|
@ -37,7 +37,7 @@ public class MoveSingleFileTest extends AbstractPpTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testEarlyExit() throws IOException {
|
||||
void testEarlyExit() throws IOException {
|
||||
Model model = mockModel();
|
||||
Recording rec = mock(Recording.class);
|
||||
when(rec.getModel()).thenReturn(model);
|
||||
|
@ -52,7 +52,7 @@ public class MoveSingleFileTest extends AbstractPpTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void absoluteFileShouldKeepBeingOriginalIfFilesDiffer() throws IOException {
|
||||
void absoluteFileShouldKeepBeingOriginalIfFilesDiffer() throws IOException {
|
||||
Model model = mockModel();
|
||||
Recording rec = mock(Recording.class);
|
||||
when(rec.getModel()).thenReturn(model);
|
||||
|
@ -67,7 +67,7 @@ public class MoveSingleFileTest extends AbstractPpTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
void testToString() {
|
||||
Move pp = new Move();
|
||||
assertEquals("move", pp.toString());
|
||||
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
package ctbrec.recorder.postprocessing;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.Recording;
|
||||
import ctbrec.recorder.RecordingManager;
|
||||
|
||||
public class RemoveKeepFileTest extends AbstractPpTest {
|
||||
class RemoveKeepFileTest extends AbstractPpTest {
|
||||
|
||||
@Test
|
||||
public void testPostProcessWithSingleFile() throws IOException, InterruptedException {
|
||||
void testPostProcessWithSingleFile() throws IOException, InterruptedException {
|
||||
Recording rec = new Recording();
|
||||
rec.setModel(mockModel());
|
||||
rec.setAbsoluteFile(original);
|
||||
|
@ -35,7 +35,7 @@ public class RemoveKeepFileTest extends AbstractPpTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testGetName() {
|
||||
void testGetName() {
|
||||
assertEquals("remove recording, but keep the files", new RemoveKeepFile().getName());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package ctbrec.recorder.postprocessing;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
|
@ -9,16 +9,16 @@ import java.nio.file.Files;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.Model;
|
||||
import ctbrec.Recording;
|
||||
|
||||
public class RenameDirectoryTest extends AbstractPpTest {
|
||||
class RenameDirectoryTest extends AbstractPpTest {
|
||||
|
||||
@Test
|
||||
public void testOriginalFileReplacement() throws IOException {
|
||||
void testOriginalFileReplacement() throws IOException {
|
||||
Config config = mockConfig();
|
||||
Recording rec = new Recording();
|
||||
rec.setModel(mockModel());
|
||||
|
@ -35,7 +35,7 @@ public class RenameDirectoryTest extends AbstractPpTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void absoluteFileShouldKeepBeingOriginalIfFilesDiffer() throws IOException {
|
||||
void absoluteFileShouldKeepBeingOriginalIfFilesDiffer() throws IOException {
|
||||
Config config = mockConfig();
|
||||
Model model = mockModel();
|
||||
Recording rec = mock(Recording.class);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package ctbrec.recorder.postprocessing;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
|
@ -8,16 +8,16 @@ import java.io.IOException;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.Model;
|
||||
import ctbrec.Recording;
|
||||
|
||||
public class RenameSingleFileTest extends AbstractPpTest {
|
||||
class RenameSingleFileTest extends AbstractPpTest {
|
||||
|
||||
@Test
|
||||
public void testOriginalFileReplacement() throws IOException {
|
||||
void testOriginalFileReplacement() throws IOException {
|
||||
Config config = mockConfig();
|
||||
Recording rec = new Recording();
|
||||
rec.setModel(mockModel());
|
||||
|
@ -34,7 +34,7 @@ public class RenameSingleFileTest extends AbstractPpTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testEarlyExit() throws IOException {
|
||||
void testEarlyExit() throws IOException {
|
||||
Config config = mockConfig();
|
||||
Model model = mockModel();
|
||||
Recording rec = mock(Recording.class);
|
||||
|
@ -49,7 +49,7 @@ public class RenameSingleFileTest extends AbstractPpTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void absoluteFileShouldKeepBeingOriginalIfFilesDiffer() throws IOException {
|
||||
void absoluteFileShouldKeepBeingOriginalIfFilesDiffer() throws IOException {
|
||||
Config config = mockConfig();
|
||||
Model model = mockModel();
|
||||
Recording rec = mock(Recording.class);
|
||||
|
@ -63,7 +63,7 @@ public class RenameSingleFileTest extends AbstractPpTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
void testToString() {
|
||||
Rename pp = new Rename();
|
||||
assertEquals("rename", pp.toString());
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package ctbrec.sites.mfc;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import ctbrec.ReflectionUtil;
|
||||
import ctbrec.StringUtil;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>ctbrec</groupId>
|
||||
|
@ -17,6 +17,7 @@
|
|||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<version.javafx>17-ea+9</version.javafx>
|
||||
<version.junit>5.7.2</version.junit>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
|
@ -27,12 +28,12 @@
|
|||
<version>3.1.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
<configuration>
|
||||
<redirectTestOutputToFile>true</redirectTestOutputToFile>
|
||||
</configuration>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
<configuration>
|
||||
<redirectTestOutputToFile>true</redirectTestOutputToFile>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
|
@ -117,15 +118,21 @@
|
|||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>${version.junit}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>${version.junit}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<version>3.5.11</version>
|
||||
<version>3.11.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -145,8 +152,23 @@
|
|||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -1,28 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="test" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
<artifactId>server</artifactId>
|
||||
|
||||
<parent>
|
||||
<groupId>ctbrec</groupId>
|
||||
<artifactId>master</artifactId>
|
||||
<version>4.3.1</version>
|
||||
<relativePath>../master</relativePath>
|
||||
</parent>
|
||||
<groupId>ctbrec</groupId>
|
||||
<artifactId>master</artifactId>
|
||||
<version>4.3.1</version>
|
||||
<relativePath>../master</relativePath>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
|
@ -96,10 +96,5 @@
|
|||
<version>1.2.0</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
Loading…
Reference in New Issue