Skip to content

Commit

Permalink
Merge pull request #156 from gsmet/tutorial-changes
Browse files Browse the repository at this point in the history
Proofread the tutorial
  • Loading branch information
kdubois committed May 23, 2024
2 parents d82bcdc + 8006a31 commit d228ba1
Show file tree
Hide file tree
Showing 22 changed files with 299 additions and 326 deletions.
20 changes: 10 additions & 10 deletions documentation/modules/ROOT/pages/01_setup.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ Please have them installed and configured before you get started with any of the
| `brew install maven`
| `dnf install maven`
| https://maven.apache.org/download.cgi[Windows] (Make sure you set the `MAVEN_HOME` environment variable and add `%MAVEN_HOME%\bin` to your `PATH`)
| **GraalVM [Optional *]**
| https://www.graalvm.org/latest/docs/getting-started/macos/[Download & install GraalVM for MacOS]
| **GraalVM for Java 21 [Optional]**
| https://www.graalvm.org/latest/docs/getting-started/macos/[Download & install GraalVM for macOS]
| https://www.graalvm.org/latest/docs/getting-started/linux/[Download & install GraalVM for Linux]
| https://www.graalvm.org/latest/docs/getting-started/windows/[Download & install GraalVM for Windows]
Expand All @@ -69,14 +69,14 @@ Alternatively on Windows you can also try https://chocolatey.org/[Chocolatey] wh
[.console-input]
[source,bash,subs="+macros,+attributes"]
----
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
.
sdk install java
sdk install maven
sdk install quarkus
sdk install java 21.0.3-tem
sdk install jbang
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install java
sdk install maven
sdk install quarkus
sdk install java 21.0.3-tem
sdk install jbang
----
=====
--
Expand Down
18 changes: 9 additions & 9 deletions documentation/modules/ROOT/pages/02_basics.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
====
Maven::
+
+
--
[.console-input]
[source,bash,subs="+macros,+attributes"]
Expand All @@ -20,11 +20,11 @@ cd {project-name}
Quarkus CLI::
+
--
The quarkus CLI tool lets you create projects, manage extensions and do essential dev, build and deploy commands using the underlying project build tool in a simplified way.
The quarkus CLI tool lets you create projects, manage extensions and do essential dev, build and deploy commands using the underlying project build tool in a simplified way.
Follow these instructions to install Quarkus CLI: https://quarkus.io/guides/cli-tooling
Then create the application:
Then create the application:
[.console-input]
[source,bash,subs="+macros,+attributes"]
----
Expand All @@ -49,7 +49,7 @@ Or else if you're a CLI person, you can run a `curl` command like:
[.console-input]
[source,bash]
----
curl localhost:8080/hello
curl -w '\n' localhost:8080/hello
----

[.console-output]
Expand Down Expand Up @@ -83,7 +83,7 @@ You can run the test in your IDE or by running the following:
[tabs%sync]
====
Maven::
+
+
--
[.console-input]
[source,bash,subs="+macros,+attributes"]
Expand Down Expand Up @@ -132,7 +132,7 @@ Let's start the _Live Coding_ mode by using the `dev` command. You probably won'
[tabs%sync]
====
Maven::
+
+
--
[.console-input]
[source,bash,subs="+macros,+attributes"]
Expand All @@ -152,7 +152,7 @@ quarkus dev
--
====

NOTE: By default Quarkus uses 'localhost' for the dev mode host setting. If you are working in a remote development environment, you may need to set the host to 0.0.0.0 by appending `-D"quarkus.http.host=0.0.0.0"` to the above command.
NOTE: By default Quarkus uses 'localhost' for the dev mode host setting. If you are working in a remote development environment, you may need to set the host to 0.0.0.0 by appending `-D"quarkus.http.host=0.0.0.0"` to the above command.

== Dev UI

Expand Down Expand Up @@ -182,6 +182,6 @@ Press `r` and the tests will start running. You should see the status change dow
All 1 test is passing (0 skipped), 1 test was run in 11705ms. Tests completed at 16:02:32.
----

TIP: If you don’t want to have continuous testing enabled, you can change this by adding `quarkus.test.continuous-testing=disabled` to your `src/main/resources/application.properties`.
TIP: If you don’t want to have continuous testing enabled, you can change this by adding `quarkus.test.continuous-testing=disabled` to your `src/main/resources/application.properties`.

You can find more details about controlling continuous testing in https://quarkus.io/guides/continuous-testing#controlling-continuous-testing[this guide].
You can find more details about controlling continuous testing in https://quarkus.io/guides/continuous-testing#controlling-continuous-testing[this guide].
40 changes: 17 additions & 23 deletions documentation/modules/ROOT/pages/03_configuration.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
= Configuration

