Best Citrus code snippet using com.consol.citrus.arquillian.shrinkwrap.CitrusArchiveBuilder.transitivity
Source:CitrusArchiveBuilder.java
...29 * @since 2.230 */31public final class CitrusArchiveBuilder {32 /** Should include transitive dependency libraries */33 private boolean transitivity = true;34 /** Should resolve library dependencies in offline mode */35 private boolean offline = true;36 /** Citrus version to use */37 private String version = Citrus.getVersion();38 /** List of Citrus artifact names to resolve */39 private List<String> artifactCoordinates = new ArrayList<>();40 /**41 * Default constructor.42 */43 private CitrusArchiveBuilder() {44 }45 /**46 * Constructor using artifact version.47 * @param version48 */49 private CitrusArchiveBuilder(String version) {50 this.version = version;51 }52 /**53 * Initialize with default settings.54 * @return55 */56 public static final CitrusArchiveBuilder latestVersion() {57 return new CitrusArchiveBuilder();58 }59 /**60 * Initialize with default settings.61 * @return62 */63 public static final CitrusArchiveBuilder version(String version) {64 return new CitrusArchiveBuilder(version);65 }66 /**67 * Resolve artifacts for given coordinates.68 * @return69 */70 public File[] build() {71 MavenStrategyStage maven = Maven.configureResolver()72 .workOffline(offline)73 .resolve(artifactCoordinates);74 return applyTransitivity(maven).asFile();75 }76 /**77 * Gets the complete Citrus stack as resolved Maven dependency set.78 * @return79 */80 public CitrusArchiveBuilder all() {81 core();82 jms();83 kafka();84 jdbc();85 http();86 websocket();87 ws();88 ssh();89 ftp();90 mail();91 camel();92 vertx();93 docker();94 kubernetes();95 selenium();96 cucumber();97 zookeeper();98 rmi();99 jmx();100 restdocs();101 javaDsl();102 return this;103 }104 /**105 * Gets the core Citrus artifact as resolved Maven dependency set.106 * @return107 */108 public CitrusArchiveBuilder core() {109 artifactCoordinates.add(getCoordinates("citrus-core"));110 return this;111 }112 /**113 * Gets the jms Citrus artifact as resolved Maven dependency set.114 * @return115 */116 public CitrusArchiveBuilder jms() {117 artifactCoordinates.add(getCoordinates("citrus-jms"));118 return this;119 }120 /**121 * Gets the kafka Citrus artifact as resolved Maven dependency set.122 * @return123 */124 public CitrusArchiveBuilder kafka() {125 artifactCoordinates.add(getCoordinates("citrus-kafka"));126 return this;127 }128 /**129 * Gets the jdbc Citrus artifact as resolved Maven dependency set.130 * @return131 */132 public CitrusArchiveBuilder jdbc() {133 artifactCoordinates.add(getCoordinates("citrus-jdbc"));134 return this;135 }136 /**137 * Gets the http Citrus artifact as resolved Maven dependency set.138 * @return139 */140 public CitrusArchiveBuilder http() {141 artifactCoordinates.add(getCoordinates("citrus-http"));142 return this;143 }144 /**145 * Gets the http Citrus artifact as resolved Maven dependency set.146 * @return147 */148 public CitrusArchiveBuilder websocket() {149 artifactCoordinates.add(getCoordinates("citrus-websocket"));150 return this;151 }152 /**153 * Gets the ws Citrus artifact as resolved Maven dependency set.154 * @return155 */156 public CitrusArchiveBuilder ws() {157 artifactCoordinates.add(getCoordinates("citrus-ws"));158 return this;159 }160 /**161 * Gets the ftp Citrus artifact as resolved Maven dependency set.162 * @return163 */164 public CitrusArchiveBuilder ftp() {165 artifactCoordinates.add(getCoordinates("citrus-ftp"));166 return this;167 }168 /**169 * Gets the ssh Citrus artifact as resolved Maven dependency set.170 * @return171 */172 public CitrusArchiveBuilder ssh() {173 artifactCoordinates.add(getCoordinates("citrus-ssh"));174 return this;175 }176 /**177 * Gets the camel Citrus artifact as resolved Maven dependency set.178 * @return179 */180 public CitrusArchiveBuilder camel() {181 artifactCoordinates.add(getCoordinates("citrus-camel"));182 return this;183 }184 /**185 * Gets the docker Citrus artifact as resolved Maven dependency set.186 * @return187 */188 public CitrusArchiveBuilder docker() {189 artifactCoordinates.add(getCoordinates("citrus-docker"));190 return this;191 }192 /**193 * Gets the kubernetes Citrus artifact as resolved Maven dependency set.194 * @return195 */196 public CitrusArchiveBuilder kubernetes() {197 artifactCoordinates.add(getCoordinates("citrus-kubernetes"));198 return this;199 }200 /**201 * Gets the selenium Citrus artifact as resolved Maven dependency set.202 * @return203 */204 public CitrusArchiveBuilder selenium() {205 artifactCoordinates.add(getCoordinates("citrus-selenium"));206 return this;207 }208 /**209 * Gets the zookeeper Citrus artifact as resolved Maven dependency set.210 * @return211 */212 public CitrusArchiveBuilder zookeeper() {213 artifactCoordinates.add(getCoordinates("citrus-zookeeper"));214 return this;215 }216 /**217 * Gets the cucumber Citrus artifact as resolved Maven dependency set.218 * @return219 */220 public CitrusArchiveBuilder cucumber() {221 artifactCoordinates.add(getCoordinates("citrus-cucumber"));222 return this;223 }224 /**225 * Gets the rmi Citrus artifact as resolved Maven dependency set.226 * @return227 */228 public CitrusArchiveBuilder rmi() {229 artifactCoordinates.add(getCoordinates("citrus-rmi"));230 return this;231 }232 /**233 * Gets the jmx Citrus artifact as resolved Maven dependency set.234 * @return235 */236 public CitrusArchiveBuilder jmx() {237 artifactCoordinates.add(getCoordinates("citrus-jmx"));238 return this;239 }240 /**241 * Gets the restdocs Citrus artifact as resolved Maven dependency set.242 * @return243 */244 public CitrusArchiveBuilder restdocs() {245 artifactCoordinates.add(getCoordinates("citrus-restdocs"));246 return this;247 }248 /**249 * Gets the mail Citrus artifact as resolved Maven dependency set.250 * @return251 */252 public CitrusArchiveBuilder mail() {253 artifactCoordinates.add(getCoordinates("citrus-mail"));254 return this;255 }256 /**257 * Gets the vertx Citrus artifact as resolved Maven dependency set.258 * @return259 */260 public CitrusArchiveBuilder vertx() {261 artifactCoordinates.add(getCoordinates("citrus-vertx"));262 return this;263 }264 /**265 * Gets the Java DSL Citrus artifact as resolved Maven dependency set.266 * @return267 */268 public CitrusArchiveBuilder javaDsl() {269 artifactCoordinates.add(getCoordinates("citrus-java-dsl"));270 return this;271 }272 /**273 * Sets the transitivity on this resolver.274 * @param transitivity275 * @return276 */277 public CitrusArchiveBuilder transitivity(boolean transitivity) {278 this.transitivity = transitivity;279 return this;280 }281 /**282 * Sets the offline mode on this resolver.283 * @param offlineMode284 * @return285 */286 public CitrusArchiveBuilder workOffline(boolean offlineMode) {287 this.offline = offlineMode;288 return this;289 }290 /**291 * Based on transitivity setting apply transitivity to Maven strategy.292 * @param maven293 * @return294 */295 private FormatStage applyTransitivity(MavenStrategyStage maven) {296 if (transitivity) {297 return maven.withTransitivity();298 } else {299 return maven.withoutTransitivity();300 }301 }302 /**303 * Constructs Maven artifact coordinates with current version.304 * @param artifactId305 * @return306 */307 private String getCoordinates(String artifactId) {308 return String.format("com.consol.citrus:%s:%s", artifactId, version);309 }310}...
Source:CitrusArchiveBuilderTest.java
...31 @Test32 public void testResolveAll() {33 File[] artifactResources = CitrusArchiveBuilder34 .latestVersion()35 .transitivity(false)36 .all()37 .build();38 Assert.assertNotNull(artifactResources);39 Assert.assertEquals(artifactResources.length, 21);40 verifyArtifact(artifactResources, "citrus-core-.*jar");41 verifyArtifact(artifactResources, "citrus-jms-.*jar");42 verifyArtifact(artifactResources, "citrus-kafka-.*jar");43 verifyArtifact(artifactResources, "citrus-jdbc-.*jar");44 verifyArtifact(artifactResources, "citrus-http-.*jar");45 verifyArtifact(artifactResources, "citrus-websocket-.*jar");46 verifyArtifact(artifactResources, "citrus-ws-.*jar");47 verifyArtifact(artifactResources, "citrus-ftp-.*jar");48 verifyArtifact(artifactResources, "citrus-camel-.*jar");49 verifyArtifact(artifactResources, "citrus-ssh-.*jar");50 verifyArtifact(artifactResources, "citrus-mail-.*jar");51 verifyArtifact(artifactResources, "citrus-vertx-.*jar");52 verifyArtifact(artifactResources, "citrus-docker-.*jar");53 verifyArtifact(artifactResources, "citrus-kubernetes-.*jar");54 verifyArtifact(artifactResources, "citrus-selenium-.*jar");55 verifyArtifact(artifactResources, "citrus-cucumber-.*jar");56 verifyArtifact(artifactResources, "citrus-zookeeper-.*jar");57 verifyArtifact(artifactResources, "citrus-rmi-.*jar");58 verifyArtifact(artifactResources, "citrus-jmx-.*jar");59 verifyArtifact(artifactResources, "citrus-restdocs-.*jar");60 verifyArtifact(artifactResources, "citrus-java-dsl-.*jar");61 }62 @Test63 public void testResolveAllWithVersion() {64 File[] artifactResources = CitrusArchiveBuilder65 .version(Citrus.getVersion())66 .transitivity(false)67 .all()68 .build();69 Assert.assertNotNull(artifactResources);70 Assert.assertEquals(artifactResources.length, 21);71 verifyArtifact(artifactResources, "citrus-core-.*jar");72 verifyArtifact(artifactResources, "citrus-jms-.*jar");73 verifyArtifact(artifactResources, "citrus-kafka-.*jar");74 verifyArtifact(artifactResources, "citrus-jdbc-.*jar");75 verifyArtifact(artifactResources, "citrus-http-.*jar");76 verifyArtifact(artifactResources, "citrus-websocket-.*jar");77 verifyArtifact(artifactResources, "citrus-ws-.*jar");78 verifyArtifact(artifactResources, "citrus-ftp-.*jar");79 verifyArtifact(artifactResources, "citrus-camel-.*jar");80 verifyArtifact(artifactResources, "citrus-ssh-.*jar");81 verifyArtifact(artifactResources, "citrus-mail-.*jar");82 verifyArtifact(artifactResources, "citrus-vertx-.*jar");83 verifyArtifact(artifactResources, "citrus-docker-.*jar");84 verifyArtifact(artifactResources, "citrus-kubernetes-.*jar");85 verifyArtifact(artifactResources, "citrus-selenium-.*jar");86 verifyArtifact(artifactResources, "citrus-cucumber-.*jar");87 verifyArtifact(artifactResources, "citrus-zookeeper-.*jar");88 verifyArtifact(artifactResources, "citrus-rmi-.*jar");89 verifyArtifact(artifactResources, "citrus-jmx-.*jar");90 verifyArtifact(artifactResources, "citrus-restdocs-.*jar");91 verifyArtifact(artifactResources, "citrus-java-dsl-.*jar");92 }93 @Test94 public void testResolveSelective() {95 File[] artifactResources = CitrusArchiveBuilder96 .latestVersion()97 .transitivity(false)98 .jms()99 .build();100 Assert.assertNotNull(artifactResources);101 Assert.assertEquals(artifactResources.length, 1);102 verifyArtifact(artifactResources, "citrus-jms-.*jar");103 }104 @Test105 public void testResolveOnline() {106 File[] artifactResources = CitrusArchiveBuilder107 .latestVersion()108 .transitivity(false)109 .workOffline(false)110 .core()111 .build();112 Assert.assertNotNull(artifactResources);113 Assert.assertEquals(artifactResources.length, 1);114 verifyArtifact(artifactResources, "citrus-core-.*jar");115 }116 private void verifyArtifact(File[] artifactResources, String expectedFileNamePattern) {117 for (File artifactResource : artifactResources) {118 if (artifactResource.getName().matches(expectedFileNamePattern)) {119 return;120 }121 }122 Assert.fail("Missing artifact resource for file name pattern: " + expectedFileNamePattern);...
transitivity
Using AI Code Generation
1import com.consol.citrus.arquillian.shrinkwrap.CitrusArchiveBuilder;2import org.jboss.shrinkwrap.api.Archive;3import org.jboss.shrinkwrap.api.ShrinkWrap;4import org.jboss.shrinkwrap.api.spec.JavaArchive;5import org.jboss.shrinkwrap.api.spec.WebArchive;6import org.junit.Test;7import static org.junit.Assert.*;8public class 3 {9 public void testTransitivity() {10 WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war");11 JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "test.jar");12 Archive archive = CitrusArchiveBuilder.transitive().addAsLibrary(jar).addAsLibrary(war).build();13 assertTrue(archive.contains("test.jar"));14 assertTrue(archive.contains("test.war"));15 }16}17import com.consol.citrus.arquillian.shrinkwrap.CitrusArchiveBuilder;18import org.jboss.shrinkwrap.api.Archive;19import org.jboss.shrinkwrap.api.ShrinkWrap;20import org.jboss.shrinkwrap.api.spec.JavaArchive;21import org.jboss.shrinkwrap.api.spec.WebArchive;22import org.junit.Test;23import static org.junit.Assert.*;24public class 4 {25 public void testTransitivity() {26 WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war");27 JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "test.jar");28 Archive archive = CitrusArchiveBuilder.transitive().addAsLibrary(jar).addAsLibrary(war).build();29 assertTrue(archive.contains("test.jar"));30 assertTrue(archive.contains("test.war"));31 }32}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!