Skip to content

Commit

Permalink
fix: remove sonar issues (#825)
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelDemey authored Dec 6, 2024
1 parent 4e4ff63 commit 053a023
Show file tree
Hide file tree
Showing 16 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public class CommonSecurityConfiguration {
private final Optional<String> allowedOrigin ;
private final String appHost;

public CommonSecurityConfiguration(@Value("${"+CORS_ALLOWED_ORIGIN+"}") Optional<String> allowedOrigin, @Value("${fr.insee.rmes.bauhaus.appHost}") String appHost) {
public CommonSecurityConfiguration(
@Value("${"+CORS_ALLOWED_ORIGIN+"}") Optional<String> allowedOrigin,
@Value("${fr.insee.rmes.bauhaus.appHost}") String appHost) {
this.allowedOrigin=allowedOrigin;
this.appHost = appHost;
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/fr/insee/rmes/utils/FilesUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ public class FilesUtils {
public static final String FODT_EXTENSION = ".fodt";

public static MediaType getMediaTypeFromExtension(String extension) {
MediaType contentType = switch (extension){
return switch (extension){
case FilesUtils.ODT_EXTENSION -> new MediaType("application", "vnd.oasis.opendocument.text");
case FilesUtils.ODS_EXTENSION -> new MediaType("application", "vnd.oasis.opendocument.spreadsheet");
case FilesUtils.ZIP_EXTENSION -> new MediaType("application", "zip");
default -> throw new IllegalStateException("Unexpected value: " + extension);
};
return contentType;
}

public static String getExtension(String acceptHeader) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/bauhaus-local-dev.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Default value for cors filter : empty means no CORS allowed :
fr.insee.rmes.bauhaus.cors.allowedOrigin=http://localhost:3000/,http://localhost:8080/
fr.insee.rmes.bauhaus.cors.allowedOrigin=*

# Properties Front
fr.insee.rmes.bauhaus.appHost = http://localhost:3000/#/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void shouldNotPublishExcludedTriplets() throws RmesException {
new RepositoryResult<>(new CloseableIteratorIteration<>(fakeStatements.iterator()));


when(publicationUtils.tranformBaseURIToPublish(eq(subject))).thenReturn(subject);
when(publicationUtils.tranformBaseURIToPublish(subject)).thenReturn(subject);
when(repositoryGestion.getConnection()).thenReturn(null);
when(repositoryGestion.getStatementsPredicateObject(any(), eq(SKOS.IN_SCHEME), any())).thenReturn(new RepositoryResult<>(new CloseableIteratorIteration<>(codeStatement.iterator())));
when(repositoryGestion.getStatements(any(), eq(resource))).thenReturn(new RepositoryResult<>(fakeRepositoryResult));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import fr.insee.rmes.model.concepts.ConceptForExport;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;

import static org.junit.jupiter.api.Assertions.assertEquals;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void testIfDateMiseAJourSavedAsString() throws RmesException {
rdfUtilsMockedStatic.when(() -> RdfUtils.addTripleString(eq(documentIRI), any(IRI.class), any(), any(Model.class), eq(graph))).thenCallRealMethod();
rdfUtilsMockedStatic.when(() -> RdfUtils.setLiteralDate(any(String.class))).thenCallRealMethod();
rdfUtilsMockedStatic.when(() -> RdfUtils.addTripleDate(eq(documentIRI), any(IRI.class), any(), any(Model.class), eq(graph))).thenCallRealMethod();
rdfUtilsMockedStatic.when(() -> RdfUtils.documentsGraph()).thenReturn(graph);
rdfUtilsMockedStatic.when(RdfUtils::documentsGraph).thenReturn(graph);
rdfUtilsMockedStatic.when(() -> RdfUtils.toString(any())).thenReturn(documentIRIString);
rdfUtilsMockedStatic.when(() -> RdfUtils.toURI(any())).thenReturn(documentIRI);
documentQueriesMockedStatic.when(() -> DocumentsQueries.checkLabelUnicity(eq("1"), anyString(), any())).thenReturn(documentIRIString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ void shouldStoreYearProperty() throws RmesException {
mockedFactory.when(() -> RdfUtils.setLiteralString(anyString(), anyString())).thenCallRealMethod();
mockedFactory.when(() -> RdfUtils.setLiteralString(anyString(), anyString())).thenCallRealMethod();
mockedFactory.when(() -> RdfUtils.setLiteralString(anyString())).thenCallRealMethod();
mockedFactory.when(RdfUtils::operationsGraph).thenReturn(valueFactory.createIRI("http://operations-graph/"));
mockedFactory.when(() -> RdfUtils.createLiteral(anyString(), eq(XSD.GYEAR))).thenCallRealMethod();
mockedFactory.when(() -> RdfUtils.operationsGraph()).thenReturn(valueFactory.createIRI("http://operations-graph/"));
mockedFactory.when(() -> RdfUtils.objectIRI(eq(ObjectType.SERIES), eq("2"))).thenReturn(valueFactory.createIRI("http://series/2"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class RdfUtilsTest {
@Test
void shouldReturnNullWhenCallingAddTripeStringMdToXhtml2WithNullValue(){
IRI iri = SimpleValueFactory.getInstance().createIRI("http://iri");
IRI predicate = SimpleValueFactory.getInstance().createIRI("http://predicate");;
IRI predicate = SimpleValueFactory.getInstance().createIRI("http://predicate");
String value = null;
String lang = "fr";
String prefix = "prefix";
Expand All @@ -24,7 +24,7 @@ void shouldReturnNullWhenCallingAddTripeStringMdToXhtml2WithNullValue(){
@Test
void shouldReturnNullWhenCallingAddTripeStringMdToXhtml2WithEmptyValue(){
IRI iri = SimpleValueFactory.getInstance().createIRI("http://iri");
IRI predicate = SimpleValueFactory.getInstance().createIRI("http://predicate");;
IRI predicate = SimpleValueFactory.getInstance().createIRI("http://predicate");
String value = "";
String lang = "fr";
String prefix = "prefix";
Expand All @@ -36,7 +36,7 @@ void shouldReturnNullWhenCallingAddTripeStringMdToXhtml2WithEmptyValue(){
@Test
void shouldUpdateModelWhenCallingAddTripeStringMdToXhtml2WithValidValue(){
IRI iri = SimpleValueFactory.getInstance().createIRI("http://iri");
IRI predicate = SimpleValueFactory.getInstance().createIRI("http://predicate");;
IRI predicate = SimpleValueFactory.getInstance().createIRI("http://predicate");
String value = "value";
String lang = "fr";
String prefix = "prefix";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void setUp() {
}

@Test
public void testAddMembers() {
void testAddMembers() {
JSONArray membersArray = new JSONArray();

JSONObject member1 = new JSONObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;

public class DatasetQueriesTest extends WithGraphDBContainer {
class DatasetQueriesTest extends WithGraphDBContainer {
RepositoryGestion repositoryGestion = new RepositoryGestion(getRdfGestionConnectionDetails(), new RepositoryUtils(null, RepositoryInitiator.Type.DISABLED));

@BeforeAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import static org.junit.jupiter.api.Assertions.*;

@SpringBootTest
public class DistributionServiceImplTest extends WithGraphDBContainer {
class DistributionServiceImplTest extends WithGraphDBContainer {
@Autowired
DistributionService distributionService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

public class OperationsQueriesTest extends WithGraphDBContainer {
class OperationsQueriesTest extends WithGraphDBContainer {
RepositoryGestion repositoryGestion = new RepositoryGestion(getRdfGestionConnectionDetails(), new RepositoryUtils(null, RepositoryInitiator.Type.DISABLED));

@BeforeAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import static org.junit.jupiter.api.Assertions.assertFalse;

public class StructureQueriesTest extends WithGraphDBContainer {
class StructureQueriesTest extends WithGraphDBContainer {
RepositoryGestion repositoryGestion = new RepositoryGestion(getRdfGestionConnectionDetails(), new RepositoryUtils(null, RepositoryInitiator.Type.DISABLED));

@BeforeAll
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/fr/insee/rmes/utils/FilesUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void testGetMediaTypeFromExtension_invalidExtension() {
}

@Test
public void testGetExtension() {
void testGetExtension() {
// Test with null input
assertEquals(".odt", FilesUtils.getExtension(null));

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/fr/insee/rmes/utils/HttpUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

public class HttpUtilsTest {
class HttpUtilsTest {

@Test
public void testGenerateHttpHeaders() {
void testGenerateHttpHeaders() {
String fileName = "tresoeTres";
String extension = ".zip";
String reducedFileName = "tresoeTres";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import static org.mockito.Mockito.when;

@ExtendWith(MockitoExtension.class)
public class DatasetResourcesTest {
class DatasetResourcesTest {
@InjectMocks
private DatasetResources datasetResources;

Expand Down

0 comments on commit 053a023

Please sign in to comment.