apply intellij fixes

This commit is contained in:
Athou
2023-12-27 08:52:24 +01:00
parent 1b4b3ca52c
commit 9cd1cde571
43 changed files with 151 additions and 190 deletions

View File

@@ -9,12 +9,7 @@ import org.junit.jupiter.api.Test;
class FixedSizeSortedSetTest {
private static final Comparator<String> COMP = new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
return ObjectUtils.compare(o1, o2);
}
};
private static final Comparator<String> COMP = ObjectUtils::compare;
private FixedSizeSortedSet<String> set;

View File

@@ -7,9 +7,10 @@ import java.util.List;
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.MockitoAnnotations;
import org.mockito.junit.jupiter.MockitoExtension;
import com.commafeed.backend.dao.FeedCategoryDAO;
import com.commafeed.backend.dao.FeedSubscriptionDAO;
@@ -20,6 +21,7 @@ import com.commafeed.backend.model.User;
import com.rometools.opml.feed.opml.Opml;
import com.rometools.opml.feed.opml.Outline;
@ExtendWith(MockitoExtension.class)
class OPMLExporterTest {
@Mock
@@ -41,21 +43,19 @@ class OPMLExporterTest {
@BeforeEach
public void init() {
MockitoAnnotations.openMocks(this);
user.setName("John Doe");
cat1.setId(1L);
cat1.setName("cat1");
cat1.setParent(null);
cat1.setChildren(new HashSet<FeedCategory>());
cat1.setSubscriptions(new HashSet<FeedSubscription>());
cat1.setChildren(new HashSet<>());
cat1.setSubscriptions(new HashSet<>());
cat2.setId(2L);
cat2.setName("cat2");
cat2.setParent(cat1);
cat2.setChildren(new HashSet<FeedCategory>());
cat2.setSubscriptions(new HashSet<FeedSubscription>());
cat2.setChildren(new HashSet<>());
cat2.setSubscriptions(new HashSet<>());
cat1.getChildren().add(cat2);

View File

@@ -13,7 +13,6 @@ class FeedEntryFilteringServiceTest {
private FeedEntryFilteringService service;
private FeedEntry entry;
private FeedEntryContent content;
@BeforeEach
public void init() {
@@ -22,7 +21,7 @@ class FeedEntryFilteringServiceTest {
entry = new FeedEntry();
entry.setUrl("https://github.com/Athou/commafeed");
content = new FeedEntryContent();
FeedEntryContent content = new FeedEntryContent();
content.setAuthor("Athou");
content.setTitle("Merge pull request #662 from Athou/dw8");
content.setContent("Merge pull request #662 from Athou/dw8");
@@ -46,13 +45,13 @@ class FeedEntryFilteringServiceTest {
}
@Test
void newIsDisabled() throws FeedEntryFilterException {
void newIsDisabled() {
Assertions.assertThrows(FeedEntryFilterException.class,
() -> service.filterMatchesEntry("null eq new ('java.lang.String', 'athou')", entry));
}
@Test
void getClassMethodIsDisabled() throws FeedEntryFilterException {
void getClassMethodIsDisabled() {
Assertions.assertThrows(FeedEntryFilterException.class, () -> service.filterMatchesEntry("null eq ''.getClass()", entry));
}
@@ -62,24 +61,24 @@ class FeedEntryFilteringServiceTest {
}
@Test
void cannotLoopForever() throws FeedEntryFilterException {
void cannotLoopForever() {
Assertions.assertThrows(FeedEntryFilterException.class, () -> service.filterMatchesEntry("while(true) {}", entry));
}
@Test
void handlesNullCorrectly() throws FeedEntryFilterException {
void handlesNullCorrectly() {
entry.setUrl(null);
entry.setContent(new FeedEntryContent());
Assertions.assertDoesNotThrow(() -> service.filterMatchesEntry("author eq 'athou'", entry));
}
@Test
void incorrectScriptThrowsException() throws FeedEntryFilterException {
void incorrectScriptThrowsException() {
Assertions.assertThrows(FeedEntryFilterException.class, () -> service.filterMatchesEntry("aa eqz bb", entry));
}
@Test
void incorrectReturnTypeThrowsException() throws FeedEntryFilterException {
void incorrectReturnTypeThrowsException() {
Assertions.assertThrows(FeedEntryFilterException.class, () -> service.filterMatchesEntry("1", entry));
}

View File

@@ -5,9 +5,10 @@ import java.util.Optional;
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.MockitoAnnotations;
import org.mockito.junit.jupiter.MockitoExtension;
import com.commafeed.CommaFeedConfiguration;
import com.commafeed.backend.dao.FeedCategoryDAO;
@@ -18,6 +19,7 @@ import com.commafeed.backend.dao.UserSettingsDAO;
import com.commafeed.backend.model.User;
import com.commafeed.backend.service.internal.PostLoginActivities;
@ExtendWith(MockitoExtension.class)
class UserServiceTest {
private static final byte[] SALT = new byte[] { 1, 2, 3 };
@@ -47,8 +49,6 @@ class UserServiceTest {
@BeforeEach
public void init() {
MockitoAnnotations.openMocks(this);
userService = new UserService(feedCategoryDAO, feedSubscriptionDAO, userDAO, userRoleDAO, userSettingsDAO,
passwordEncryptionService, commaFeedConfiguration, postLoginActivities);

View File

@@ -63,7 +63,7 @@ public class PlaywrightTestBase {
private final String directory = buildDirectory + "/playwright-artifacts";
@Override
public void beforeEach(ExtensionContext context) throws Exception {
public void beforeEach(ExtensionContext context) {
PlaywrightTestBase testInstance = getTestInstance(context);
NewContextOptions newContextOptions = new Browser.NewContextOptions().setRecordVideoDir(Paths.get(directory));

View File

@@ -178,11 +178,19 @@ class FeedIT extends BaseIT {
void importExportOpml() throws IOException {
importOpml();
String opml = getClient().target(getApiBaseUrl() + "feed/export").request().get(String.class);
String expextedOpml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<opml version=\"1.0\">\n" + " <head>\n"
+ " <title>admin subscriptions in CommaFeed</title>\n" + " </head>\n" + " <body>\n"
+ " <outline text=\"out1\" title=\"out1\">\n"
+ " <outline text=\"feed1\" type=\"rss\" title=\"feed1\" xmlUrl=\"https://hostname.local/commafeed/feed1.xml\" />\n"
+ " </outline>\n" + " </body>\n" + "</opml>\n";
String expextedOpml = """
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>admin subscriptions in CommaFeed</title>
</head>
<body>
<outline text="out1" title="out1">
<outline text="feed1" type="rss" title="feed1" xmlUrl="https://hostname.local/commafeed/feed1.xml" />
</outline>
</body>
</opml>
""";
Assertions.assertEquals(StringUtils.normalizeSpace(expextedOpml), StringUtils.normalizeSpace(opml));
}