// this isn't quite a unit test. It produces files to be visualized with R
@Test
public void testCompromise() throws IOException, ParseException {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
long start = df.parse("2014-01-01 00:00:00").getTime();
SchemaSampler s = new SchemaSampler(Resources.asCharSource(Resources.getResource("schema013.json"), Charsets.UTF_8).read());
long exploitStart = df.parse("2014-01-20 00:00:00").getTime();
long exploitEnd = df.parse("2014-02-20 00:00:00").getTime();
int exploitStartDay = (int) TimeUnit.DAYS.convert(exploitStart - start, TimeUnit.MILLISECONDS);
int[] transactionsByDay = new int[DAYS_COUNTED];
int[] compromiseByDay = new int[DAYS_COUNTED];
int[] fraudByDay = new int[DAYS_COUNTED];
Multiset<Integer> fraudUserCounts = HashMultiset.create();
Multiset<Integer> nonfraudUserCounts = HashMultiset.create();
Multiset<Integer> allMerchantCounts = HashMultiset.create();
int fraudAccounts = 0;
Set<Integer> merchantHistory = Sets.newHashSet();
// these collect the evolution of the contingency table for just merchant 0 and are indexed by time relative to exploit window.
int exploitLength = (int) (TimeUnit.DAYS.convert(exploitEnd - exploitStart, TimeUnit.MILLISECONDS)) + 1;
// exploitLength = 5;
int[] atmTotal = new int[exploitLength];
int[] atmFraud = new int[exploitLength];
int[] atmNonFraud = new int[exploitLength];
int[] nonAtmFraud = new int[exploitLength];
int[] nonAtmNonFraud = new int[exploitLength];
for (int userId = 0; userId < USER_COUNT; userId++) {
JsonNode sample = s.sample();
merchantHistory.clear();
boolean userHasFraud = false;
int[] hasFraudPerUser = new int[exploitLength];