Skip to content

Commit

Permalink
[GH-275] Fix test failures on Windows build.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Ledvinka committed Nov 1, 2024
1 parent 750df26 commit 4aa5cbd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
import org.jsoup.Jsoup;
import org.jsoup.select.Elements;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
Expand Down Expand Up @@ -180,13 +178,12 @@ void findTermOccurrencesMarksOccurrencesAsSuggested() {
}

@Test
@DisabledOnOs(OS.WINDOWS) // TODO: https://github.com/kbss-cvut/termit/issues/275
void findTermOccurrencesSetsFoundOccurrencesAsApprovedWhenCorrespondingExistingOccurrenceWasApproved() throws Exception {
when(termService.exists(TERM_URI)).thenReturn(true);
final File file = initFile();
final TermOccurrence existing = Generator.generateTermOccurrence(new Term(TERM_URI), file, false);
final Selector quoteSelector = new TextQuoteSelector("Územní plán", "RDFa simple", "hlavního města Prahy.");
final Selector posSelector = new TextPositionSelector(21, 32);
final Selector posSelector = new TextPositionSelector(35, 46);
existing.getTarget().setSelectors(Set.of(quoteSelector, posSelector));
final InputStream is = cz.cvut.kbss.termit.environment.Environment.loadFile("data/rdfa-simple.html");
sut.parseContent(is, file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,6 @@
*/
package cz.cvut.kbss.termit.service.repository;

import cz.cvut.kbss.termit.environment.Environment;
import cz.cvut.kbss.termit.environment.Generator;
import cz.cvut.kbss.termit.exception.ValidationException;
import cz.cvut.kbss.termit.model.UserAccount;
import cz.cvut.kbss.termit.persistence.dao.UserAccountDao;
import cz.cvut.kbss.termit.service.IdentifierResolver;
import cz.cvut.kbss.termit.util.Configuration;
import cz.cvut.kbss.termit.util.Vocabulary;
import jakarta.validation.Validation;
import jakarta.validation.Validator;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

import java.net.URI;
import java.util.Optional;

Expand All @@ -47,10 +27,30 @@
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.any;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import static org.mockito.ArgumentMatchers.any;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.mockito.Spy;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

import cz.cvut.kbss.termit.environment.Environment;
import cz.cvut.kbss.termit.environment.Generator;
import cz.cvut.kbss.termit.exception.ValidationException;
import cz.cvut.kbss.termit.model.UserAccount;
import cz.cvut.kbss.termit.persistence.dao.UserAccountDao;
import cz.cvut.kbss.termit.service.IdentifierResolver;
import cz.cvut.kbss.termit.util.Configuration;
import cz.cvut.kbss.termit.util.Vocabulary;
import jakarta.validation.Validation;
import jakarta.validation.Validator;

@ExtendWith(MockitoExtension.class)
class UserRepositoryServiceTest {
Expand Down Expand Up @@ -168,7 +168,7 @@ void updateThrowsValidationExceptionWhenUpdatedInstanceIsMissingValues() {
user.setUsername(null);
user.setPassword(null); // Simulate instance being loaded from repo
final ValidationException ex = assertThrows(ValidationException.class, () -> sut.update(user));
assertThat(ex.getMessage(), containsString("username must not be blank"));
assertThat(ex.getMessage(), containsString("username"));
}

@Test
Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/data/rdfa-simple.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>RDFa simple</title>
<title>RDFa simple</title>
</head>
<body prefix="termit: http://onto.fel.cvut.cz/ontologies/application/termit/pojem/">
<span about="_:1" property="termit:je-výskytem-termu" score="1.0" resource="http://onto.fel.cvut.cz/ontologies/mpp/domains/uzemni-plan"
<span about="_:1" property="termit:je-výskytem-termu" score="1.0" resource="http://onto.fel.cvut.cz/ontologies/mpp/domains/uzemni-plan"
typeof="termit:výskyt-termu">Územní plán</span> hlavního města Prahy.
</body>
</html>

0 comments on commit 4aa5cbd

Please sign in to comment.