Hardcoded values in your code is a no go, so let's see how to add configuration to your application.
Hardcoded values in your code is a no go, so let's see how to add configuration to your application.
Quarkus relies on the MicroProfile Config specification and the main configuration file is `application.properties`.

== Using a config property in your code
Expand Down Expand Up @@ -38,23 +38,17 @@ If you refresh your browser pointing to http://localhost:8080/hello[window="_bla
[.console-output]
[source,text]
----
jakarta.enterprise.inject.spi.DeploymentException: No config value of type [java.lang.String] exists for: greeting
at io.quarkus.arc.runtime.ConfigRecorder.validateConfigProperties(ConfigRecorder.java:37)
at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigProperties61.deploy_0(ConfigBuildStep$validateConfigProperties61.zig:120)
at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigProperties61.deploy(ConfigBuildStep$validateConfigProperties61.zig:36)
at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:166)
at io.quarkus.runtime.Application.start(Application.java:89)
at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:90)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:61)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:38)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:106)
at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:99)
at java.base/java.lang.Thread.run(Thread.java:834)
io.quarkus.runtime.configuration.ConfigurationException: Failed to load config value of type class java.lang.String for: greeting
at io.quarkus.arc.runtime.ConfigRecorder.validateConfigProperties(ConfigRecorder.java:70)
at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigValues1665125174.deploy_0(Unknown Source)
at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigValues1665125174.deploy(Unknown Source)
at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
at io.quarkus.runtime.Application.start(Application.java:101)
at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:111)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:124)
at io.quarkus.runner.GeneratedMain.main(Unknown Source)
----

Which is expected, since we didn't provide the `greeting` property neither at the `application.properties` file nor with some runtime configuration.
Expand All @@ -78,7 +72,7 @@ You can also use `curl` to check the same result:
[.console-input]
[source,bash]
----
curl localhost:8080/hello
curl -w '\n' localhost:8080/hello
----

[.console-output]
Expand All @@ -87,9 +81,9 @@ curl localhost:8080/hello
Hello y'all!
----

== Update your integration test
== Update your test

Since we changed the output of our `/hello` endpoint, our integration test doesn't pass anymore.
Since we changed the output of our `/hello` endpoint, our test doesn't pass anymore.

Let's update `GreetingResourceTest` to reflect our recent changes:

Expand Down Expand Up @@ -136,7 +130,7 @@ Now run your tests to check if everything is ok:
[tabs]
====
Maven::
+
+
--
[.console-input]
[source,bash,subs="+macros,+attributes"]
Expand Down Expand Up @@ -177,7 +171,7 @@ quarkus test
[tabs]
====
Maven::
+
+
--
[.console-input]
[source,bash,subs="+macros,+attributes"]
Expand Down
49 changes: 24 additions & 25 deletions documentation/modules/ROOT/pages/04_panache.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
:project-name: tutorial-app

