Skip to content

Commit

Permalink
Minor improvements to array creation and one unit test (#1122)
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanSpieker authored and timja committed Oct 3, 2019
1 parent c505013 commit 221d390
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void checkUsernamePasswordIsSecret() {

@Nonnull
private <T> Attribute<T,?> getFromDatabound(Class<T> clazz, @Nonnull String attributeName) {
DataBoundConfigurator<T> cfg = new DataBoundConfigurator<T>(clazz);
DataBoundConfigurator<T> cfg = new DataBoundConfigurator<>(clazz);
Set<Attribute<T,?>> attributes = cfg.describe();
for (Attribute<T,?> a : attributes) {
if(attributeName.equals(a.getName())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
public interface RootElementConfigurator<T> extends Configurator<T> {

static List<RootElementConfigurator> all() {
List<RootElementConfigurator> configurators = new ArrayList<>();
final Jenkins jenkins = Jenkins.getInstance();
configurators.addAll(jenkins.getExtensionList(RootElementConfigurator.class));
List<RootElementConfigurator> configurators = new ArrayList<>(
jenkins.getExtensionList(RootElementConfigurator.class));

for (GlobalConfigurationCategory category : GlobalConfigurationCategory.all()) {
configurators.add(new GlobalConfigurationCategoryConfigurator(category));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ public void init() {
public abstract Optional<String> reveal(String secret) throws IOException;

public static List<SecretSource> all() {
List<SecretSource> all = new ArrayList<>();
all.addAll(Jenkins.getInstance().getExtensionList(SecretSource.class));
return all;
return new ArrayList<>(
Jenkins.getInstance().getExtensionList(SecretSource.class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void _int() throws Exception {
public void _Integer() throws Exception {
Configurator c = registry.lookupOrFail(Integer.class);
final Object value = c.configure(new Scalar("123"), context);
assertTrue(123 == (Integer) value);
assertEquals(123, (int) value);
}

@Test
Expand Down Expand Up @@ -87,7 +87,7 @@ public void _Integer_env() throws Exception {
environment.set("ENV_FOR_TEST", "123");
Configurator c = registry.lookupOrFail(Integer.class);
final Object value = c.configure(new Scalar("${ENV_FOR_TEST}"), context);
assertTrue(123 == (Integer) value);
assertEquals(123, (int) value);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -53,7 +54,8 @@ public void before() throws Throwable {
try {
File codeBlockFile = File.createTempFile("integrations", "markdown");
InputStream inputStream = clazz.getClassLoader().getResourceAsStream(s);
List<String> lines = Arrays.asList(transformFencedCodeBlockFromMarkdownToString(inputStream));
List<String> lines = Collections.singletonList(
transformFencedCodeBlockFromMarkdownToString(inputStream));
Path file = Paths.get(codeBlockFile.getCanonicalPath());
Files.write(file, lines, StandardCharsets.UTF_8);
return codeBlockFile.toURI().toString();
Expand Down

0 comments on commit 221d390

Please sign in to comment.