Fixed most reported issues by SonarCloud.
This commit is contained in:
@ -38,6 +38,9 @@ import java.util.Map;
|
||||
*/
|
||||
public final class RainbowFishSerializer {
|
||||
|
||||
public static final String LENGTH_METERS = "lengthMeters";
|
||||
public static final String WEIGHT_TONS = "weightTons";
|
||||
|
||||
private RainbowFishSerializer() {
|
||||
}
|
||||
|
||||
@ -48,8 +51,8 @@ public final class RainbowFishSerializer {
|
||||
var map = Map.of(
|
||||
"name", rainbowFish.getName(),
|
||||
"age", String.format("%d", rainbowFish.getAge()),
|
||||
"lengthMeters", String.format("%d", rainbowFish.getLengthMeters()),
|
||||
"weightTons", String.format("%d", rainbowFish.getWeightTons())
|
||||
LENGTH_METERS, String.format("%d", rainbowFish.getLengthMeters()),
|
||||
WEIGHT_TONS, String.format("%d", rainbowFish.getWeightTons())
|
||||
);
|
||||
|
||||
try (var fileOut = new FileOutputStream(filename);
|
||||
@ -65,8 +68,8 @@ public final class RainbowFishSerializer {
|
||||
var map = Map.of(
|
||||
"name", rainbowFish.getName(),
|
||||
"age", String.format("%d", rainbowFish.getAge()),
|
||||
"lengthMeters", String.format("%d", rainbowFish.getLengthMeters()),
|
||||
"weightTons", String.format("%d", rainbowFish.getWeightTons()),
|
||||
"lengthMeters", String.format("%d", rainbowFish.getLengthMeters()),
|
||||
WEIGHT_TONS, String.format("%d", rainbowFish.getWeightTons()),
|
||||
"angry", Boolean.toString(rainbowFish.getAngry()),
|
||||
"hungry", Boolean.toString(rainbowFish.getHungry()),
|
||||
"sleeping", Boolean.toString(rainbowFish.getSleeping())
|
||||
@ -93,7 +96,7 @@ public final class RainbowFishSerializer {
|
||||
map.get("name"),
|
||||
Integer.parseInt(map.get("age")),
|
||||
Integer.parseInt(map.get("lengthMeters")),
|
||||
Integer.parseInt(map.get("weightTons"))
|
||||
Integer.parseInt(map.get(WEIGHT_TONS))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -29,19 +29,21 @@ import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
|
||||
/**
|
||||
* Application test
|
||||
*/
|
||||
public class AppTest {
|
||||
class AppTest {
|
||||
|
||||
@Test
|
||||
public void test() throws ClassNotFoundException, IOException {
|
||||
App.main(new String[]{});
|
||||
void shouldExecuteWithoutException() {
|
||||
assertDoesNotThrow(() -> App.main(new String[]{}));
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
@AfterEach
|
||||
public void cleanup() {
|
||||
void cleanup() {
|
||||
var file1 = new File("fish1.out");
|
||||
file1.delete();
|
||||
var file2 = new File("fish2.out");
|
||||
|
Reference in New Issue
Block a user