[#quarkusp-demo-overview]
== Demo Overview
== Demo Overview

You'll learn how easy and productive Quarkus is with Hibernate with Panache. For this, we'll develop a simple CRUD REST API that handles information about fruits.

Expand All @@ -21,12 +21,12 @@ Just open a new terminal window, and make sure you're at the root of your `{proj
[tabs]
====
Maven::
+
+
--
[.console-input]
[source,bash,subs="+macros,+attributes"]
----
./mvnw quarkus:add-extension -Dextension="rest-jsonb, jdbc-h2, hibernate-orm-panache, smallrye-openapi"
./mvnw quarkus:add-extension -Dextension="rest-jackson, jdbc-h2, hibernate-orm-panache, smallrye-openapi"
----
--
Expand All @@ -36,7 +36,7 @@ Quarkus CLI::
[.console-input]
[source,bash,subs="+macros,+attributes"]
----
quarkus extension add rest-jsonb jdbc-h2 hibernate-orm-panache smallrye-openapi
quarkus extension add rest-jackson jdbc-h2 hibernate-orm-panache smallrye-openapi
----
--
====
Expand All @@ -45,7 +45,7 @@ quarkus extension add rest-jsonb jdbc-h2 hibernate-orm-panache smallrye-openapi
[.console-output]
[source,text]
----
✅ Adding extension io.quarkus:quarkus-rest-jsonb
✅ Adding extension io.quarkus:quarkus-rest-jackson
✅ Adding extension io.quarkus:quarkus-smallrye-openapi
✅ Adding extension io.quarkus:quarkus-hibernate-orm-panache
✅ Adding extension io.quarkus:quarkus-jdbc-h2
Expand Down Expand Up @@ -144,7 +144,7 @@ Now we should have everything in place to query our *GET* REST endpoint:
[.console-input]
[source,bash]
----
curl localhost:8080/fruit
curl -w '\n' localhost:8080/fruit
----

[.console-output]
Expand Down Expand Up @@ -190,20 +190,19 @@ public class FruitResource {
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response newFruit(Fruit fruit) {
fruit.id = null;
fruit.persist();
return Response.status(Status.CREATED).entity(fruit).build();
}
}
----

Now you can insert a new fruit by using `curl`:
Now you can insert a new fruit by using `curl`:

[.console-input]
[source,bash]
----
curl -d "{\"name\": \"Banana\", \"season\": \"Summer\"}" -H "Content-Type: application/json" http://localhost:8080/fruit
curl -w '\n' -d "{\"name\": \"Banana\", \"season\": \"Summer\"}" -H "Content-Type: application/json" http://localhost:8080/fruit
----

[.console-output]
Expand Down Expand Up @@ -237,16 +236,16 @@ Create the file `import.sql` in the folder `src/main/resources` with the followi
[.console-input]
[source,sql]
----
create sequence fruit_sequence start with 1 increment by 1;
INSERT INTO Fruit(id,name,season) VALUES (nextval('fruit_sequence'),'Mango','Spring');
INSERT INTO Fruit(id,name,season) VALUES (nextval('fruit_sequence'),'Strawberry','Spring');
INSERT INTO Fruit(id,name,season) VALUES (nextval('fruit_sequence'),'Orange','Winter');
INSERT INTO Fruit(id,name,season) VALUES (nextval('fruit_sequence'),'Lemon','Winter');
INSERT INTO Fruit(id,name,season) VALUES (nextval('fruit_sequence'),'Blueberry','Summer');
INSERT INTO Fruit(id,name,season) VALUES (nextval('fruit_sequence'),'Banana','Summer');
INSERT INTO Fruit(id,name,season) VALUES (nextval('fruit_sequence'),'Watermelon','Summer');
INSERT INTO Fruit(id,name,season) VALUES (nextval('fruit_sequence'),'Apple','Fall');
INSERT INTO Fruit(id,name,season) VALUES (nextval('fruit_sequence'),'Pear','Fall');
INSERT INTO Fruit(id,name,season) VALUES (1,'Mango','Spring');
INSERT INTO Fruit(id,name,season) VALUES (2,'Strawberry','Spring');
INSERT INTO Fruit(id,name,season) VALUES (3,'Orange','Winter');
INSERT INTO Fruit(id,name,season) VALUES (4,'Lemon','Winter');
INSERT INTO Fruit(id,name,season) VALUES (5,'Blueberry','Summer');
INSERT INTO Fruit(id,name,season) VALUES (6,'Banana','Summer');
INSERT INTO Fruit(id,name,season) VALUES (7,'Watermelon','Summer');
INSERT INTO Fruit(id,name,season) VALUES (8,'Apple','Fall');
INSERT INTO Fruit(id,name,season) VALUES (9,'Pear','Fall');
ALTER SEQUENCE fruit_seq RESTART WITH 10;
----

And append the following configuration in `application.properties`:
Expand Down Expand Up @@ -315,16 +314,16 @@ Now if you refresh your browser pointing to http://localhost:8080/fruit[window=_

[TIP]
====
You can add different `import.sql` files based on the application profile.
You can add different `import.sql` files based on the application profile.
For example: in dev mode, you
can use the configuration `quarkus.hibernate-orm.sql-load-script=import-dev.sql`,
For example: in dev mode, you
can use the configuration `quarkus.hibernate-orm.sql-load-script=import-dev.sql`,
while in production mode you can use `quarkus.hibernate-orm.sql-load-script=import-prod.sql`.
====

== Adding a custom finder to the `Fruit` Entity

Update the `Fruit` class to contain a finder method `findBySeason` like:
Update the `Fruit` class to contain a finder method `findBySeason` like:

[#quarkusp-find-fruits]
[.console-input]
Expand Down Expand Up @@ -403,7 +402,7 @@ Let's try to filter only the fruits with the *Summer* season:
[.console-input]
[source,bash]
----
curl localhost:8080/fruit?season=Summer
curl -w '\n' localhost:8080/fruit?season=Summer
----

[.console-output]
Expand Down Expand Up @@ -518,7 +517,7 @@ Let's try again to filter only the fruits with the *Spring* season:
[.console-input]
[source,bash]
----
curl localhost:8080/fruit?season=Spring
curl -w '\n' localhost:8080/fruit?season=Spring
----

[.console-output]
Expand Down
Loading

0 comments on commit d228ba1

Please sign in to comment.