MetadataBuilder { public static String processApidGapsInfo(String gapStart, String gapStop) { String stringParsed=""; if(gapStart!=null && gapStop != null) { String[] gapStartList = gapStart.trim().split(";"); String[] gapStopList = gapStop.trim().split(";"); if(gapStartList.length == gapStopList.length) { for(int i=0;i<gapStartList.length;i++) { stringParsed = stringParsed + "Gap Start Time: "+(gapStartList[i].isEmpty()?"-":gapStartList[i])+ " Gap Stop Time: "+ (gapStopList[i].isEmpty()?"-":gapStopList[i])+"; "; } } else { for(int i=0;i<gapStartList.length;i++) { stringParsed = stringParsed + "Gap Start Time: "+(gapStartList[i].isEmpty()?"-":gapStartList[i])+"; "; } } } else { logger.error("Error getting Information on missing ISPs APID"); } logger.debug(" ************* missing ISPs APID: " + stringParsed); stringParsed=stringParsed.replace("Gap Start Time: - Gap Stop Time: -;", "N/A").replace("Gap Start Time: -;", "N/A"); if(stringParsed.length()>MAX_METADATA_SIZE) { stringParsed=stringParsed.substring(0,MAX_METADATA_SIZE-4)+"..."; } return stringParsed; } private  MetadataBuilder(); static String processApidInfo(String apidnum, String apidgaps); static String processApidGapsInfo(String gapStart, String gapStop);  }
@Test public void testProcessApidGapsInfo() throws Exception { String gapStart = "2015-03-30T17:07:50.028000Z;2015-03-30T17:37:55.028000Z"; String gapStop = "2015-03-30T17:07:55.028000Z;2015-03-30T17:38:00.028000Z"; String expected = "Gap Start Time: 2015-03-30T17:07:50.028000Z Gap Stop Time: 2015-03-30T17:07:55.028000Z; Gap Start Time: 2015-03-30T17:37:55.028000Z Gap Stop Time: 2015-03-30T17:38:00.028000Z; "; String apidInfo = MetadataBuilder.processApidGapsInfo(gapStart, gapStop); Assert.assertEquals(expected, apidInfo); }
@Test public void testProcessApidGapsInfo2() throws Exception { String gapStart = "2015-03-30T17:07:50.028000Z;2015-03-30T17:37:55.028000Z"; String gapStop = "2015-03-30T17:07:55.028000Z"; String expected = "Gap Start Time: 2015-03-30T17:07:50.028000Z; Gap Start Time: 2015-03-30T17:37:55.028000Z; "; String apidInfo = MetadataBuilder.processApidGapsInfo(gapStart, gapStop); Assert.assertEquals(expected, apidInfo); }