Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<maven-javadoc-plugin.version>3.4.1</maven-javadoc-plugin.version>
<maven-resources-plugin.version>3.3.0</maven-resources-plugin.version>
<maven-source-plugin.version>3.2.1</maven-source-plugin.version>
<maven-surefire-plugin.version>3.0.0-M7</maven-surefire-plugin.version>
<maven-surefire-plugin.version>3.1.2</maven-surefire-plugin.version>
<mockito.version>5.19.0</mockito.version>
<nexus-staging-maven-plugin.version>1.6.13</nexus-staging-maven-plugin.version>
<okhttp3.version>4.10.0</okhttp3.version>
Expand Down Expand Up @@ -138,7 +138,7 @@
<artifactId>HikariCP</artifactId>
<version>5.1.0</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
Expand Down Expand Up @@ -242,11 +242,6 @@
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>net.bytebuddy</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,27 @@

import de.mediathekview.mserver.crawler.basic.CrawlerUrlDTO;

import java.util.Objects;

public class SrTopicUrlDTO extends CrawlerUrlDTO {

private final String theme;


@Override
public final boolean equals(Object o) {
if (!(o instanceof SrTopicUrlDTO that)) return false;
if (!super.equals(o)) return false;

return Objects.equals(theme, that.theme);
}

@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + Objects.hashCode(theme);
return result;
}

