From 1848c25f4958e1c75402e6fed12d03a43069b855 Mon Sep 17 00:00:00 2001 From: Rajat Garg Date: Fri, 22 Jun 2018 00:33:53 +0530 Subject: [PATCH] Bael 1734 get file extension in java (#4522) * change method to return Optionals * add check for empty Optional * replace ifPresent() with get() * remove extra check --- .../test/java/com/baeldung/extension/ExtensionUnitTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core-java/src/test/java/com/baeldung/extension/ExtensionUnitTest.java b/core-java/src/test/java/com/baeldung/extension/ExtensionUnitTest.java index 14e05d6b95..680eea0cae 100644 --- a/core-java/src/test/java/com/baeldung/extension/ExtensionUnitTest.java +++ b/core-java/src/test/java/com/baeldung/extension/ExtensionUnitTest.java @@ -19,8 +19,7 @@ public class ExtensionUnitTest { public void getExtension_whenStringHandle_thenExtensionIsTrue() { String expectedExtension = "java"; Optional actualExtension = extension.getExtensionByStringHandling("Demo.java"); - Assert.assertTrue(actualExtension.isPresent()); - actualExtension.ifPresent(ext -> Assert.assertEquals(expectedExtension,ext)); + Assert.assertEquals(expectedExtension, actualExtension.get()); } @Test