use of com.cognizant.devops.platformcommons.dal.neo4j.GraphDBHandler in project Insights by CognizantOneDevOps.
the class WebhookEngineTestData method readNeo4JData.
@SuppressWarnings("rawtypes")
public static Map readNeo4JData(String nodeName, String compareFlag) {
Map map = null;
ObjectMapper mapper = new ObjectMapper();
GraphDBHandler dbHandler = new GraphDBHandler();
String query = "MATCH (n:" + nodeName + ") where n." + compareFlag + "='8ea6c42b96d5c0ffdaf3622720450e2d5def75e6' return n";
GraphResponse neo4jResponse;
try {
neo4jResponse = dbHandler.executeCypherQuery(query);
JsonElement tooldataObject = neo4jResponse.getJson().get("results").getAsJsonArray().get(0).getAsJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("row");
String finalJson = tooldataObject.toString().replace("[", "").replace("]", "");
// Gson gson = new Gson();
// map = gson.fromJson(finalJson, Map.class); GraphDB
map = mapper.readValue(finalJson, Map.class);
} catch (Exception e) {
LOG.error(e);
}
return map;
}
use of com.cognizant.devops.platformcommons.dal.neo4j.GraphDBHandler in project Insights by CognizantOneDevOps.
the class EngineAggregatorCorelationModuleTest method testCorrelation.
@Test(priority = 3)
public void testCorrelation() {
GraphDBHandler dbHandler = new GraphDBHandler();
String query = "MATCH (a)<-[r:TEST_FROM_GIT_TO_JENKINS]-(b) where a.scmcommitId=\"CM-7569369619\" and b.commitId='CM-7569369619' return count(a) as Total";
GraphResponse neo4jResponse;
try {
neo4jResponse = dbHandler.executeCypherQuery(query);
String finalJson = neo4jResponse.getJson().get("results").getAsJsonArray().get(0).getAsJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("row").toString().replace("[", "").replace("]", "");
/* Assert on Node Relationship */
log.debug("finalJson {} ", finalJson);
// "true"
Assert.assertTrue(Integer.parseInt(finalJson) > 0);
} catch (InsightsCustomException | AssertionError e) {
log.error("InsightsCustomException : or AssertionError " + e);
}
}
use of com.cognizant.devops.platformcommons.dal.neo4j.GraphDBHandler in project Insights by CognizantOneDevOps.
the class EngineAggregatorCorelationModuleTest method cleanUp.
@AfterClass
public void cleanUp() {
try {
agentConfigDAL.deleteAgentConfigurations("JENKINSTEST8800");
agentConfigDAL.deleteAgentConfigurations("GITTEST8800");
correlationConfigDAL.deleteCorrelationConfig("TEST_FROM_GIT_TO_JENKINS");
configFilesDAL.deleteConfigurationFile("DataEnrichmentTest");
} catch (InsightsCustomException e1) {
log.error(e1);
}
ApplicationConfigProvider.getInstance().getCorrelations().setBatchSize(2000);
ApplicationConfigProvider.getInstance().getCorrelations().setCorrelationFrequency(3);
ApplicationConfigProvider.getInstance().getCorrelations().setCorrelationWindow(48);
/* Cleaning Neo4J */
GraphDBHandler dbHandler = new GraphDBHandler();
String query = "MATCH p=()-[r:TEST_FROM_GIT_TO_JENKINS]->() delete p";
try {
dbHandler.executeCypherQuery(query);
dbHandler.executeCypherQuery("MATCH (n:JENKINS_UNTEST) DETACH DELETE n");
dbHandler.executeCypherQuery("MATCH (n:GIT_UNTEST) DETACH DELETE n");
} catch (InsightsCustomException e) {
log.error("InsightsCustomException : " + e.toString());
}
}
use of com.cognizant.devops.platformcommons.dal.neo4j.GraphDBHandler in project Insights by CognizantOneDevOps.
the class WebhookEngineTest method cleanUp.
/*@Test(priority = 8)
public void testEngineAgreegateException() throws Exception {
WebHookConfig webhookConfig = new WebHookConfig();
webhookConfig.setResponseTemplate(webhookEngineTestData.responseTemplate);
webhookConfig.setDynamicTemplate(webhookEngineTestData.dynamicTemplate);
webhookConfig.setToolName(webhookEngineTestData.toolName);
webhookConfig.setWebHookName(webhookEngineTestData.webhookNameException);
webhookConfig.setMQChannel("");
webhookConfig.setSubscribeStatus(true);
webhookConfig.setIsUpdateRequired(webhookEngineTestData.isUpdateRequired);
webhookConfig.setFieldUsedForUpdate(webhookEngineTestData.fieldUsedForUpdate);
webhookConfig.setDataFormat(p.getProperty("dataFormat"));
webhookConfig.setWebhookDerivedConfig(webhookEngineTestData.derivedOperationsArray);
webhookConfigDAL.saveWebHookConfiguration(webhookConfig);
WebHookEngineAggregatorModule em = new WebHookEngineAggregatorModule();
em.run();
}*/
@AfterClass
public void cleanUp() {
// Cleaning Postgre
webhookConfigDAL.deleteWebhookConfigurations(p.getProperty("webhookName"));
// webhookConfigDAL.deleteWebhookConfigurations(webhookEngineTestData.webhookNameException);
// Cleaning Neo4J
GraphDBHandler dbHandler = new GraphDBHandler();
String query = "MATCH (p:" + webhookEngineTestData.labelName + ") where p.webhookName='" + webhookEngineTestData.webhookName + "' delete p";
String queryDeleteHeathData = "MATCH (p:" + webhookEngineTestData.WEBHOOK_SUBSCRIBER_HEALTH_ROUTING_KEY + ") where p.instanceName='" + webhookEngineTestData.healthMessageInstanceName + "' delete p";
try {
dbHandler.executeCypherQuery(query);
dbHandler.executeCypherQuery(queryDeleteHeathData);
} catch (InsightsCustomException e) {
log.error("InsightsCustomException : " + e.toString());
}
}
use of com.cognizant.devops.platformcommons.dal.neo4j.GraphDBHandler in project Insights by CognizantOneDevOps.
the class GraphdbCorrelationConfiguration method checkQuery.
private boolean checkQuery(String query) {
GraphDBHandler dbHandler = new GraphDBHandler();
GraphResponse neo4jResponse;
try {
neo4jResponse = dbHandler.executeCypherQuery(query);
String finalJson = neo4jResponse.getJson().get("results").getAsJsonArray().get(0).getAsJsonObject().get("data").getAsJsonArray().get(0).getAsJsonObject().get("row").toString().replace("[", "").replace("]", "");
log.debug("finalJson {} ", finalJson);
if (Integer.parseInt(finalJson) > 0) {
return true;
}
} catch (InsightsCustomException | AssertionError e) {
log.error("InsightsCustomException : or AssertionError {}", e);
}
return false;
}
Aggregations