public SrTopicUrlDTO(String aTheme, String aUrl) {
super(aUrl);
theme = aTheme;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
import de.mediathekview.mserver.daten.Sender;
import de.mediathekview.mserver.base.config.MServerBasicConfigDTO;
import de.mediathekview.mserver.base.config.MServerConfigManager;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static de.mediathekview.mserver.daten.Sender.ARD;
import static de.mediathekview.mserver.daten.Sender.BR;
import static org.assertj.core.api.Assertions.assertThat;

public class SenderConfigUsesServerConfigForDefaultTest {
class SenderConfigUsesServerConfigForDefaultTest {

private MServerConfigManager configManager;

@Before
public void setUp() {
@BeforeEach
void setUp() {
configManager = new MServerConfigManager("ConfigTest.yaml");
}

@Test
public void senderConfig_NotOverriddenValue_ValueFromRootConfig() {
void senderConfig_NotOverriddenValue_ValueFromRootConfig() {
configManager.getConfig().setSocketTimeoutInSeconds(42);
final MServerBasicConfigDTO kikaConfig = configManager.getSenderConfig(Sender.KIKA);
kikaConfig.setMaximumSubpages(42);
Expand All @@ -30,7 +30,7 @@ public void senderConfig_NotOverriddenValue_ValueFromRootConfig() {
}

@Test
public void
void
senderConfig_NotOverriddenRootConfigValueChangedAfterInitialization_NewValueFromRootConfig() {
final MServerBasicConfigDTO kikaConfig = configManager.getSenderConfig(Sender.KIKA);
kikaConfig.setMaximumSubpages(42);
Expand All @@ -41,7 +41,7 @@ public void senderConfig_NotOverriddenValue_ValueFromRootConfig() {
}

@Test
public void senderConfig_OverrideValue_OverriddenValue() {
void senderConfig_OverrideValue_OverriddenValue() {
configManager.getConfig().setMaximumSubpages(21);
final MServerBasicConfigDTO kikaConfig = configManager.getSenderConfig(Sender.KIKA);
kikaConfig.setMaximumSubpages(42);
Expand All @@ -51,7 +51,7 @@ public void senderConfig_OverrideValue_OverriddenValue() {
}

@Test
public void senderConfig_OverriddenRootConfigValueChangedAfterInitialization_OverriddenValue() {
void senderConfig_OverriddenRootConfigValueChangedAfterInitialization_OverriddenValue() {
final MServerBasicConfigDTO kikaConfig = configManager.getSenderConfig(Sender.KIKA);
kikaConfig.setMaximumSubpages(42);
configManager.getConfig().setMaximumSubpages(21);
Expand All @@ -61,19 +61,19 @@ public void senderConfig_OverriddenRootConfigValueChangedAfterInitialization_Ove
}

@Test
public void configFromFile_NotOverridden_ValueFromRootConfig() {
void configFromFile_NotOverridden_ValueFromRootConfig() {
assertThat(configManager.getSenderConfig(ARD).getMaximumSubpages())
.isEqualTo(configManager.getConfig().getMaximumSubpages());
}

@Test
public void configFromFile_Overridden_OverriddenValue() {
void configFromFile_Overridden_OverriddenValue() {
assertThat(configManager.getSenderConfig(ARD).getMaximumUrlsPerTask())
.isNotEqualTo(configManager.getConfig().getMaximumUrlsPerTask());
}

@Test
public void configFromFile_NoDirectConfigForSender_ValueFromRootConfig() {
void configFromFile_NoDirectConfigForSender_ValueFromRootConfig() {
assertThat(configManager.getSenderConfig(BR).getMaximumUrlsPerTask())
.isEqualTo(configManager.getConfig().getMaximumUrlsPerTask());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,17 @@

import de.mediathekview.mserver.daten.GeoLocations;
import de.mediathekview.mserver.daten.Sender;
import junit.framework.TestCase;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import java.util.Arrays;
import java.util.Collection;

import static org.hamcrest.MatcherAssert.assertThat;

@RunWith(Parameterized.class)
public class GeoLocationGuesserTest extends TestCase {
public class GeoLocationGuesserTest {

private final Sender sender;
private final String url;
private final GeoLocations expectedGeoLocation;

@Parameterized.Parameters
public static Collection<Object[]> data() {
return Arrays.asList(
new Object[][] {
Expand Down Expand Up @@ -177,16 +169,9 @@ public static Collection<Object[]> data() {
});
}

public GeoLocationGuesserTest(
final Sender sender, final String url, final GeoLocations expectedGeoLocation) {

this.sender = sender;
this.url = url;
this.expectedGeoLocation = expectedGeoLocation;
}

@Test
public void geoLocations() {
@MethodSource("data")
@ParameterizedTest
void geoLocations(final Sender sender, final String url, final GeoLocations expectedGeoLocation) {

final Collection<GeoLocations> actualGeoLocations =
GeoLocationGuesser.getGeoLocations(sender, url);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
package de.mediathekview.mserver.base.utils;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import java.util.Arrays;
import java.util.Collection;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;

@RunWith(Parameterized.class)
public class UrlUtilsAddDomainIfMissingTest {
private static final String DOMAIN = "https://mydomain.de";
private final String inputUrl;
private final String expectedBaseUrl;

public UrlUtilsAddDomainIfMissingTest(final String aInputUrl, final String aExpectedBaseUrl) {
inputUrl = aInputUrl;
expectedBaseUrl = aExpectedBaseUrl;
}

@Parameterized.Parameters
public static Collection<String[]> data() {
return Arrays.asList(
new String[][] {
Expand All @@ -33,8 +23,9 @@ public static Collection<String[]> data() {
});
}

@Test
public void addDomainIfMissingTest() {
@MethodSource("data")
@ParameterizedTest
void addDomainIfMissingTest(final String inputUrl, final String expectedBaseUrl) {
final String actual = UrlUtils.addDomainIfMissing(inputUrl, DOMAIN);

assertThat(actual, equalTo(expectedBaseUrl));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
package de.mediathekview.mserver.base.utils;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import java.util.Arrays;
import java.util.Collection;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;

@RunWith(Parameterized.class)
public class UrlUtilsAddProtocolIfMissingTest {

private static final String PROTOCOL = "https:";
private final String inputUrl;
private final String expectedBaseUrl;

public UrlUtilsAddProtocolIfMissingTest(final String aInputUrl, final String aExpectedBaseUrl) {
inputUrl = aInputUrl;
expectedBaseUrl = aExpectedBaseUrl;
}

@Parameterized.Parameters
public static Collection<String[]> data() {
return Arrays.asList(
new String[][] {
Expand All @@ -36,8 +26,9 @@ public static Collection<String[]> data() {
});
}

@Test
public void addProtocolIfMissingTest() {
@MethodSource("data")
@ParameterizedTest
void addProtocolIfMissingTest(final String inputUrl, final String expectedBaseUrl) {
final String actual = UrlUtils.addProtocolIfMissing(inputUrl, PROTOCOL);

assertThat(actual, equalTo(expectedBaseUrl));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
package de.mediathekview.mserver.base.utils;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import java.util.Arrays;
import java.util.Collection;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;

@RunWith(Parameterized.class)
public class UrlUtilsGetBaseUrlTest {
private final String inputUrl;
private final String expectedBaseUrl;

public UrlUtilsGetBaseUrlTest(final String aInputUrl, final String aExpectedBaseUrl) {
inputUrl = aInputUrl;
expectedBaseUrl = aExpectedBaseUrl;
}

@Parameterized.Parameters
public static Collection<Object[]> data() {
return Arrays.asList(
new Object[][] {
Expand All @@ -32,8 +21,9 @@ public static Collection<Object[]> data() {
});
}

@Test
public void getBaseUrlTest() {
@MethodSource("data")
@ParameterizedTest
void getBaseUrlTest(final String inputUrl, final String expectedBaseUrl) {
final String actual = UrlUtils.getBaseUrl(inputUrl);

assertThat(actual, equalTo(expectedBaseUrl));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package de.mediathekview.mserver.base.utils;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import java.util.Arrays;
import java.util.Collection;
Expand All @@ -11,18 +10,8 @@
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;

@RunWith(Parameterized.class)
public class UrlUtilsGetFileNameTest {

private final String inputUrl;
private final Optional<String> expectedFileType;

public UrlUtilsGetFileNameTest(final String aInputUrl, final Optional<String> aExpectedFileType) {
inputUrl = aInputUrl;
expectedFileType = aExpectedFileType;
}

@Parameterized.Parameters
public static Collection<Object[]> data() {
return Arrays.asList(
new Object[][] {
Expand All @@ -39,8 +28,9 @@ public static Collection<Object[]> data() {
});
}

@Test
public void getFileNameTest() {
@MethodSource("data")
@ParameterizedTest
void getFileNameTest(final String inputUrl, final Optional<String> expectedFileType) {
final Optional<String> actual = UrlUtils.getFileName(inputUrl);

assertThat(actual, equalTo(expectedFileType));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package de.mediathekview.mserver.base.utils;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import java.util.Arrays;
import java.util.Collection;
Expand All @@ -11,18 +10,8 @@
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;

@RunWith(Parameterized.class)
public class UrlUtilsGetFileTypeTest {

private final String inputUrl;
private final Optional<String> expectedFileType;

public UrlUtilsGetFileTypeTest(final String aInputUrl, final Optional<String> aExpectedFileType) {
inputUrl = aInputUrl;
expectedFileType = aExpectedFileType;
}

@Parameterized.Parameters
public static Collection<Object[]> data() {
return Arrays.asList(
new Object[][] {
Expand All @@ -40,8 +29,9 @@ public static Collection<Object[]> data() {
});
}

@Test
public void getFileTypeTest() {
@MethodSource("data")
@ParameterizedTest
void getFileTypeTest(final String inputUrl, final Optional<String> expectedFileType) {
final Optional<String> actual = UrlUtils.getFileType(inputUrl);

assertThat(actual, equalTo(expectedFileType));
Expand Down
Loading
Loading