@Test public void testDoDataLoad() throws Exception{ new MockUp<DBQueryUtil>() { @Mock public List<CounterDetailVO> getCounterDetails() { CounterDetailVO counterDetails = new CounterDetailVO(); counterDetails.setEnvironmentCounterId(6); counterDetails.setEnvironmentId(1); counterDetails.setCounterId(1); counterDetails.setCounterMetricTypeId(1); counterDetails.setCounterMetricTypeClassName("com.tmobile.gdm.surveiller.counters.PercentageUpTimeHandler"); counterDetails.setParameter1("4,6"); counterDetails.setParameter2("AVG"); List<CounterDetailVO> counterList = new ArrayList<CounterDetailVO>(); counterList.add(counterDetails); return counterList; } }; new MockUp<MailSenderUtil>(){ @Mock public void sendMail(String messageText, String toMail, String subject){ } }; CounterDataLoader.doDataLoad(); }
public static void doDataLoad() throws Exception{ logger.info("************** STARTED Counter Data Loader **************"); ProxyUtil.setProxy(); ProxyUtil.disableCertificates(); List<CounterDetailVO> listCounterDetails = DBQueryUtil.getCounterDetails(); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.SECOND, 00); Timestamp currDate = new java.sql.Timestamp(calendar.getTimeInMillis()); for(CounterDetailVO counterDetails: listCounterDetails){ try{ int counterMetricTypeId = counterDetails.getCounterMetricTypeId(); CounterMetricHandler metricHandler = null; if(counterDetails.getCounterMetricTypeClassName() != null) { ClassLoader classLoader = CounterDataLoader.class.getClassLoader(); @SuppressWarnings("unchecked") Class<CounterMetricHandler> objectClass = (Class<CounterMetricHandler>)classLoader.loadClass(counterDetails.getCounterMetricTypeClassName()); metricHandler = objectClass.newInstance(); } else{ throw new ConfigurationException("No class configured for counterMetricTypeId = " + counterMetricTypeId); } counterDetails.setMetricValue(metricHandler.getCounterMerticValue(counterDetails, listCounterDetails)); DBQueryUtil.addCounterMertic(counterDetails.getEnvironmentCounterId(), counterDetails.getMetricValue(), currDate); DBQueryUtil.addCounterMetricHistory(counterDetails.getEnvironmentCounterId(), counterDetails.getMetricValue()); }catch(Exception ex){ logger.error("Surveiller Counter DataLoad Failed for Environment Counter ID :-"+counterDetails.getEnvironmentCounterId()+":: Exception : "+ex); counterDetails.setMetricValue(-1); CommonsUtil.handleException(ex, "doCounterDataLoad"); } } logger.info("************** COMPLETED Counter Data Loader **************"); }
CounterDataLoader { public static void doDataLoad() throws Exception{ logger.info("************** STARTED Counter Data Loader **************"); ProxyUtil.setProxy(); ProxyUtil.disableCertificates(); List<CounterDetailVO> listCounterDetails = DBQueryUtil.getCounterDetails(); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.SECOND, 00); Timestamp currDate = new java.sql.Timestamp(calendar.getTimeInMillis()); for(CounterDetailVO counterDetails: listCounterDetails){ try{ int counterMetricTypeId = counterDetails.getCounterMetricTypeId(); CounterMetricHandler metricHandler = null; if(counterDetails.getCounterMetricTypeClassName() != null) { ClassLoader classLoader = CounterDataLoader.class.getClassLoader(); @SuppressWarnings("unchecked") Class<CounterMetricHandler> objectClass = (Class<CounterMetricHandler>)classLoader.loadClass(counterDetails.getCounterMetricTypeClassName()); metricHandler = objectClass.newInstance(); } else{ throw new ConfigurationException("No class configured for counterMetricTypeId = " + counterMetricTypeId); } counterDetails.setMetricValue(metricHandler.getCounterMerticValue(counterDetails, listCounterDetails)); DBQueryUtil.addCounterMertic(counterDetails.getEnvironmentCounterId(), counterDetails.getMetricValue(), currDate); DBQueryUtil.addCounterMetricHistory(counterDetails.getEnvironmentCounterId(), counterDetails.getMetricValue()); }catch(Exception ex){ logger.error("Surveiller Counter DataLoad Failed for Environment Counter ID :-"+counterDetails.getEnvironmentCounterId()+":: Exception : "+ex); counterDetails.setMetricValue(-1); CommonsUtil.handleException(ex, "doCounterDataLoad"); } } logger.info("************** COMPLETED Counter Data Loader **************"); } }
CounterDataLoader { public static void doDataLoad() throws Exception{ logger.info("************** STARTED Counter Data Loader **************"); ProxyUtil.setProxy(); ProxyUtil.disableCertificates(); List<CounterDetailVO> listCounterDetails = DBQueryUtil.getCounterDetails(); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.SECOND, 00); Timestamp currDate = new java.sql.Timestamp(calendar.getTimeInMillis()); for(CounterDetailVO counterDetails: listCounterDetails){ try{ int counterMetricTypeId = counterDetails.getCounterMetricTypeId(); CounterMetricHandler metricHandler = null; if(counterDetails.getCounterMetricTypeClassName() != null) { ClassLoader classLoader = CounterDataLoader.class.getClassLoader(); @SuppressWarnings("unchecked") Class<CounterMetricHandler> objectClass = (Class<CounterMetricHandler>)classLoader.loadClass(counterDetails.getCounterMetricTypeClassName()); metricHandler = objectClass.newInstance(); } else{ throw new ConfigurationException("No class configured for counterMetricTypeId = " + counterMetricTypeId); } counterDetails.setMetricValue(metricHandler.getCounterMerticValue(counterDetails, listCounterDetails)); DBQueryUtil.addCounterMertic(counterDetails.getEnvironmentCounterId(), counterDetails.getMetricValue(), currDate); DBQueryUtil.addCounterMetricHistory(counterDetails.getEnvironmentCounterId(), counterDetails.getMetricValue()); }catch(Exception ex){ logger.error("Surveiller Counter DataLoad Failed for Environment Counter ID :-"+counterDetails.getEnvironmentCounterId()+":: Exception : "+ex); counterDetails.setMetricValue(-1); CommonsUtil.handleException(ex, "doCounterDataLoad"); } } logger.info("************** COMPLETED Counter Data Loader **************"); } private  CounterDataLoader(); }
CounterDataLoader { public static void doDataLoad() throws Exception{ logger.info("************** STARTED Counter Data Loader **************"); ProxyUtil.setProxy(); ProxyUtil.disableCertificates(); List<CounterDetailVO> listCounterDetails = DBQueryUtil.getCounterDetails(); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.SECOND, 00); Timestamp currDate = new java.sql.Timestamp(calendar.getTimeInMillis()); for(CounterDetailVO counterDetails: listCounterDetails){ try{ int counterMetricTypeId = counterDetails.getCounterMetricTypeId(); CounterMetricHandler metricHandler = null; if(counterDetails.getCounterMetricTypeClassName() != null) { ClassLoader classLoader = CounterDataLoader.class.getClassLoader(); @SuppressWarnings("unchecked") Class<CounterMetricHandler> objectClass = (Class<CounterMetricHandler>)classLoader.loadClass(counterDetails.getCounterMetricTypeClassName()); metricHandler = objectClass.newInstance(); } else{ throw new ConfigurationException("No class configured for counterMetricTypeId = " + counterMetricTypeId); } counterDetails.setMetricValue(metricHandler.getCounterMerticValue(counterDetails, listCounterDetails)); DBQueryUtil.addCounterMertic(counterDetails.getEnvironmentCounterId(), counterDetails.getMetricValue(), currDate); DBQueryUtil.addCounterMetricHistory(counterDetails.getEnvironmentCounterId(), counterDetails.getMetricValue()); }catch(Exception ex){ logger.error("Surveiller Counter DataLoad Failed for Environment Counter ID :-"+counterDetails.getEnvironmentCounterId()+":: Exception : "+ex); counterDetails.setMetricValue(-1); CommonsUtil.handleException(ex, "doCounterDataLoad"); } } logger.info("************** COMPLETED Counter Data Loader **************"); } private  CounterDataLoader(); static void doDataLoad(); }
CounterDataLoader { public static void doDataLoad() throws Exception{ logger.info("************** STARTED Counter Data Loader **************"); ProxyUtil.setProxy(); ProxyUtil.disableCertificates(); List<CounterDetailVO> listCounterDetails = DBQueryUtil.getCounterDetails(); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.SECOND, 00); Timestamp currDate = new java.sql.Timestamp(calendar.getTimeInMillis()); for(CounterDetailVO counterDetails: listCounterDetails){ try{ int counterMetricTypeId = counterDetails.getCounterMetricTypeId(); CounterMetricHandler metricHandler = null; if(counterDetails.getCounterMetricTypeClassName() != null) { ClassLoader classLoader = CounterDataLoader.class.getClassLoader(); @SuppressWarnings("unchecked") Class<CounterMetricHandler> objectClass = (Class<CounterMetricHandler>)classLoader.loadClass(counterDetails.getCounterMetricTypeClassName()); metricHandler = objectClass.newInstance(); } else{ throw new ConfigurationException("No class configured for counterMetricTypeId = " + counterMetricTypeId); } counterDetails.setMetricValue(metricHandler.getCounterMerticValue(counterDetails, listCounterDetails)); DBQueryUtil.addCounterMertic(counterDetails.getEnvironmentCounterId(), counterDetails.getMetricValue(), currDate); DBQueryUtil.addCounterMetricHistory(counterDetails.getEnvironmentCounterId(), counterDetails.getMetricValue()); }catch(Exception ex){ logger.error("Surveiller Counter DataLoad Failed for Environment Counter ID :-"+counterDetails.getEnvironmentCounterId()+":: Exception : "+ex); counterDetails.setMetricValue(-1); CommonsUtil.handleException(ex, "doCounterDataLoad"); } } logger.info("************** COMPLETED Counter Data Loader **************"); } private  CounterDataLoader(); static void doDataLoad();  }