OKW_Helper { public static Boolean String2Boolean( String fpsTrueOrFalse ) throws XPathExpressionException { Boolean lvbReturn = false; Boolean bOK = false; String lvsTrueOrFalse = fpsTrueOrFalse.toLowerCase(); Log.LogFunctionStartDebug("OKW_Helper.String2Boolean", "fpsTrueOrFalse", fpsTrueOrFalse); try { if ( "true".equals( lvsTrueOrFalse ) ) { lvbReturn = true; bOK = true; } else if ( "false".equals( lvsTrueOrFalse ) ) { lvbReturn = false; bOK = true; } else { bOK = false; String lvsLM = LM.GetMessage("String2Boolean", "OKWNotAllowedValueException", fpsTrueOrFalse); throw new OKWNotAllowedValueException(lvsLM); } } finally { if (bOK) { Log.LogFunctionEndDebug(lvbReturn); } else { Log.LogFunctionEndDebug(); } } return lvbReturn; }  static String Boolean2String( Boolean fpbTrueOrFalse ); static String getLeftFromDelimiterNumber( String fpsSource, String fpsDelimiter, Integer fpiCount ); static String getRightFromDelimiterNumber( String fpsSource, String fpsDelimiter, Integer fpiCount ); static Boolean compareListString( List<String> ListString1, List<String> ListString2 ); static String concatListString( ArrayList<String> fps_ListString2Concat, String fps_Delimiter ); static Boolean matchString( String fpsPattern, String fpsStringToMatch ); static Boolean matchStrIgnoreCase( String fpsPattern, String fpsStringToMatch ); static String removeBeginEndQuotations( String fps_StringinQuotations ); static ArrayList<String> StringArray2ListStr( String[] fpsStringArray ); static Boolean String2Boolean( String fpsTrueOrFalse ); static ArrayList<String> splitString(String fpsString2Split, String fpsSeparator); static String repeatString( char c, Integer n ); static String repeatString( String c, Integer n ); static Boolean isStringNullOrEmpty( String fpsString);  }
@Test public void tcString2Boolean_false() throws XPathExpressionException { Boolean actual = true; Boolean expected = true; actual = OKW_Helper.String2Boolean("true"); assertEquals(expected, actual); }
@Test public void tcString2Boolean_true() throws XPathExpressionException { Boolean actual = false; Boolean expected = false; actual = OKW_Helper.String2Boolean("false"); assertEquals(expected, actual); }
@Test public void tcString2Boolean_false_lower() throws XPathExpressionException { Boolean actual = true; Boolean expected = false; actual = OKW_Helper.String2Boolean("False"); assertEquals(expected, actual); actual = OKW_Helper.String2Boolean("FALSE"); assertEquals(expected, actual); actual = OKW_Helper.String2Boolean("falsE"); assertEquals(expected, actual); actual = OKW_Helper.String2Boolean("FaLsE"); assertEquals(expected, actual); }
@Test public void tcString2Boolean_true_lower() throws XPathExpressionException { Boolean actual = false; Boolean expected = true; actual = OKW_Helper.String2Boolean("True"); assertEquals(expected, actual); actual = OKW_Helper.String2Boolean("TRUE"); assertEquals(expected, actual); actual = OKW_Helper.String2Boolean("truE"); assertEquals(expected, actual); actual = OKW_Helper.String2Boolean("TruE"); assertEquals(expected, actual); }
@Test public void tcString2Boolean_true_OKWNotAllowedValueException() { try { OKW_Helper.String2Boolean("Uschi"); fail(); } catch (OKWNotAllowedValueException e) { OKWLanguage.getInstance().setLanguage("en"); String Expected = "Value 'Uschi' is not allowd here! Valid values are: 'true' or 'false'"; String Actual = e.getMessage(); assertEquals(Expected, Actual); } catch (Exception e) { Log.LogPrint("Exception nicht erwartet: '" + e.getMessage() + "'"); fail(); } }