OKW_Helper { public static String getLeftFromDelimiterNumber( String fpsSource, String fpsDelimiter, Integer fpiCount ) throws XPathExpressionException { String lvsReturn = ""; ArrayList<String> lvLsSplitedSource = null; int RangeMin = 1; int RangeMax = 1; try { Log.LogFunctionStartDebug("OKW_Helper.GetLeftFromDelimiterNumber", "fpsSource", fpsSource, "fpsDelimiter", fpsDelimiter, "fpiCount", fpiCount.toString()); if ( ! "".equals( fpsDelimiter ) ) { lvLsSplitedSource = splitString(fpsSource, fpsDelimiter); RangeMax = lvLsSplitedSource.size() - 1; RangeMin = 1; if ((RangeMin <= fpiCount) & (fpiCount <= RangeMax)) { lvsReturn = lvLsSplitedSource.get(0); for (int i = 1; i < fpiCount; i++) { lvsReturn = lvsReturn + fpsDelimiter + lvLsSplitedSource.get(i); } } else { String lvsLM = LM.GetMessage("GetLeftFromDelimiterNumber", "OKWDelimiterCountOutOfRangeException", fpiCount, RangeMax); throw new IndexOutOfBoundsException(lvsLM); } } else { String lvsLM = LM.GetMessage("GetLeftFromDelimiterNumber", "OKWDelimiterIsEmptyException"); throw new IllegalArgumentException(lvsLM); } } finally { Log.LogFunctionEndDebug(lvsReturn); } return lvsReturn; }  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 tcGetLeftFromDelimiterMultipleCharacterDelemeter() throws XPathExpressionException { assertEquals("AAAA", OKW_Helper.getLeftFromDelimiterNumber("AAAAGGBBBBGGDDDD", "GG", 1)); assertEquals("AAAAGGBBBB", OKW_Helper.getLeftFromDelimiterNumber("AAAAGGBBBBGGDDDD", "GG", 2)); }
@Test public void tcGetLeftFromDelimiterNumber() throws XPathExpressionException { assertEquals("AAAA", OKW_Helper.getLeftFromDelimiterNumber("AAAACBBBB", "C", 1)); }
@Test public void tcGetLeftFromDelimiterNumber_2() throws XPathExpressionException { assertEquals("AAAACBBBB", OKW_Helper.getLeftFromDelimiterNumber("AAAACBBBBCDDDD", "C", 2)); }
@Test public void tcGetLeftFromDelimiterNumber_2a() throws XPathExpressionException { assertEquals("AAAA", OKW_Helper.getLeftFromDelimiterNumber("AAAACBBBBCDDDD", "C", 1)); }
@Test public void tcGetLeftFromDelimiterNumber_OKWDelimiterCountOutOfRangeException() { try { OKWLanguage.getInstance().setLanguage("en"); OKW_Helper.getLeftFromDelimiterNumber("AAAAGGBBBBGGDDDD", "GG", 3); fail(); } catch (IndexOutOfBoundsException e) { assertEquals("The split-position(=3) is outside of valid range [1...2]!", e.getMessage()); } catch (Exception e) { fail(); } }
@Test public void tcGetLeftFromDelimiterNumber_OKWDelimiterCountOutOfRangeException_0() { try { OKWLanguage.getInstance().setLanguage("en"); OKW_Helper.getLeftFromDelimiterNumber("AAAAGGBBBBGGDDDD", "GG", 0); fail(); } catch (IndexOutOfBoundsException e) { assertEquals("The split-position(=0) is outside of valid range [1...2]!", e.getMessage()); } catch (Exception e) { fail(); } }
@Test public void tcGetLeftFromDelimiterNumber_OKWDelimiterIsEmptyException() { try { OKWLanguage.getInstance().setLanguage("en"); OKW_Helper.getLeftFromDelimiterNumber("AAAAGGBBBBGGDDDD", "", 1); fail(); } catch (IllegalArgumentException e) { assertEquals("Delimiter is empty!", e.getMessage()); } catch (Exception e) { fail(); } }