Program: 91049
Project: 91049
Buggy source:
@Test public void should_query_signature_correctly() throws Exception {
  ImportDescriptorBuilder builder=builder().now(now).app("String_Node_Str").app("String_Node_Str").method(testDataGenerator.getMethod(0)).method(testDataGenerator.getMethod(1)).method(testDataGenerator.getMethod(2)).jvm(createJvm(1,adjust(now,-10,DAYS),adjust(now,-1,DAYS),"String_Node_Str","String_Node_Str","String_Node_Str")).jvm(createJvm(2,adjust(now,-20,DAYS),adjust(now,-11,DAYS),"String_Node_Str","String_Node_Str","String_Node_Str")).jvm(createJvm(3,adjust(now,-30,DAYS),adjust(now,-29,DAYS),"String_Node_Str","String_Node_Str","String_Node_Str"));
  for (long appId=1; appId <= 2; appId++) {
    for (long methodId=1; methodId <= 3; methodId++) {
      for (long jvmId=1; jvmId <= 3; jvmId++) {
        long hash=appId * 100 + methodId * 10 + jvmId;
        builder.invocation(Invocation.builder().localApplicationId(appId).localMethodId(methodId).localJvmId(jvmId).status(SignatureStatus.EXACT_MATCH).invocationCount(hash).invokedAtMillis(hash).build());
      }
    }
  }
  testDataGenerator.simulateFileImport(builder.build());
  List<MethodDescriptor> methods=queryService.findMethodsBySignature(null);
  assertThat(methods,hasSize(3));
  methods=queryService.findMethodsBySignature(testDataGenerator.getMethod(1).getSignature());
  assertThat(methods,hasSize(1));
  methods=queryService.findMethodsBySignature(testDataGenerator.getMethod(1).getSignature().substring(3,10));
  assertThat(methods,hasSize(1));
  MethodDescriptor md=methods.get(0);
  ApplicationId app1=ApplicationId.of("String_Node_Str","String_Node_Str");
  ApplicationId app2=ApplicationId.of("String_Node_Str","String_Node_Str");
  assertThat(md.getOccursInApplications().keySet(),contains(app1,app2));
  assertThat(toDaysAgo(md.getCollectedSinceMillis()),is(30));
  methods=queryService.findMethodsBySignature("String_Node_Str");
  assertThat(methods,hasSize(0));
}

Fixed version (ground truth):
@Test public void should_query_signature_correctly() throws Exception {
  ImportDescriptorBuilder builder=builder().now(now).app("String_Node_Str").app("String_Node_Str").app("String_Node_Str").method(testDataGenerator.getMethod(1)).method(testDataGenerator.getMethod(2)).method(testDataGenerator.getMethod(3)).jvm(createJvm(1,adjust(now,-10,DAYS),adjust(now,-1,DAYS),"String_Node_Str","String_Node_Str","String_Node_Str")).jvm(createJvm(2,adjust(now,-30,DAYS),adjust(now,-29,DAYS),"String_Node_Str","String_Node_Str","String_Node_Str")).jvm(createJvm(3,adjust(now,-20,DAYS),adjust(now,-19,DAYS),"String_Node_Str","String_Node_Str","String_Node_Str"));
  for (long appId=1; appId <= 3; appId++) {
    for (long methodId=1; methodId <= 3; methodId++) {
      for (long jvmId=1; jvmId <= 3; jvmId++) {
        long hash=appId * 100 + methodId * 10 + jvmId;
        builder.invocation(Invocation.builder().localApplicationId(appId).localMethodId(methodId).localJvmId(jvmId).status(SignatureStatus.EXACT_MATCH).invocationCount(hash).invokedAtMillis(hash).build());
      }
    }
  }
  testDataGenerator.simulateFileImport(builder.build());
  List<MethodDescriptor> methods=queryService.findMethodsBySignature(null);
  assertThat(methods,hasSize(3));
  methods=queryService.findMethodsBySignature(testDataGenerator.getMethod(1).getSignature());
  assertThat(methods,hasSize(1));
  methods=queryService.findMethodsBySignature(testDataGenerator.getMethod(1).getSignature().substring(3,10));
  assertThat(methods,hasSize(1));
  MethodDescriptor md=methods.get(0);
  assertThat(toDaysAgo(md.getCollectedSinceMillis()),is(30));
  assertThat(toDaysAgo(md.getCollectedToMillis()),is(1));
  methods=queryService.findMethodsBySignature("String_Node_Str");
  assertThat(methods,hasSize(0));
}