Skip to content

touchbit/shields4j

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shields4j Master MavenCentral DocumentationStatus AlertStatus Coverage =======================================

Lightweight java HTTP-client for the shields.io service.

Full documentation is available on the shields4j.readthedocs.io

Briefly

Java client

Add dependency

<dependency>
    <groupId>org.touchbit.shields4j</groupId>
    <artifactId>client</artifactId>
    <version>${shields4j.version}</version>
</dependency>

If you need to get Shields4j versions that are not uploaded to maven central (snapshot/staging), add the Sonatype repository to your pom.xml

<repositories>
    <repository>
        <id>SonatypeNexus</id>
        <url>https://oss.sonatype.org/content/groups/staging/</url>
    </repository>
</repositories>

Minimal minimal

class Example {
    public static void main (String[] arg) {
        new ShieldsIO()
            .withLabel("Shields4J")
            .withMessage("1.0")
            .writeShieldToFile("minimal.svg");
    }
}

With logo and color background withlogo

class Example {
    public static void main (String[] arg) {
        new ShieldsIO()
            .withLabel("Shields4J")
            .withLabelColor(Color.BLUE)
            .withMessage("with Raspberry PI logo")
            .withMessageColor(Color.GREEN)
            .withStyle(Style.POPOUT)
            .withLogo(Logo.RASPBERRY_PI)
            .withLogoColor(Color.RED)
            .withLogoWidth(30)
            .writeShieldToFile("with-logo.svg");
    }
}

With custom logo and color background withcustomlogo

class Example {
    public static void main (String[] arg) {
         new ShieldsIO()
            .withLabel("Shields4J")
            .withLabelColor(Color.BLUE)
            .withMessage("with custom logo")
            .withMessageColor(Color.GREEN)
            .withStyle(Style.POPOUT)
            .withBase64Logo(new File("docs/img/status_success.svg"))
            .writeShieldToFile("with-custom-logo.svg");
    }
}

TestNG listener

Add dependency

<dependency>
    <groupId>org.touchbit.shields4j</groupId>
    <artifactId>testng</artifactId>
    <version>${shields4j.version}</version>
</dependency>

Add IShieldsListener to testNG iteststotal itestssuccesspercent

class Example {
    public static void main (String[] arg) {
         TestNG testNG = new TestNG();
         testNG.addListener(new IShieldsListener());
    }
}

or add IShieldsListener in your testng.xml file

<suite>
  <listeners>
    <listener class-name="org.touchbit.shields4j.testng.IShieldsListener" />
  </listeners>
</suite>

To customize the prefixes, create your own listener inherited from IShieldsListener integrationtesttotal integrationtestsuccesspercent

public class ShieldsListener extends IShieldsListener {
    public ShieldsListener() {
        withLabelPefix("Integration test");
        withFilePefix("testng");
    }
}