private String fetchParentJobId(QueryResult queryResult) { String parentJobId = ""; if (queryResult.getDone()) { SObject[] sObjects = queryResult.getRecords(); if (sObjects != null) { for (SObject sobject : sObjects) { parentJobId = sobject.getField("ParentJobId").toString(); } return parentJobId; } } return null; } }
private static String[] fetchApexClassesAsArray(QueryResult queryResult) { Object[] apexClassesObjArr = null; if (queryResult.getDone()) { SObject[] sObjects = queryResult.getRecords(); if (sObjects != null) { ArrayList<String> apexClasses = new ArrayList<String>(); LOG.debug("Fetched Apex classes:"); for (SObject sobject : sObjects) { apexClasses.add(sobject.getField("Id").toString()); // crucial step. Populate apexCLassMap each time a class is // fetched. Will be used for lot of computations apexClassMap.put(sobject.getField("Id").toString(), sobject.getField("Name").toString()); LOG.debug("ApexClassId : " + sobject.getField("Id").toString() + " ApexClassName : " + sobject.getField("Name").toString()); } apexClassesObjArr = apexClasses.toArray(); //line below only works for java 1.6 and above return Arrays.copyOf(apexClassesObjArr, apexClassesObjArr.length, String[].class); } } return null; }
public static String fetchApexTestClassNameFromId(PartnerConnection connection, String apexClassId) { String apexClassName = ""; String soql = QueryConstructor.generateQueryToFetchApexClassFromId(apexClassId); QueryResult queryResult = null; try { queryResult = connection.query(soql); } catch (ConnectionException e) { ApexUnitUtils.shutDownWithDebugLog(e, ConnectionHandler .logConnectionException(e, connection, soql)); } if (queryResult != null && queryResult.getDone()) { SObject[] sObjects = queryResult.getRecords(); for (SObject sobject : sObjects) { if (sobject != null) { apexClassName = sobject.getField("Name").toString(); LOG.info("Fetched the Apex test class for Id: " + apexClassId + " : " + apexClassName); if (!apexClassMap.containsKey(apexClassId)) { apexClassMap.put(apexClassId, apexClassName); } } } } return apexClassName; }
public static String fetchAndAddToMapApexClassIdBasedOnName(PartnerConnection connection, String soqlBasedOnName) { String apexClassId = null; QueryResult queryResult = null; try { queryResult = connection.query(soqlBasedOnName); } catch (ConnectionException e) { ApexUnitUtils.shutDownWithDebugLog(e, ConnectionHandler .logConnectionException(e, connection, soqlBasedOnName)); } if (queryResult != null && queryResult.getDone()) { String[] classIds = fetchApexClassesAsArray(queryResult); if(classIds!=null && classIds.length>0){ apexClassId = classIds[0]; } } return apexClassId; }
.logConnectionException(e, conn, soql)); if (queryResult.getDone()) { int index = 0; SObject[] sObjects = queryResult.getRecords();
if (queryResult != null && queryResult.getDone()) { SObject[] sObjects = queryResult.getRecords(); for (SObject sobject : sObjects) {
queryResult = conn.query(soql); if (queryResult.getDone()) { SObject[] sObjects = queryResult.getRecords();