Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
run: bash ./tools/pr-checker/checker.sh ${{ github.repository }} ${{ github.event.pull_request.number }} | tee checker.log
- id: Lint-Code-Base
if: always()
uses: github/super-linter@v3
uses: github/super-linter@v3.17.0
env:
VALIDATE_ALL_CODEBASE: false
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -46,10 +46,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 8
java-version: 11
- run: unset _JAVA_OPTIONS

- name: Run tests
Expand Down
6 changes: 3 additions & 3 deletions finish/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>8.0.0</version>
<version>9.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>4.1</version>
<version>5.0</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
Expand All @@ -42,7 +42,7 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.8.1</version>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
51 changes: 23 additions & 28 deletions finish/src/main/java/io/openliberty/guides/testing/Person.java
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
/*
* Copyright (c) 2019 IBM Corporation and others
// tag::copyright[]
/*******************************************************************************
* Copyright (c) 2019, 2022 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Contributors:
* IBM Corporation - Initial implementation
*******************************************************************************/
// end::copyright[]
package io.openliberty.guides.testing;

import java.util.Objects;
import java.util.Random;

import javax.json.bind.annotation.JsonbCreator;
import javax.json.bind.annotation.JsonbProperty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.PositiveOrZero;
import javax.validation.constraints.Size;
import jakarta.json.bind.annotation.JsonbCreator;
import jakarta.json.bind.annotation.JsonbProperty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.PositiveOrZero;
import jakarta.validation.constraints.Size;

public class Person {

private static final Random r = new Random();
private static final Random R = new Random();

@NotNull
public final long id;
Expand All @@ -52,17 +46,18 @@ public Person(@JsonbProperty("name") String name,
@JsonbProperty("id") Long id) {
this.name = name;
this.age = age;
this.id = id == null ? r.nextLong() : id;
this.id = id == null ? R.nextLong() : id;
}

@Override
public boolean equals(Object obj) {
if (obj == null || !(obj instanceof Person))
if (obj == null || !(obj instanceof Person)) {
return false;
}
Person other = (Person) obj;
return Objects.equals(id, other.id) &&
Objects.equals(name, other.name) &&
Objects.equals(age, other.age);
return Objects.equals(id, other.id)
&& Objects.equals(name, other.name)
&& Objects.equals(age, other.age);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,44 +1,36 @@
// tag::copyright[]
/*
* Copyright (c) 2019 IBM Corporation and others
/*******************************************************************************
* Copyright (c) 2019, 2022 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Contributors:
* IBM Corporation - Initial implementation
*******************************************************************************/
// end::copyright[]
package io.openliberty.guides.testing;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import javax.enterprise.context.ApplicationScoped;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.PositiveOrZero;
import javax.validation.constraints.Size;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.PositiveOrZero;
import jakarta.validation.constraints.Size;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.NotFoundException;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;

@Path("/people")
@ApplicationScoped
Expand All @@ -57,13 +49,15 @@ public Collection<Person> getAllPeople() {
@Path("/{personId}")
public Person getPerson(@PathParam("personId") long id) {
Person foundPerson = personRepo.get(id);
if (foundPerson == null)
if (foundPerson == null) {
personNotFound(id);
}
return foundPerson;
}

@POST
public Long createPerson(@QueryParam("name") @NotEmpty @Size(min=2, max=50) String name,
public Long createPerson(@QueryParam("name") @NotEmpty @Size(min = 2, max = 50)
String name,
@QueryParam("age") @PositiveOrZero int age) {
Person p = new Person(name, age);
personRepo.put(p.id, p);
Expand All @@ -74,20 +68,22 @@ public Long createPerson(@QueryParam("name") @NotEmpty @Size(min=2, max=50) Stri
@Path("/{personId}")
public void updatePerson(@PathParam("personId") long id, @Valid Person p) {
Person toUpdate = getPerson(id);
if (toUpdate == null)
if (toUpdate == null) {
personNotFound(id);
}
personRepo.put(id, p);
}

@DELETE
@Path("/{personId}")
public void removePerson(@PathParam("personId") long id) {
Person toDelete = personRepo.get(id);
if (toDelete == null)
if (toDelete == null) {
personNotFound(id);
}
personRepo.remove(id);
}

private void personNotFound(long id) {
throw new NotFoundException("Person with id " + id + " not found.");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
/*
* Copyright (c) 2019 IBM Corporation and others
// tag::copyright[]
/*******************************************************************************
* Copyright (c) 2019, 2022 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Contributors:
* IBM Corporation - Initial implementation
*******************************************************************************/
// end::copyright[]
package io.openliberty.guides.testing;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;

@ApplicationPath("/")
public class PersonServiceApp extends Application { }
14 changes: 7 additions & 7 deletions finish/src/main/liberty/config/server.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<server>

<featureManager>
<feature>jaxrs-2.1</feature>
<feature>jsonb-1.0</feature>
<feature>restfulWS-3.0</feature>
<feature>jsonb-2.0</feature>
<!-- tag::mpHealth[] -->
<feature>mpHealth-3.1</feature>
<feature>mpHealth-4.0</feature>
<!-- end::mpHealth[] -->
<feature>mpConfig-2.0</feature>
<feature>mpRestClient-2.0</feature>
<feature>beanValidation-2.0</feature>
<feature>cdi-2.0</feature>
<feature>mpConfig-3.0</feature>
<feature>mpRestClient-3.0</feature>
<feature>beanValidation-3.0</feature>
<feature>cdi-3.0</feature>
</featureManager>

</server>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// tag::copyright[]
/*******************************************************************************
* Copyright (c) 2019, 2021 IBM Corporation and others.
* Copyright (c) 2019, 2022 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand All @@ -14,8 +14,8 @@

import static org.junit.jupiter.api.Assertions.assertThrows;

import javax.ws.rs.BadRequestException;
import javax.ws.rs.NotFoundException;
import jakarta.ws.rs.BadRequestException;
import jakarta.ws.rs.NotFoundException;

import org.junit.jupiter.api.Test;
// tag::importSharedContainerConfig[]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// tag::copyright[]
/*******************************************************************************
* Copyright (c) 2019, 2021 IBM Corporation and others.
* Copyright (c) 2019, 2022 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand All @@ -14,8 +14,8 @@

import static org.junit.jupiter.api.Assertions.assertThrows;

import javax.ws.rs.BadRequestException;
import javax.ws.rs.NotFoundException;
import jakarta.ws.rs.BadRequestException;
import jakarta.ws.rs.NotFoundException;

import org.junit.jupiter.api.Test;
import org.microshed.testing.jupiter.MicroShedTest;
Expand Down
6 changes: 3 additions & 3 deletions start/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>8.0.0</version>
<version>9.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>4.1</version>
<version>5.0</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
Expand All @@ -42,7 +42,7 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.8.1</version>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Loading