Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test case for OL issue 29893. #30431

Open
wants to merge 2 commits into
base: integration
Choose a base branch
from
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*******************************************************************************
* Copyright (c) 2024 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/

package io.openliberty.jpa.data.tests.models;

import jakarta.persistence.Entity;
import jakarta.persistence.Id;

@Entity
public class Vehicle {

@Id
private String id;

private String make;
private String model;
private int numSeats;
private float price;
private String vinId;
private String color;


public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getMake() {
return make;
}

public void setMake(String make) {
this.make = make;
}

public String getModel() {
return model;
}

public void setModel(String model) {
this.model = model;
}

public int getNumSeats() {
return numSeats;
}

public void setNumSeats(int numSeats) {
this.numSeats = numSeats;
}

public float getPrice() {
return price;
}

public void setPrice(float price) {
this.price = price;
}

public String getVinId() {
return vinId;
}

public void setVinId(String vinId) {
this.vinId = vinId;
}

public String getColor() {
return color;
}

public void setColor(String color) {
this.color = color;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import io.openliberty.jpa.data.tests.models.Segment;
import io.openliberty.jpa.data.tests.models.Store;
import io.openliberty.jpa.data.tests.models.Triangle;
import io.openliberty.jpa.data.tests.models.Vehicle;
import jakarta.annotation.Resource;
import jakarta.persistence.EntityManager;
import jakarta.persistence.LockModeType;
Expand Down Expand Up @@ -1635,6 +1636,41 @@ public void testOLGH29443ZonedDateTime() throws Exception {
}
}


@Test
//Reference issue: https://github.com/OpenLiberty/open-liberty/issues/29893
public void testOLGH29893() throws Exception {
String vehicleId = "V1234";
Vehicle vehicle = new Vehicle();
vehicle.setId(vehicleId);
vehicle.setModel("Toyota Corolla");
vehicle.setColor("Blue");

tx.begin();
em.persist(vehicle);
tx.commit();


String idToSearch = "v1234";
Vehicle result;

tx.begin();
try {
result = em.createQuery("FROM Vehicle WHERE LOWER(ID(THIS)) = ?1", Vehicle.class)
.setParameter(1, idToSearch.toLowerCase())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: (do not need to change) the variable idToSearch is unnecessary. You could have just used vehicleId.toLowerCase()

.getSingleResult();
tx.commit();
} catch (Exception e) {
tx.rollback();
throw e;
}

assertNotNull(result);
assertEquals(vehicleId, result.getId());
assertEquals("Toyota Corolla", result.getModel());
assertEquals("Blue", result.getColor());
}

@Test
@Ignore("Reference issue: https://github.com/OpenLiberty/open-liberty/issues/29475")
public void testOLGH29475() throws Exception {
Expand Down