From 05ffbac8828fa4b4eaf46ce5279067c890558463 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Mon, 7 Oct 2024 17:22:44 +0200 Subject: [PATCH] fix lastUnixUserId - 3rd try --- .../HsHostingAssetControllerAcceptanceTest.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java index 43cb0daf..30b62a5a 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java @@ -157,7 +157,7 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup ) ); final var givenParentAsset = givenParentAsset(MANAGED_SERVER, "vm1011"); - final var expectedUnixUserId = lastUnixUserId(); + final var expectedUnixUserId = nextUnixUserId(); final var location = RestAssured // @formatter:off .given() @@ -208,9 +208,11 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup .isEqualTo(""" HsHostingAsset(UNIX_USER, fir10, fir10 webspace user, MANAGED_WEBSPACE:fir10, { "password" : null, - "userid" : 1000000 + "userid" : {lastUnixUserId} }) - """.trim()); + """ + .replace("{lastUnixUserId}", expectedUnixUserId.toString()) + .trim()); } @Test @@ -781,10 +783,10 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup } - private Integer lastUnixUserId() { - final Object result = em.createNativeQuery("SELECT last_value from hs_hosting.asset_unixuser_system_id_seq", Integer.class) + private Integer nextUnixUserId() { + final Object result = em.createNativeQuery("SELECT nextval('hs_hosting.asset_unixuser_system_id_seq')", Integer.class) .getSingleResult(); - return (Integer) result; + return (Integer) result + 1; } }