This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
Commit c9dd60d6 authored by Michael Breu's avatar Michael Breu :speech_balloon:
Browse files

Some minor code improvements

parent f3299981
2 merge requests!91Bringing JHipster7.6.0 to production,!88Integrating Update to JHipster 7.6.0 back to Development
......@@ -2,6 +2,9 @@ package at.ac.uibk.gitsearch.service;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.charset.UnsupportedCharsetException;
import org.gitlab4j.api.GitLabApiException;
import org.gitlab4j.api.models.WikiPage;
......@@ -36,11 +39,7 @@ public class EditorialPagesService {
@Cacheable(PAGES_CACHE)
public EditorialPageDTO getContent(String path) throws GitLabApiException {
String encodedPath;
try {
encodedPath = URLEncoder.encode(path, "UTF-8");
} catch (UnsupportedEncodingException e) {
encodedPath = URLEncoder.encode(path);
}
encodedPath = URLEncoder.encode(path, StandardCharsets.UTF_8);
final WikiPage page = gitLabRepository.getGitLabApi().getWikisApi().getPage(editorialProject, encodedPath);
return new EditorialPageDTO(path, page.getContent());
}
......
......@@ -9,6 +9,7 @@ import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
......@@ -180,7 +181,7 @@ public class ExerciseService {
jsonObject.put("type", "programming exercise");
}
try (FileWriter fileWriter = new FileWriter(jsonFile)) {
try (FileWriter fileWriter = new FileWriter(jsonFile, StandardCharsets.UTF_8)) {
fileWriter.write(jsonObject.toString(JSONStyle.NO_COMPRESS));
}
}
......
......@@ -4,6 +4,7 @@ import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
......@@ -45,7 +46,7 @@ public class TestMetaDataGenerator {
fileContent = Files.readAllBytes(f.toPath());
if(f.getName().endsWith(".yaml")) {
String content = new String(fileContent, "UTF-8");
String content = new String(fileContent, StandardCharsets.UTF_8);
return content.replace("${title}", "Meta Test Data " + count).replace("${keyword}", "testing" + count).getBytes();
} else {
return fileContent;
......
......@@ -9,6 +9,7 @@ import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
......@@ -647,7 +648,7 @@ public class ElasticSearchTestConfiguration {
return metaDataStream;
}
};
String text = byteSource.asCharSource(Charsets.UTF_8).read();
String text = byteSource.asCharSource(StandardCharsets.UTF_8).read();
return text;
}
......
......@@ -8,6 +8,7 @@ import static org.mockito.Mockito.verify;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
......@@ -106,7 +107,7 @@ public class ExerciseServiceIT {
File metadata = new File("tmp-import/" + token, "Exercise-Details-something.json");
metadata.getParentFile().mkdirs();
metadata.createNewFile();
FileWriter writer = new FileWriter(metadata);
FileWriter writer = new FileWriter(metadata, StandardCharsets.UTF_8);
writer.write("{\n" + " \"metadataVersion\": \"1\",\n" + " \"type\": \"programming exercise\",\n"
+ " \"title\": \"TestTitle\",\n" + " \"license\": \"testLicense\",\n" + " \"maxPoints\": 100,\n"
+ " \"bonusPoints\": 100,\n" + " \"mode\": \"INDIVIDUAL\",\n" + " \"staticCodeAnalysis\": false,\n"
......@@ -138,7 +139,7 @@ public class ExerciseServiceIT {
File metadata = new File("tmp-import/" + token, "Exercise-Details-something.json");
metadata.getParentFile().mkdirs();
metadata.createNewFile();
FileWriter writer = new FileWriter(metadata);
FileWriter writer = new FileWriter(metadata, StandardCharsets.UTF_8);
writer.write("{\n" + " \"metadataVersion\": \"1\",\n" + " \"type\": \"programming exercise\",\n"
+ " \"title\": \"TestTitle\",\n" + " \"license\": \"testLicense\"\n" + "}");
writer.close();
......
......@@ -131,7 +131,7 @@ public void testSetters(Class<?> beanClass, Object bean, String... setterExcepti
property = null;
}
} else if(Set.class.isAssignableFrom(type)) {
property = Collections.EMPTY_SET;
property = Collections.emptySet();
} else if (Instant.class.isAssignableFrom(type)) {
property = Instant.now();
} else if (Float.class.isAssignableFrom(type)) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment