Skip to content

Commit

Permalink
fix: remove sonar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelDemey committed Dec 16, 2024
1 parent 881078a commit 66d34ce
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private RdfUtils(){}

static ValueFactory factory = SimpleValueFactory.getInstance();

public static BNode createBlankNode(){ return factory.createBNode(); };
public static BNode createBlankNode(){ return factory.createBNode(); }
public static String getBaseGraph(){
return config.getBaseGraph();
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/fr/insee/rmes/config/keycloak/ServerZone.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void setZone(String zone) {
.filter(z->zone.toUpperCase().equals(z.name()))
.findFirst()
.orElseGet(()->{
logger.warn("No zone found for value "+zone+" : this is serverZone set to default zone");
logger.warn(String.format("No zone found for value {0} : this is serverZone set to default zone"), zone);
return Zone.defaultZone();
});
}
Expand All @@ -28,7 +28,7 @@ public ServerZone(String zone) {
.filter(z->zone.toUpperCase().equals(z.name()))
.findFirst()
.orElseGet(()->{
logger.warn("No zone found for value "+zone+" : this is serverZone set to default zone");
logger.warn(String.format("No zone found for value {0} : this is serverZone set to default zone", zone));
return Zone.defaultZone();
});
}
Expand Down
52 changes: 52 additions & 0 deletions src/test/java/fr/insee/rmes/config/keycloak/ServerZoneTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package fr.insee.rmes.config.keycloak;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

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

class ServerZoneTest {

private ServerZone serverZone;

@BeforeEach
void setUp() {
serverZone = new ServerZone();
}

@Test
void testSetZone_withValidZone() {
String validZone = "INTERNE";

serverZone.setZone(validZone);

assertEquals(ServerZone.Zone.INTERNE, serverZone.zone());
}

@Test
void testSetZone_withInvalidZone_logsWarningAndSetsDefaultZone() {
String invalidZone = "INVALID_ZONE";

serverZone.setZone(invalidZone);

assertEquals(ServerZone.Zone.defaultZone(), serverZone.zone());
}

@Test
void testConstructor_withValidZone() {
String validZone = "DMZ";

ServerZone serverZone = new ServerZone(validZone);

assertEquals(ServerZone.Zone.DMZ, serverZone.zone());
}

@Test
void testConstructor_withInvalidZone_logsWarningAndSetsDefaultZone() {
String invalidZone = "UNKNOWN";

ServerZone serverZone = new ServerZone(invalidZone);

assertEquals(ServerZone.Zone.defaultZone(), serverZone.zone());
}
}

0 comments on commit 66d34ce

Please sign in to comment.