From 7c532eec7131c275b8805cc0234a62a2e7c45bb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Contreras?= Date: Sat, 9 Oct 2021 19:40:06 +0000 Subject: [PATCH] [NETBEANS-6118] - Fix test failures in 'j2ee.core' (#3226) - Fix test failures - Add missing tests - Remove redundant if statement --- .../org/netbeans/api/j2ee/core/Profile.java | 8 ++---- .../netbeans/api/j2ee/core/ProfileTest.java | 28 +++++++++++++++---- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/enterprise/j2ee.core/src/org/netbeans/api/j2ee/core/Profile.java b/enterprise/j2ee.core/src/org/netbeans/api/j2ee/core/Profile.java index c620391a18aa..5e7d70e82e60 100644 --- a/enterprise/j2ee.core/src/org/netbeans/api/j2ee/core/Profile.java +++ b/enterprise/j2ee.core/src/org/netbeans/api/j2ee/core/Profile.java @@ -244,12 +244,8 @@ private static boolean isVersionEqualOrHigher(@NonNull Profile profileToCompare, if (profileToCompareVersion.equals(comparingProfileVersion)) { return compareWebAndFull(profileToCompare, comparingVersion); } else { - if (comparisonResult > 0) { - // profileToCompare has lower version than comparingVersion - return false; - } else { - return true; - } + // profileToCompare has lower version than comparingVersion + return comparisonResult <= 0; } } } diff --git a/enterprise/j2ee.core/test/unit/src/org/netbeans/api/j2ee/core/ProfileTest.java b/enterprise/j2ee.core/test/unit/src/org/netbeans/api/j2ee/core/ProfileTest.java index e31af7c9471b..b1f2bd091c6c 100644 --- a/enterprise/j2ee.core/test/unit/src/org/netbeans/api/j2ee/core/ProfileTest.java +++ b/enterprise/j2ee.core/test/unit/src/org/netbeans/api/j2ee/core/ProfileTest.java @@ -39,6 +39,22 @@ public void testFromPropertiesString() { assertEquals(Profile.JAVA_EE_6_FULL, Profile.fromPropertiesString("EE_6_FULL")); assertEquals(Profile.JAVA_EE_6_WEB, Profile.fromPropertiesString("1.6-web")); assertEquals(Profile.JAVA_EE_6_WEB, Profile.fromPropertiesString("EE_6_WEB")); + assertEquals(Profile.JAVA_EE_7_FULL, Profile.fromPropertiesString("1.7")); + assertEquals(Profile.JAVA_EE_7_FULL, Profile.fromPropertiesString("EE_7_FULL")); + assertEquals(Profile.JAVA_EE_7_WEB, Profile.fromPropertiesString("1.7-web")); + assertEquals(Profile.JAVA_EE_7_WEB, Profile.fromPropertiesString("EE_7_WEB")); + assertEquals(Profile.JAVA_EE_8_FULL, Profile.fromPropertiesString("1.8")); + assertEquals(Profile.JAVA_EE_8_FULL, Profile.fromPropertiesString("EE_8_FULL")); + assertEquals(Profile.JAVA_EE_8_WEB, Profile.fromPropertiesString("1.8-web")); + assertEquals(Profile.JAVA_EE_8_WEB, Profile.fromPropertiesString("EE_8_WEB")); + assertEquals(Profile.JAKARTA_EE_8_FULL, Profile.fromPropertiesString("8.0")); + assertEquals(Profile.JAKARTA_EE_8_FULL, Profile.fromPropertiesString("JAKARTA_EE_8_FULL")); + assertEquals(Profile.JAKARTA_EE_8_WEB, Profile.fromPropertiesString("8.0-web")); + assertEquals(Profile.JAKARTA_EE_8_WEB, Profile.fromPropertiesString("JAKARTA_EE_8_WEB")); + assertEquals(Profile.JAKARTA_EE_9_FULL, Profile.fromPropertiesString("9.0")); + assertEquals(Profile.JAKARTA_EE_9_FULL, Profile.fromPropertiesString("JAKARTA_EE_9_FULL")); + assertEquals(Profile.JAKARTA_EE_9_WEB, Profile.fromPropertiesString("9.0-web")); + assertEquals(Profile.JAKARTA_EE_9_WEB, Profile.fromPropertiesString("JAKARTA_EE_9_WEB")); assertNull(Profile.fromPropertiesString("something")); } @@ -97,8 +113,8 @@ public void testIsHigherJavaEEVersionJakartaEE8full() { assertFalse(Profile.JAVA_EE_6_FULL.isAtLeast(Profile.JAKARTA_EE_8_WEB)); assertFalse(Profile.JAVA_EE_7_WEB.isAtLeast(Profile.JAKARTA_EE_8_WEB)); assertFalse(Profile.JAVA_EE_7_FULL.isAtLeast(Profile.JAKARTA_EE_8_WEB)); - assertTrue(Profile.JAVA_EE_8_WEB.isAtLeast(Profile.JAKARTA_EE_8_WEB)); - assertTrue(Profile.JAVA_EE_8_FULL.isAtLeast(Profile.JAKARTA_EE_8_WEB)); + assertFalse(Profile.JAVA_EE_8_WEB.isAtLeast(Profile.JAKARTA_EE_8_WEB)); + assertFalse(Profile.JAVA_EE_8_FULL.isAtLeast(Profile.JAKARTA_EE_8_WEB)); assertTrue(Profile.JAKARTA_EE_8_WEB.isAtLeast(Profile.JAKARTA_EE_8_WEB)); assertTrue(Profile.JAKARTA_EE_8_FULL.isAtLeast(Profile.JAKARTA_EE_8_WEB)); } @@ -112,10 +128,10 @@ public void testIsHigherJavaEEVersionJakartaEE9full() { assertFalse(Profile.JAVA_EE_6_FULL.isAtLeast(Profile.JAKARTA_EE_9_WEB)); assertFalse(Profile.JAVA_EE_7_WEB.isAtLeast(Profile.JAKARTA_EE_9_WEB)); assertFalse(Profile.JAVA_EE_7_FULL.isAtLeast(Profile.JAKARTA_EE_9_WEB)); - assertTrue(Profile.JAVA_EE_8_WEB.isAtLeast(Profile.JAKARTA_EE_9_WEB)); - assertTrue(Profile.JAVA_EE_8_FULL.isAtLeast(Profile.JAKARTA_EE_9_WEB)); - assertTrue(Profile.JAKARTA_EE_8_WEB.isAtLeast(Profile.JAKARTA_EE_9_WEB)); - assertTrue(Profile.JAKARTA_EE_8_FULL.isAtLeast(Profile.JAKARTA_EE_9_WEB)); + assertFalse(Profile.JAVA_EE_8_WEB.isAtLeast(Profile.JAKARTA_EE_9_WEB)); + assertFalse(Profile.JAVA_EE_8_FULL.isAtLeast(Profile.JAKARTA_EE_9_WEB)); + assertFalse(Profile.JAKARTA_EE_8_WEB.isAtLeast(Profile.JAKARTA_EE_9_WEB)); + assertFalse(Profile.JAKARTA_EE_8_FULL.isAtLeast(Profile.JAKARTA_EE_9_WEB)); assertTrue(Profile.JAKARTA_EE_9_WEB.isAtLeast(Profile.JAKARTA_EE_9_WEB)); assertTrue(Profile.JAKARTA_EE_9_FULL.isAtLeast(Profile.JAKARTA_EE_9_WEB)); }