-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide a copy button for link examples (#222)
Use a more modern page layout with jelly instead of groovy layout. Provide a copy button rather than using a borderless input field to provide easy copy and paste. The copy button is used in multiple places in Jenkins. Fix Bitbucket URL link error (Had unbalanced parentheses) Add Asciidoc examples Fixes #59
1 parent
5999f58
commit 09dadb1
Showing
8 changed files
with
570 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 0 additions & 114 deletions
114
src/main/resources/org/jenkinsci/plugins/badge/actions/JobBadgeAction/index.groovy
This file was deleted.
Oops, something went wrong.
204 changes: 204 additions & 0 deletions
204
src/main/resources/org/jenkinsci/plugins/badge/actions/JobBadgeAction/index.jelly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core" xmlns:l="/lib/layout"> | ||
|
||
<j:set var="fullJobName" value="${it.urlEncodedFullName}"/> | ||
<j:set var="jobUrl" value="${it.url}"/> | ||
<j:set var="badgeUrl" value="${jobUrl}badge/icon"/> | ||
<j:set var="textUrl" value="${jobUrl}badge/text"/> | ||
<j:set var="publicBadge" value="${app.rootUrl}buildStatus/icon?job=${fullJobName}"/> | ||
<j:set var="publicText" value="${app.rootUrl}buildStatus/text?job=${fullJobName}"/> | ||
|
||
<l:layout title="${%Embeddable Build Status Icon}" type="one-column"> | ||
<l:header> | ||
<link rel='stylesheet' href='${app.rootUrl}/plugin/embeddable-build-status/css/design.css' type='text/css'/> | ||
</l:header> | ||
<l:main-panel> | ||
<h1>${%Embeddable Build Status Icon}</h1> | ||
<p>${%blurb}</p> | ||
|
||
<h2>${%Examples}</h2> | ||
<small>${%examples_note}</small> | ||
|
||
<j:set var="flatCustomSubjectUrl" value="${badgeUrl}?subject=Custom%20Subject&status=Any%20State&color=darkturquoise"/> | ||
|
||
<h3 class="help-format">${%flat}</h3> | ||
<img id='${badgeUrl}' src='${badgeUrl}' title='${badgeUrl}'/> | ||
<br/> | ||
<img id='${badgeUrl}-custom' src='${flatCustomSubjectUrl}' title='${flatCustomSubjectUrl}'/> | ||
|
||
<j:set var="flatSquareUrl" value="${badgeUrl}?style=flat-square"/> | ||
<j:set var="flatSquareCustomSubjectUrl" value="${badgeUrl}?style=flat-square&subject=Custom%20Subject&status=Any%20State&color=darkturquoise"/> | ||
|
||
<h3 class="help-format">${%flat-square}</h3> | ||
<img src='${flatSquareUrl}' title='${flatSquareUrl}'/> | ||
<br/> | ||
<img src='${flatSquareCustomSubjectUrl}' title='${flatSquareCustomSubjectUrl}'/> | ||
|
||
<j:set var="plasticUrl" value="${badgeUrl}?style=plastic"/> | ||
<j:set var="plasticCustomSubjectUrl" value="${badgeUrl}?style=plastic&subject=Custom%20Subject&status=Any%20State&color=darkturquoise"/> | ||
|
||
<h3 class="help-format">${%plastic}</h3> | ||
<img src='${plasticUrl}' title='${plasticUrl}'/> | ||
<br/> | ||
<img src='${plasticCustomSubjectUrl}' title='${plasticCustomSubjectUrl}'/> | ||
|
||
<j:set var="ball16Url" value="${badgeUrl}?style=ball-16x16"/> | ||
<j:set var="ball32Url" value="${badgeUrl}?style=ball-32x32"/> | ||
|
||
<h3 class="help-format">${%ball-size}</h3> | ||
<img src='${ball16Url}' title='${ball16Url}'/> | ||
<br/> | ||
<img src='${ball32Url}' title='${ball32Url}'/> | ||
|
||
<h2>${%Links}</h2> | ||
|
||
<h3 class="help-format">${%Plain link}</h3> | ||
<p> | ||
<b>${%Protected}</b> <l:copyButton text="${badgeUrl}"/> | ||
<br/> | ||
${badgeUrl} | ||
</p> | ||
<p> | ||
<b>${%Unprotected}</b> <l:copyButton text="${publicBadge}"/> | ||
<br/> | ||
${publicBadge} | ||
</p> | ||
|
||
<j:set var="markdownProtectedLink" value="[](${jobUrl})"/> | ||
<j:set var="markdownUnprotectedLink" value="[](${jobUrl})"/> | ||
|
||
<h3 class="help-format">${%Markdown}</h3> | ||
<p> | ||
<b>${%Protected}</b> <l:copyButton text="${markdownProtectedLink}"/> | ||
<br/> | ||
${markdownProtectedLink} | ||
</p> | ||
<p> | ||
<b>${%Unprotected}</b> <l:copyButton text="${markdownUnprotectedLink}"/> | ||
<br/> | ||
${markdownUnprotectedLink} | ||
</p> | ||
|
||
<j:set var="htmlProtectedLink" value="<a href='${jobUrl}'><img src='${badgeUrl}'></a>"/> | ||
<j:set var="htmlUnprotectedLink" value="<a href='${jobUrl}'><img src='${publicBadge}'></a>"/> | ||
|
||
<h3 class="help-format">${%HTML}</h3> | ||
<p> | ||
<b>${%Protected}</b> <l:copyButton text="${htmlProtectedLink}"/> | ||
<br/> | ||
${htmlProtectedLink} | ||
</p> | ||
<p> | ||
<b>${%Unprotected}</b> <l:copyButton text="${htmlUnprotectedLink}"/> | ||
<br/> | ||
${htmlUnprotectedLink} | ||
</p> | ||
|
||
<j:set var="asciidocProtectedLink" value="image:${badgeUrl}[link='${jobUrl}']"/> | ||
<j:set var="asciidocUnprotectedLink" value="image:${publicBadge})[link='${jobUrl}']"/> | ||
|
||
<h3 class="help-format">${%Asciidoc}</h3> | ||
<p> | ||
<b>${%Protected}</b> <l:copyButton text="${asciidocProtectedLink}"/> | ||
<br/> | ||
${asciidocProtectedLink} | ||
</p> | ||
<p> | ||
<b>${%Unprotected}</b> <l:copyButton text="${asciidocUnprotectedLink}"/> | ||
<br/> | ||
${asciidocUnprotectedLink} | ||
</p> | ||
|
||
<j:set var="confluenceProtectedLink" value="[!${badgeUrl}!|${jobUrl}]"/> | ||
<j:set var="confluenceUnprotectedLink" value="[!${publicBadge}!|${jobUrl}]"/> | ||
|
||
<h3 class="help-format">${%Confluence}</h3> | ||
<p> | ||
<b>${%Protected}</b> <l:copyButton text="${confluenceProtectedLink}"/> | ||
<br/> | ||
${confluenceProtectedLink} | ||
</p> | ||
<p> | ||
<b>${%Unprotected}</b> <l:copyButton text="${confluenceUnprotectedLink}"/> | ||
<br/> | ||
${confluenceUnprotectedLink} | ||
</p> | ||
|
||
<j:set var="xwikiProtectedLink" value="[[image:${badgeUrl}>>${jobUrl}||target='__new']]"/> | ||
<j:set var="xwikiUnprotectedLink" value="[[image:${publicBadge}>>${jobUrl}||target='__new']]"/> | ||
|
||
<h3 class="help-format">${%XWiki}</h3> | ||
<p> | ||
<b>${%Protected}</b> <l:copyButton text="${xwikiProtectedLink}"/> | ||
<br/> | ||
${xwikiProtectedLink} | ||
</p> | ||
<p> | ||
<b>${%Unprotected}</b> <l:copyButton text="${xwikiUnprotectedLink}"/> | ||
<br/> | ||
${xwikiUnprotectedLink} | ||
</p> | ||
|
||
<j:set var="rdocProtectedLink" value="{<img src='${badgeUrl}'/>}[${jobUrl}]"/> | ||
<j:set var="rdocUnprotectedLink" value="{<img src='${publicBadge}'/>}[${jobUrl}]"/> | ||
|
||
<h3 class="help-format">${%RDoc}</h3> | ||
<p> | ||
<b>${%Protected}</b> <l:copyButton text="${rdocProtectedLink}"/> | ||
<br/> | ||
${rdocProtectedLink} | ||
</p> | ||
<p> | ||
<b>${%Unprotected}</b> <l:copyButton text="${rdocUnprotectedLink}"/> | ||
<br/> | ||
${rdocUnprotectedLink} | ||
</p> | ||
|
||
<j:set var="textileProtectedLink" value=""!${badgeUrl}!":${jobUrl}"/> | ||
<j:set var="textileUnprotectedLink" value=""!${publicBadge}!":${jobUrl}"/> | ||
|
||
<h3 class="help-format">${%Textile}</h3> | ||
<p> | ||
<b>${%Protected}</b> <l:copyButton text="${textileProtectedLink}"/> | ||
<br/> | ||
${textileProtectedLink} | ||
</p> | ||
<p> | ||
<b>${%Unprotected}</b> <l:copyButton text="${textileUnprotectedLink}"/> | ||
<br/> | ||
${textileUnprotectedLink} | ||
</p> | ||
|
||
<j:set var="bitbucketProtectedLink" value="[Build Status](${badgeUrl} "${jobUrl}")"/> | ||
<j:set var="bitbucketUnprotectedLink" value="[Build Status](${publicBadge} "${jobUrl}")"/> | ||
|
||
<h3 class="help-format">${%Bitbucket}</h3> | ||
<p> | ||
<b>${%Protected}</b> <l:copyButton text="${bitbucketProtectedLink}"/> | ||
<br/> | ||
${bitbucketProtectedLink} | ||
</p> | ||
<p> | ||
<b>${%Unprotected}</b> <l:copyButton text="${bitbucketUnprotectedLink}"/> | ||
<br/> | ||
${bitbucketUnprotectedLink} | ||
</p> | ||
|
||
<h2>${%Embeddable Build Status Text}</h2> | ||
<p>${%blurb_text}</p> | ||
|
||
<h3 class="help-format">${%Text Only}</h3> | ||
<p> | ||
<b>${%Protected}</b> <l:copyButton text="${textUrl}"/> | ||
<br/> | ||
${textUrl} | ||
</p> | ||
<p> | ||
<b>${%Unprotected}</b> <l:copyButton text="${publicText}"/> | ||
<br/> | ||
${publicText} | ||
</p> | ||
|
||
</l:main-panel> | ||
</l:layout> | ||
</j:jelly> |
113 changes: 0 additions & 113 deletions
113
src/main/resources/org/jenkinsci/plugins/badge/actions/RunBadgeAction/index.groovy
This file was deleted.
Oops, something went wrong.
204 changes: 204 additions & 0 deletions
204
src/main/resources/org/jenkinsci/plugins/badge/actions/RunBadgeAction/index.jelly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core" xmlns:l="/lib/layout"> | ||
|
||
<j:set var="fullJobName" value="${it.urlEncodedFullName}"/> | ||
<j:set var="jobUrl" value="${it.url}"/> | ||
<j:set var="badgeUrl" value="${jobUrl}badge/icon"/> | ||
<j:set var="textUrl" value="${jobUrl}badge/text"/> | ||
<j:set var="publicBadge" value="${app.rootUrl}buildStatus/icon?job=${fullJobName}&build=${it.run.number}"/> | ||
<j:set var="publicText" value="${app.rootUrl}buildStatus/text?job=${fullJobName}&build=${it.run.number}"/> | ||
|
||
<l:layout title="${%Embeddable Build Status Icon}" type="one-column"> | ||
<l:header> | ||
<link rel='stylesheet' href='${app.rootUrl}/plugin/embeddable-build-status/css/design.css' type='text/css'/> | ||
</l:header> | ||
<l:main-panel> | ||
<h1>${%Embeddable Build Status Icon}</h1> | ||
<p>${%blurb}</p> | ||
|
||
<h2>${%Examples}</h2> | ||
<small>${%examples_note}</small> | ||
|
||
<j:set var="flatCustomSubjectUrl" value="${badgeUrl}?subject=Custom%20Subject&status=Any%20State&color=darkturquoise"/> | ||
|
||
<h3 class="help-format">${%flat}</h3> | ||
<img id='${badgeUrl}' src='${badgeUrl}' title='${badgeUrl}'/> | ||
<br/> | ||
<img id='${badgeUrl}-custom' src='${flatCustomSubjectUrl}' title='${flatCustomSubjectUrl}'/> | ||
|
||
<j:set var="flatSquareUrl" value="${badgeUrl}?style=flat-square"/> | ||
<j:set var="flatSquareCustomSubjectUrl" value="${badgeUrl}?style=flat-square&subject=Custom%20Subject&status=Any%20State&color=darkturquoise"/> | ||
|
||
<h3 class="help-format">${%flat-square}</h3> | ||
<img src='${flatSquareUrl}' title='${flatSquareUrl}'/> | ||
<br/> | ||
<img src='${flatSquareCustomSubjectUrl}' title='${flatSquareCustomSubjectUrl}'/> | ||
|
||
<j:set var="plasticUrl" value="${badgeUrl}?style=plastic"/> | ||
<j:set var="plasticCustomSubjectUrl" value="${badgeUrl}?style=plastic&subject=Custom%20Subject&status=Any%20State&color=darkturquoise"/> | ||
|
||
<h3 class="help-format">${%plastic}</h3> | ||
<img src='${plasticUrl}' title='${plasticUrl}'/> | ||
<br/> | ||
<img src='${plasticCustomSubjectUrl}' title='${plasticCustomSubjectUrl}'/> | ||
|
||
<j:set var="ball16Url" value="${badgeUrl}?style=ball-16x16"/> | ||
<j:set var="ball32Url" value="${badgeUrl}?style=ball-32x32"/> | ||
|
||
<h3 class="help-format">${%ball-size}</h3> | ||
<img src='${ball16Url}' title='${ball16Url}'/> | ||
<br/> | ||
<img src='${ball32Url}' title='${ball32Url}'/> | ||
|
||
<h2>${%Links}</h2> | ||
|
||
<h3 class="help-format">${%Plain link}</h3> | ||
<p> | ||
<b>${%Protected}</b> <l:copyButton text="${badgeUrl}"/> | ||
<br/> | ||
${badgeUrl} | ||
</p> | ||
<p> | ||
<b>${%Unprotected}</b> <l:copyButton text="${publicBadge}"/> | ||
<br/> | ||
${publicBadge} | ||
</p> | ||
|
||
<j:set var="markdownProtectedLink" value="[](${jobUrl})"/> | ||
<j:set var="markdownUnprotectedLink" value="[](${jobUrl})"/> | ||
|
||
<h3 class="help-format">${%Markdown}</h3> | ||
<p> | ||
<b>${%Protected}</b> <l:copyButton text="${markdownProtectedLink}"/> | ||
<br/> | ||
${markdownProtectedLink} | ||
</p> | ||
<p> | ||
<b>${%Unprotected}</b> <l:copyButton text="${markdownUnprotectedLink}"/> | ||
<br/> | ||
${markdownUnprotectedLink} | ||
</p> | ||
|
||
<j:set var="htmlProtectedLink" value="<a href='${jobUrl}'><img src='${badgeUrl}'></a>"/> | ||
<j:set var="htmlUnprotectedLink" value="<a href='${jobUrl}'><img src='${publicBadge}'></a>"/> | ||
|
||
<h3 class="help-format">${%HTML}</h3> | ||
<p> | ||
<b>${%Protected}</b> <l:copyButton text="${htmlProtectedLink}"/> | ||
<br/> | ||
${htmlProtectedLink} | ||
</p> | ||
<p> | ||
<b>${%Unprotected}</b> <l:copyButton text="${htmlUnprotectedLink}"/> | ||
<br/> | ||
${htmlUnprotectedLink} | ||
</p> | ||
|
||
<j:set var="asciidocProtectedLink" value="image:${badgeUrl}[link='${jobUrl}']"/> | ||
<j:set var="asciidocUnprotectedLink" value="image:${publicBadge})[link='${jobUrl}']"/> | ||
|
||
<h3 class="help-format">${%Asciidoc}</h3> | ||
<p> | ||
<b>${%Protected}</b> <l:copyButton text="${asciidocProtectedLink}"/> | ||
<br/> | ||
${asciidocProtectedLink} | ||
</p> | ||
<p> | ||
<b>${%Unprotected}</b> <l:copyButton text="${asciidocUnprotectedLink}"/> | ||
<br/> | ||
${asciidocUnprotectedLink} | ||
</p> | ||
|
||
<j:set var="confluenceProtectedLink" value="[!${badgeUrl}!|${jobUrl}]"/> | ||
<j:set var="confluenceUnprotectedLink" value="[!${publicBadge}!|${jobUrl}]"/> | ||
|
||
<h3 class="help-format">${%Confluence}</h3> | ||
<p> | ||
<b>${%Protected}</b> <l:copyButton text="${confluenceProtectedLink}"/> | ||
<br/> | ||
${confluenceProtectedLink} | ||
</p> | ||
<p> | ||
<b>${%Unprotected}</b> <l:copyButton text="${confluenceUnprotectedLink}"/> | ||
<br/> | ||
${confluenceUnprotectedLink} | ||
</p> | ||
|
||
<j:set var="xwikiProtectedLink" value="[[image:${badgeUrl}>>${jobUrl}||target='__new']]"/> | ||
<j:set var="xwikiUnprotectedLink" value="[[image:${publicBadge}>>${jobUrl}||target='__new']]"/> | ||
|
||
<h3 class="help-format">${%XWiki}</h3> | ||
<p> | ||
<b>${%Protected}</b> <l:copyButton text="${xwikiProtectedLink}"/> | ||
<br/> | ||
${xwikiProtectedLink} | ||
</p> | ||
<p> | ||
<b>${%Unprotected}</b> <l:copyButton text="${xwikiUnprotectedLink}"/> | ||
<br/> | ||
${xwikiUnprotectedLink} | ||
</p> | ||
|
||
<j:set var="rdocProtectedLink" value="{<img src='${badgeUrl}'/>}[${jobUrl}]"/> | ||
<j:set var="rdocUnprotectedLink" value="{<img src='${publicBadge}'/>}[${jobUrl}]"/> | ||
|
||
<h3 class="help-format">${%RDoc}</h3> | ||
<p> | ||
<b>${%Protected}</b> <l:copyButton text="${rdocProtectedLink}"/> | ||
<br/> | ||
${rdocProtectedLink} | ||
</p> | ||
<p> | ||
<b>${%Unprotected}</b> <l:copyButton text="${rdocUnprotectedLink}"/> | ||
<br/> | ||
${rdocUnprotectedLink} | ||
</p> | ||
|
||
<j:set var="textileProtectedLink" value=""!${badgeUrl}!":${jobUrl}"/> | ||
<j:set var="textileUnprotectedLink" value=""!${publicBadge}!":${jobUrl}"/> | ||
|
||
<h3 class="help-format">${%Textile}</h3> | ||
<p> | ||
<b>${%Protected}</b> <l:copyButton text="${textileProtectedLink}"/> | ||
<br/> | ||
${textileProtectedLink} | ||
</p> | ||
<p> | ||
<b>${%Unprotected}</b> <l:copyButton text="${textileUnprotectedLink}"/> | ||
<br/> | ||
${textileUnprotectedLink} | ||
</p> | ||
|
||
<j:set var="bitbucketProtectedLink" value="[Build Status](${badgeUrl} "${jobUrl}")"/> | ||
<j:set var="bitbucketUnprotectedLink" value="[Build Status](${publicBadge} "${jobUrl}")"/> | ||
|
||
<h3 class="help-format">${%Bitbucket}</h3> | ||
<p> | ||
<b>${%Protected}</b> <l:copyButton text="${bitbucketProtectedLink}"/> | ||
<br/> | ||
${bitbucketProtectedLink} | ||
</p> | ||
<p> | ||
<b>${%Unprotected}</b> <l:copyButton text="${bitbucketUnprotectedLink}"/> | ||
<br/> | ||
${bitbucketUnprotectedLink} | ||
</p> | ||
|
||
<h2>${%Embeddable Build Status Text}</h2> | ||
<p>${%blurb_text}</p> | ||
|
||
<h3 class="help-format">${%Text Only}</h3> | ||
<p> | ||
<b>${%Protected}</b> <l:copyButton text="${textUrl}"/> | ||
<br/> | ||
${textUrl} | ||
</p> | ||
<p> | ||
<b>${%Unprotected}</b> <l:copyButton text="${publicText}"/> | ||
<br/> | ||
${publicText} | ||
</p> | ||
|
||
</l:main-panel> | ||
</l:layout> | ||
</j:jelly> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
src/test/java/org/jenkinsci/plugins/badge/actions/JobBadgeActionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright 2023 Mark Waite. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package org.jenkinsci.plugins.badge.actions; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.CoreMatchers.nullValue; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
import hudson.model.FreeStyleProject; | ||
import hudson.model.Result; | ||
import org.junit.BeforeClass; | ||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
|
||
public class JobBadgeActionTest { | ||
|
||
@ClassRule | ||
public static JenkinsRule j = new JenkinsRule(); | ||
|
||
private static final String NOT_BUILT_JOB_NAME = "not-built-job"; | ||
private static JobBadgeAction notBuiltAction; | ||
|
||
private static final String SUCCESSFUL_JOB_NAME = "successful-job"; | ||
private static JobBadgeAction successfulAction; | ||
|
||
public JobBadgeActionTest() {} | ||
|
||
@BeforeClass | ||
public static void createAction() throws Exception { | ||
/* Build a job for assertions on successful jobs */ | ||
FreeStyleProject successfulJob = j.createFreeStyleProject(SUCCESSFUL_JOB_NAME); | ||
j.buildAndAssertStatus(Result.SUCCESS, successfulJob); | ||
successfulAction = new JobBadgeAction(successfulJob); | ||
|
||
/* Define a job and do not build it for assertions on jobs that have not been built */ | ||
FreeStyleProject notBuiltJob = j.createFreeStyleProject(NOT_BUILT_JOB_NAME); | ||
notBuiltAction = new JobBadgeAction(notBuiltJob); | ||
} | ||
|
||
@Test | ||
public void testGetIconFileName() { | ||
assertThat(notBuiltAction.getIconFileName(), is(nullValue())); | ||
assertThat(successfulAction.getIconFileName(), is(nullValue())); | ||
} | ||
|
||
@Test | ||
public void testGetIconClassName() { | ||
assertThat(notBuiltAction.getIconClassName(), is("symbol-shield-outline plugin-ionicons-api")); | ||
assertThat(successfulAction.getIconClassName(), is("symbol-shield-outline plugin-ionicons-api")); | ||
} | ||
|
||
@Test | ||
public void testGetDisplayName() { | ||
assertThat(notBuiltAction.getDisplayName(), is("Embeddable Build Status")); | ||
assertThat(successfulAction.getDisplayName(), is("Embeddable Build Status")); | ||
} | ||
|
||
@Test | ||
public void testGetUrlName() { | ||
assertThat(notBuiltAction.getUrlName(), is("badge")); | ||
assertThat(successfulAction.getUrlName(), is("badge")); | ||
} | ||
|
||
@Test | ||
public void testGetUrl() { | ||
assertThat(notBuiltAction.getUrl(), is("")); | ||
assertThat(successfulAction.getUrl(), is("")); | ||
} | ||
|
||
@Test | ||
public void testGetUrlEncodedFullName() { | ||
assertThat(notBuiltAction.getUrlEncodedFullName(), is(NOT_BUILT_JOB_NAME)); | ||
assertThat(successfulAction.getUrlEncodedFullName(), is(SUCCESSFUL_JOB_NAME)); | ||
} | ||
|
||
@Test | ||
public void testDoText() { | ||
assertThat(notBuiltAction.doText(), is("Not built")); | ||
assertThat(successfulAction.doText(), is("Success")); | ||
} | ||
} |