String userId = "file";
int session = 3;
rec.setParameters(params);
Throwable thrown = new NullPointerException("TESTING NULL POINTER");
Logfile log = new Logfile(userId, session);
DbInsertion insertion = new DbInsertion(rec, thrown, new TestLogFileTask(em, log));
ExceptionsData insertionResult = getInsertionData(insertion);
assertFalse("THIS ISSUE IS NOT ANY DUPLICATE", insertionResult.isDuplicateReport());
assertNull("NO ISSUEZILLA ID", insertionResult.getIssuezillaId());
assertEquals("Exception report", ExceptionsData.DataType.EXC_REPORT, insertionResult.getDataType());
waitLogsParsed();
List<Nbuser> usersList = PersistenceUtils.getAll(em, Nbuser.class);
Nbuser user = usersList.get(0);
assertEquals("THERE MUST BE ONE USER", 1, usersList.size());
assertEquals("USER NAME CHECK", user.getName(), params[3]);
List<org.netbeans.modules.exceptions.entity.Exceptions> exceptionList = PersistenceUtils.getAll(em, org.netbeans.modules.exceptions.entity.Exceptions.class);
org.netbeans.modules.exceptions.entity.Exceptions exception = exceptionList.get(0);
assertEquals("THERE MUST BE ONE ISSUE", 1, exceptionList.size());
assertEquals("THIS ISSUE WAS ADDED WITH ID", insertionResult.getSubmitId(), exception.getId());
assertEquals("SUMMARY CHECK", exception.getSummary(), params[4]);
assertEquals(fileNames[0], exception.getLogfileId().getFileName());
assertEquals("VM MACHINE CHECK", exception.getVmId().getName(), params[1]);
assertEquals("NB PRODUCT VERSION CHECK", exception.getLogfileId().getProductVersionId().getProductVersion(), params[2]);
String os = exception.getOperatingsystemId().getName() + ", " + exception.getOperatingsystemId().getVersion() + ", " + exception.getOperatingsystemId().getArch();
assertEquals("OPERATING SYSTEM NAME CHECK", os, params[0]);
assertEquals("PRODUCT BUILD NUMBER", exception.getBuild(), Long.valueOf("070212"));
assertEquals("NR. OF DUPLICATES SHOULD BE 1", 1, exception.getReportId().getSubmitCollection().size());
assertEquals("STACKTRACE LINES NUMBER", thrown.getStackTrace().length, exception.getStacktrace().getLineCollection().size());
List<Line> linesList = PersistenceUtils.getAll(em, Line.class);
Iterator<Line> lineIterator = linesList.iterator();
assertTrue("THERE MUST BE FEW LINES", linesList.size() > 0);
List<StackTraceElement> list = Arrays.asList(thrown.getStackTrace());
do{
Line line = lineIterator.next();
assertNotNull("JarFile is not inserted", line.getJarfileId());
int lineOrder = line.getLinePK().getLineOrder();
int lineNumber = line.getLinePK().getLinenumber();
int stackLineNumber = list.get(lineOrder).getLineNumber();
if (stackLineNumber < 0) stackLineNumber = 0;
assertEquals(lineNumber, stackLineNumber);
}while (lineIterator.hasNext());
assertEquals(linesList.size(), list.size());
Integer count = perUtils.count(Jarfile.class);
assertTrue("THE NUMBER MUST BE NOT 0", count > 0);
logFiles = AddLogFileTest.logFiles(em);
assertEquals("JUST ONE logfile: " + logFiles,1, logFiles.size());
assertEquals("Build Number", logFiles.get(0).getBuildnumber(), Long.valueOf("070212"));
assertEquals("Upload Number", logFiles.get(0).getUploadNumber(), new Integer(session));
assertEquals("userDir", logFiles.get(0).getUserdir(), userId);
assertEquals("File Name", logFiles.get(0).getFileName(), userId+"."+String.valueOf(session-1));
assertNull("IP is null - it was not set", logFiles.get(0).getIp());
//********* ADD DUPLICATE *********/
params[3] = users[1];
params[5] = comments[1];
params[2] = productVersion[1];
rec.setParameters(params);
log = new Logfile(userId, session+1);
insertion = new DbInsertion(rec, thrown, new TestLogFileTask(em, log));
insertionResult = getInsertionData(insertion);
assertTrue("THIS ISSUE IS A DUPLICATE", insertionResult.isDuplicateReport());
assertAreDuplicates("DUPLICATE INSERTION", em, new Integer(1), insertionResult.getSubmitId());
assertNull("NO ISSUEZILLA ID", insertionResult.getIssuezillaId());
assertEquals("Exception report", ExceptionsData.DataType.EXC_REPORT, insertionResult.getDataType());
waitLogsParsed();
Integer nextCount = perUtils.count(Jarfile.class);
assertEquals("THE NUMBER OF JAR FILES MUST BE THE SAME", count, nextCount);
usersList = PersistenceUtils.getAll(em, Nbuser.class);
user = usersList.get(0);
assertEquals("THERE MUST BE USER", 1, usersList.size());
assertEquals(users[0], user.getName());
List<Comment> commentList = PersistenceUtils.getAll(em, Comment.class);
assertEquals("THERE SHOULD BE TWO COMMENTS", 2, commentList.size());
//first record
Comment comment = commentList.get(0);
assertEquals(comments[0],comment.getComment());
comment = commentList.get(1);
//second record
assertEquals(comments[1],comment.getComment());
exceptionList = PersistenceUtils.getAll(em, org.netbeans.modules.exceptions.entity.Exceptions.class);
exception = exceptionList.get(0);
assertEquals("THERE MUST BE ONE ISSUE", 2, exceptionList.size());
//check the first one
assertEquals("THIS ISSUE WAS ADDED WITH ID", new Integer(1), exception.getId());
assertEquals("SUMMARY CHECK", exception.getSummary(), params[4]);
assertEquals(fileNames[0], exception.getLogfileId().getFileName());
assertEquals("VM MACHINE CHECK", exception.getVmId().getName(), params[1]);
assertEquals("NB PRODUCT VERSION CHECK", exception.getLogfileId().getProductVersionId().getProductVersion(), productVersion[0]);
assertEquals("PRODUCT BUILD NUMBER", exception.getBuild(),Long.valueOf("070212"));
os = exception.getOperatingsystemId().getName() + ", " + exception.getOperatingsystemId().getVersion() + ", " + exception.getOperatingsystemId().getArch();
assertEquals("OPERATING SYSTEM NAME CHECK", os, params[0]);
// assertNull("THIS SHOULD NOT BE A DUPLICATE", exception.getDuplicateof());// NULL
//check the second one
exception = exceptionList.get(1);
assertEquals("THIS ISSUE WAS ADDED WITH ID", new Integer(2), exception.getId());
assertEquals("SUMMARY CHECK", exception.getSummary(), params[4]);
assertEquals(fileNames[1], exception.getLogfileId().getFileName());
assertEquals("VM MACHINE CHECK", exception.getVmId().getName(), params[1]);
assertEquals("NB PRODUCT VERSION CHECK", exception.getLogfileId().getProductVersionId().getProductVersion(), productVersion[1]);
assertEquals("PRODUCT BUILD NUMBER", exception.getBuild(), Long.valueOf("070416"));
os = exception.getOperatingsystemId().getName() + ", " + exception.getOperatingsystemId().getVersion() + ", " + exception.getOperatingsystemId().getArch();
assertEquals("OPERATING SYSTEM NAME CHECK", os, params[0]);
// assertNotNull("THIS SHOULD BE A DUPLICATE", exception.getDuplicateof());
// assertEquals("THIS SHOULD BE A DUPLICATE OF ISSUE 1", exception.getDuplicateof(), exceptionList.get(0));
assertEquals("COMPONENT FROM COMMENT", "versioncontrol", exception.getReportId().getComponent());
assertEquals("SUBCOMPONENT FROM COMMENT", "Subversion", exception.getReportId().getSubcomponent());
logFiles = AddLogFileTest.logFiles(em);
assertEquals("TWO logfile",2, logFiles.size());
//--- FIRST --//
Logfile logFile = logFiles.get(0);
assertEquals("Build Number", logFile.getBuildnumber(), Long.valueOf("070212"));
assertEquals("Upload Number", logFile.getUploadNumber(), new Integer(session));
assertEquals("userDir", logFile.getUserdir(), userId);
assertEquals("File Name", logFile.getFileName(), userId+"."+String.valueOf(session-1));
assertNull("IP is null - it was not set", logFile.getIp());
assertNotNull(logFile.getProductVersionId());
assertEquals("PRODUCT VERSION CHECK", productVersion[0], logFile.getProductVersionId().getProductVersion());
assertEquals("NBVersion CHECK", "Dev", logFile.getProductVersionId().getNbversionId().getVersion());
//---SECOND--//
logFile = logFiles.get(1);
assertEquals("Build Number", logFile.getBuildnumber(), Long.valueOf("070416"));
assertEquals("Upload Number", logFile.getUploadNumber(), new Integer(session+1));
assertEquals("userDir", logFile.getUserdir(), userId);
assertEquals("File Name", logFile.getFileName(), userId+"."+String.valueOf(session));
assertNull("IP is null - it was not set", logFile.getIp());
assertNotNull(logFile.getProductVersionId());
assertEquals("PRODUCT VERSION CHECK", productVersion[1], logFile.getProductVersionId().getProductVersion());
assertEquals("NBVersion CHECK", "Dev", logFile.getProductVersionId().getNbversionId().getVersion());
}