Skip to content

Commit

Permalink
Use Java 17 language features
Browse files Browse the repository at this point in the history
Formatted strings
  • Loading branch information
MarkEWaite committed Nov 22, 2024
1 parent 0264fd7 commit 0e4d9bf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ public void testRestInterfaceSuccess() throws Exception {
wc.login("test1");

// GET config.xml of srcProject (userid is set to test1)
String configXml = getConfigXml(wc.goToXml(String.format("%s/config.xml", srcProject.getUrl())));
String configXml = getConfigXml(wc.goToXml("%s/config.xml".formatted(srcProject.getUrl())));

// POST config.xml of srcProject (userid is set to test1) to a new project.
// This should success.
Expand All @@ -354,7 +354,7 @@ public void testRestInterfaceSuccess() throws Exception {
String projectName = destProject.getFullName();

WebRequest req = new WebRequest(
new URL(wc.getContextPath() + String.format("%s/config.xml", destProject.getUrl())), HttpMethod.POST);
new URL("%s%s/config.xml".formatted(wc.getContextPath(), destProject.getUrl())), HttpMethod.POST);
req.setAdditionalHeader(
j.jenkins.getCrumbIssuer().getCrumbRequestField(),
j.jenkins.getCrumbIssuer().getCrumb((jakarta.servlet.ServletRequest) null));
Expand Down Expand Up @@ -398,7 +398,7 @@ public void testRestInterfaceFailure() throws Exception {
wc.login("test1");

// GET config.xml of srcProject (userid is set to admin)
String configXml = getConfigXml(wc.goToXml(String.format("%s/config.xml", srcProject.getUrl())));
String configXml = getConfigXml(wc.goToXml("%s/config.xml".formatted(srcProject.getUrl())));

// POST config.xml of srcProject (userid is set to admin) to a new project.
// This should fail.
Expand All @@ -407,7 +407,7 @@ public void testRestInterfaceFailure() throws Exception {
String projectName = destProject.getFullName();

WebRequest req = new WebRequest(
new URL(wc.getContextPath() + String.format("%s/config.xml", destProject.getUrl())), HttpMethod.POST);
new URL("%s%s/config.xml".formatted(wc.getContextPath(), destProject.getUrl())), HttpMethod.POST);
req.setAdditionalHeader(
j.jenkins.getCrumbIssuer().getCrumbRequestField(),
j.jenkins.getCrumbIssuer().getCrumb((jakarta.servlet.ServletRequest) null));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public void testRestInterfaceSuccess() throws Exception {
wc.login("admin");

// GET config.xml of srcProject
String configXml = getConfigXml(wc.goToXml(String.format("%s/config.xml", srcProject.getUrl())));
String configXml = getConfigXml(wc.goToXml("%s/config.xml".formatted(srcProject.getUrl())));

// POST config.xml of srcProject to a new project.
// This should success.
Expand All @@ -182,7 +182,7 @@ public void testRestInterfaceSuccess() throws Exception {
String projectName = destProject.getFullName();

WebRequest req = new WebRequest(
new URL(wc.getContextPath() + String.format("%s/config.xml", destProject.getUrl())), HttpMethod.POST);
new URL(wc.getContextPath() + "%s/config.xml".formatted(destProject.getUrl())), HttpMethod.POST);
req.setAdditionalHeader(
j.jenkins.getCrumbIssuer().getCrumbRequestField(),
j.jenkins.getCrumbIssuer().getCrumb((jakarta.servlet.ServletRequest) null));
Expand Down Expand Up @@ -223,7 +223,7 @@ public void testRestInterfaceFailure() throws Exception {
.setPermitReconfiguration(true);

// GET config.xml of srcProject
String configXml = getConfigXml(wc.goToXml(String.format("%s/config.xml", srcProject.getUrl())));
String configXml = getConfigXml(wc.goToXml("%s/config.xml".formatted(srcProject.getUrl())));

// POST config.xml of srcProject (userid is set to admin) to a new project.
// This should fail.
Expand All @@ -232,7 +232,7 @@ public void testRestInterfaceFailure() throws Exception {
String projectName = destProject.getFullName();

WebRequest req = new WebRequest(
new URL(wc.getContextPath() + String.format("%s/config.xml", destProject.getUrl())), HttpMethod.POST);
new URL(wc.getContextPath() + "%s/config.xml".formatted(destProject.getUrl())), HttpMethod.POST);
req.setAdditionalHeader(
j.jenkins.getCrumbIssuer().getCrumbRequestField(),
j.jenkins.getCrumbIssuer().getCrumb((jakarta.servlet.ServletRequest) null));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public SecurityComponents createSecurityComponents() {
baseComponent.manager,
username -> {
if (!validUserList.contains(username)) {
throw new UsernameNotFoundException(
String.format("%s is not listed as valid username.", username));
throw new UsernameNotFoundException("%s is not listed as valid username.".formatted(username));
}
return baseComponent.userDetails.loadUserByUsername(username);
},
Expand Down

0 comments on commit 0e4d9bf

Please sign in to comment.