-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding two new static file extension folders for Java Specific Workfl…
…ows (#97) * Adding two new static file extension folders for Java Specific Workflows When using a spring boot application in Java, many of the static files will be placed in META-INF/resources. Right now these are treated like first class concepts, eventually moving the weight of Java application down far enough to not be selected. Signed-off-by: Shawn Hurley <[email protected]> * adding test case for the coolstore application Signed-off-by: Shawn Hurley <[email protected]> * Restructure test resource Signed-off-by: thepetk <[email protected]> * Increase number of total projects Signed-off-by: thepetk <[email protected]> --------- Signed-off-by: Shawn Hurley <[email protected]> Signed-off-by: thepetk <[email protected]> Co-authored-by: thepetk <[email protected]>
- Loading branch information
1 parent
e5e9330
commit 464fff4
Showing
98 changed files
with
178,693 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.redhat.coolstore</groupId> | ||
<artifactId>coolstore</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<name>coolstore-quarkus</name> | ||
<properties> | ||
<compiler-plugin.version>3.13.0</compiler-plugin.version> | ||
<maven.compiler.release>21</maven.compiler.release> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id> | ||
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id> | ||
<quarkus.platform.version>3.12.3</quarkus.platform.version> | ||
<skipITs>true</skipITs> | ||
<surefire-plugin.version>3.2.5</surefire-plugin.version> | ||
</properties> | ||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus.platform</groupId> | ||
<artifactId>quarkus-bom</artifactId> | ||
<version>${quarkus.platform.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-arc</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-jackson</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-client</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-client-jackson</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-hibernate-orm</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-jdbc-postgresql</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-flyway</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.flywaydb</groupId> | ||
<artifactId>flyway-database-postgresql</artifactId> | ||
<version>10.12.0</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-undertow</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-messaging</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-container-image-docker</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-minikube</artifactId> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>${quarkus.platform.group-id}</groupId> | ||
<artifactId>quarkus-maven-plugin</artifactId> | ||
<version>${quarkus.platform.version}</version> | ||
<extensions>true</extensions> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>build</goal> | ||
<goal>generate-code</goal> | ||
<goal>generate-code-tests</goal> | ||
<goal>native-image-agent</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>${compiler-plugin.version}</version> | ||
<configuration> | ||
<compilerArgs> | ||
<arg>-parameters</arg> | ||
</compilerArgs> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>${surefire-plugin.version}</version> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> | ||
<maven.home>${maven.home}</maven.home> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<version>${surefire-plugin.version}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>integration-test</goal> | ||
<goal>verify</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path> | ||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> | ||
<maven.home>${maven.home}</maven.home> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>native</id> | ||
<activation> | ||
<property> | ||
<name>native</name> | ||
</property> | ||
</activation> | ||
<properties> | ||
<skipITs>false</skipITs> | ||
<quarkus.native.enabled>true</quarkus.native.enabled> | ||
</properties> | ||
</profile> | ||
</profiles> | ||
</project> |
17 changes: 17 additions & 0 deletions
17
...jects/js-static-files-in-java-app/src/main/java/com/redhat/coolstore/utils/Producers.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,17 @@ | ||
package com.redhat.coolstore.utils; | ||
|
||
import jakarta.enterprise.inject.Produces; | ||
import jakarta.enterprise.inject.spi.InjectionPoint; | ||
import java.util.logging.Logger; | ||
|
||
|
||
public class Producers { | ||
|
||
Logger log = Logger.getLogger(Producers.class.getName()); | ||
|
||
@Produces | ||
public Logger produceLog(InjectionPoint injectionPoint) { | ||
return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName()); | ||
} | ||
|
||
} |
100 changes: 100 additions & 0 deletions
100
...ts/js-static-files-in-java-app/src/main/java/com/redhat/coolstore/utils/Transformers.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,100 @@ | ||
package com.redhat.coolstore.utils; | ||
|
||
import com.redhat.coolstore.model.CatalogItemEntity; | ||
import com.redhat.coolstore.model.Order; | ||
import com.redhat.coolstore.model.OrderItem; | ||
import com.redhat.coolstore.model.Product; | ||
import com.redhat.coolstore.model.ShoppingCart; | ||
import java.io.StringReader; | ||
import java.io.StringWriter; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import jakarta.json.Json; | ||
import jakarta.json.JsonArray; | ||
import jakarta.json.JsonArrayBuilder; | ||
import jakarta.json.JsonObject; | ||
import jakarta.json.JsonReader; | ||
import jakarta.json.JsonWriter; | ||
|
||
import java.util.concurrent.ThreadLocalRandom; | ||
import java.util.logging.Logger; | ||
|
||
/** | ||
* Created by tqvarnst on 2017-03-30. | ||
*/ | ||
public class Transformers { | ||
|
||
private static final String[] RANDOM_NAMES = {"Sven Karlsson","Johan Andersson","Karl Svensson","Anders Johansson","Stefan Olson","Martin Ericsson"}; | ||
private static final String[] RANDOM_EMAILS = {"[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]"}; | ||
|
||
private static Logger log = Logger.getLogger(Transformers.class.getName()); | ||
|
||
public static Product toProduct(CatalogItemEntity entity) { | ||
Product prod = new Product(); | ||
prod.setItemId(entity.getItemId()); | ||
prod.setName(entity.getName()); | ||
prod.setDesc(entity.getDesc()); | ||
prod.setPrice(entity.getPrice()); | ||
if (entity.getInventory() != null) { | ||
prod.setLocation(entity.getInventory().getLocation()); | ||
prod.setLink(entity.getInventory().getLink()); | ||
prod.setQuantity(entity.getInventory().getQuantity()); | ||
} else { | ||
log.warning("Inventory for " + entity.getName() + "[" + entity.getItemId()+ "] unknown and missing"); | ||
} | ||
return prod; | ||
} | ||
|
||
public static String shoppingCartToJson(ShoppingCart cart) { | ||
JsonArrayBuilder cartItems = Json.createArrayBuilder(); | ||
cart.getShoppingCartItemList().forEach(item -> { | ||
cartItems.add(Json.createObjectBuilder() | ||
.add("productSku",item.getProduct().getItemId()) | ||
.add("quantity",item.getQuantity()) | ||
); | ||
}); | ||
|
||
int randomNameAndEmailIndex = ThreadLocalRandom.current().nextInt(RANDOM_NAMES.length); | ||
|
||
JsonObject jsonObject = Json.createObjectBuilder() | ||
.add("orderValue", Double.valueOf(cart.getCartTotal())) | ||
.add("customerName",RANDOM_NAMES[randomNameAndEmailIndex]) | ||
.add("customerEmail",RANDOM_EMAILS[randomNameAndEmailIndex]) | ||
.add("retailPrice", cart.getShoppingCartItemList().stream().mapToDouble(i -> i.getQuantity()*i.getPrice()).sum()) | ||
.add("discount", Double.valueOf(cart.getCartItemPromoSavings())) | ||
.add("shippingFee", Double.valueOf(cart.getShippingTotal())) | ||
.add("shippingDiscount", Double.valueOf(cart.getShippingPromoSavings())) | ||
.add("items",cartItems) | ||
.build(); | ||
StringWriter w = new StringWriter(); | ||
try (JsonWriter writer = Json.createWriter(w)) { | ||
writer.write(jsonObject); | ||
} | ||
return w.toString(); | ||
} | ||
|
||
public static Order jsonToOrder(String json) { | ||
JsonReader jsonReader = Json.createReader(new StringReader(json)); | ||
JsonObject rootObject = jsonReader.readObject(); | ||
Order order = new Order(); | ||
order.setCustomerName(rootObject.getString("customerName")); | ||
order.setCustomerEmail(rootObject.getString("customerEmail")); | ||
order.setOrderValue(rootObject.getJsonNumber("orderValue").doubleValue()); | ||
order.setRetailPrice(rootObject.getJsonNumber("retailPrice").doubleValue()); | ||
order.setDiscount(rootObject.getJsonNumber("discount").doubleValue()); | ||
order.setShippingFee(rootObject.getJsonNumber("shippingFee").doubleValue()); | ||
order.setShippingDiscount(rootObject.getJsonNumber("shippingDiscount").doubleValue()); | ||
JsonArray jsonItems = rootObject.getJsonArray("items"); | ||
List<OrderItem> items = new ArrayList<OrderItem>(jsonItems.size()); | ||
for (JsonObject jsonItem : jsonItems.getValuesAs(JsonObject.class)) { | ||
OrderItem oi = new OrderItem(); | ||
oi.setProductId(jsonItem.getString("productSku")); | ||
oi.setQuantity(jsonItem.getInt("quantity")); | ||
items.add(oi); | ||
} | ||
order.setItemList(items); | ||
return order; | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.