@Test
  public void shouldUpdateEntityByExternalPrimaryKeyWhenExists() {
    String caseId = "94d5374f-290e-409f-bc57-86c2e4bcc43f";
    ChildCase existingChild = new ChildCase();
    existingChild.setCaseId(caseId);
    existingChild.setName("old Child name");
    template.save(existingChild);

    HashMap<String, String> updatedValues =
        new HashMap<String, String>() {
          {
            put("caseId", "94d5374f-290e-409f-bc57-86c2e4bcc43f");
            put("name", "new child name");
          }
        };

    careService.saveByExternalPrimaryKey(ChildCase.class, updatedValues);

    List<ChildCase> childCases = template.loadAll(ChildCase.class);
    Assert.assertEquals(1, childCases.size());

    ChildCase expectedChildCase = new ChildCase();
    expectedChildCase.setCaseId(caseId);
    expectedChildCase.setName("new child name");
    assertReflectionEqualsWithIgnore(
        expectedChildCase,
        childCases.get(0),
        new String[] {"id", "creationTime", "lastModifiedTime"});
  }
  @Test
  public void insertMixOfWronglyFormedAndCorrectlyFormedEvents() {
    try {
      cassandraConnector.saveStreamDefinitionToStore(getCluster(), streamDefinition1);
    } catch (StreamDefinitionStoreException e) {
      e.printStackTrace();
      fail();
    }

    List<Event> eventList =
        EventConverterUtils.convertFromJson(
            CassandraTestConstants.properandImproperEvent, streamDefinition1.getStreamId());
    List<String> insertedEvents = new ArrayList<String>();
    int eventCounter = 0;
    for (Event event : eventList) {
      try {
        String rowKey = insertEvent(cluster, event, eventCounter++);
        // inserts row key only if event is valid, i.e. only proper events will add a row key
        insertedEvents.add(rowKey);
      } catch (Exception e) {
        // ignore
      }
    }
    assertEquals(2, insertedEvents.size());
  }
Exemple #3
0
  @Test
  public void testLoadSIF() throws Exception {
    String filepath = TestUtils.DATA_DIR + "sample/BRCA_sif.txt";
    List<String> expectedAttributeNames =
        Arrays.asList(
            "TCGA_EXPERIMENT",
            "TCGA_BATCH",
            "TUMOR_NORMAL",
            "BIRDSEED_GENDER",
            "LEVEL2_NOISE",
            "LEVEL3_SEGMENT_COUNT",
            "PURITY	PLOIDY",
            "DELTA",
            "CANCER_DNA_FRACTION",
            "SUBCLONAL_GENOME_FRACTION");

    tstLoadFi(filepath, 0, false); // Sample information file, shouldn't have tracks.

    Set<String> attrNames = new HashSet<String>(AttributeManager.getInstance().getAttributeNames());

    assertTrue(
        attrNames.size()
            >= expectedAttributeNames.size()); // Can be larger because of default attributes
    for (String name : expectedAttributeNames) {
      assertTrue(expectedAttributeNames.contains(name));
    }
  }
Exemple #4
0
  static List<Track> tstLoadFi(
      TrackLoader trackLoader,
      String filepath,
      Integer expected_tracks,
      Genome genome,
      boolean makeIndex)
      throws Exception {
    ResourceLocator locator = new ResourceLocator(filepath);

    // Try creating an index
    // UI would ask for confirmation
    if (makeIndex) {
      try {
        TestUtils.createIndex(filepath);
      } catch (Exception e) {

      }
    }
    List<Track> tracks = trackLoader.load(locator, genome);
    if (expected_tracks != null) {
      assertEquals(expected_tracks.intValue(), tracks.size());
      if (expected_tracks == 0) {
        return tracks;
      }
    }

    Track track = tracks.get(0);
    assertEquals(locator, track.getResourceLocator());

    return tracks;
  }
  @Test
  public void shouldNotDeleteEarlierFormIfNewerMotherFormWithSameInstanceIdHasOldDate() {
    NewForm persistedForm = new NewForm();
    persistedForm.setInstanceId("e34707f8-80c8-4198-bf99-c11c90ba5c98");
    final Date oldFormModifiedDate = DateTime.parse("2012-07-20T12:02:59.923+05:30").toDate();
    persistedForm.setServerDateModified(oldFormModifiedDate);
    persistedForm.setDateModified(oldFormModifiedDate);
    template.save(persistedForm);

    final String newFormModifiedOn = "2012-07-10T12:02:59.923+05:30";

    Map<String, String> motherFormValues =
        new HashMap<String, String>() {
          {
            put("caseId", "94d5374f-290e-409f-bc57-86c2e4bcc43f");
            put("dateModified", newFormModifiedOn);
            put("serverDateModified", newFormModifiedOn);
            put("userId", "89fda0284e008d2e0c980fb13fa0e5bb");
            put("xmlns", "http://bihar.commcarehq.org/pregnancy/new");
            put("instanceId", "e34707f8-80c8-4198-bf99-c11c90ba5c98");
          }
        };

    careService.processAndSaveForms(motherFormValues, new ArrayList<Map<String, String>>());

    List<NewForm> newFormsFromDb = template.loadAll(NewForm.class);
    assertEquals(1, newFormsFromDb.size());
    assertEquals(oldFormModifiedDate, newFormsFromDb.get(0).getDateModified());
  }
  @Test
  public void shouldDeleteEarlierFormIfBothNewerAndOlderMotherFormWithSameInstanceIdHasNullDate() {
    NewForm persistedForm = new NewForm();
    persistedForm.setInstanceId("e34707f8-80c8-4198-bf99-c11c90ba5c98");

    persistedForm.setCaste("OldCaste");
    persistedForm.setServerDateModified(null);
    template.save(persistedForm);

    final String newCaste = "NewCaste";

    Map<String, String> motherFormValues =
        new HashMap<String, String>() {
          {
            put("caseId", "94d5374f-290e-409f-bc57-86c2e4bcc43f");
            put("serverDateModified", null);
            put("userId", "89fda0284e008d2e0c980fb13fa0e5bb");
            put("xmlns", "http://bihar.commcarehq.org/pregnancy/new");
            put("instanceId", "e34707f8-80c8-4198-bf99-c11c90ba5c98");
            put("caste", newCaste);
          }
        };

    careService.processAndSaveForms(motherFormValues, new ArrayList<Map<String, String>>());

    List<NewForm> newFormsFromDb = template.loadAll(NewForm.class);
    assertEquals(1, newFormsFromDb.size());
    assertNull(newFormsFromDb.get(0).getDateModified());
    assertEquals(newCaste, newFormsFromDb.get(0).getCaste());
  }
Exemple #7
0
  /**
   * Test that we properly load a vcf file, even though the extension is upper-case. IGV-2012
   *
   * @throws Exception
   */
  @Test
  public void testLoadVCFUpperCase() throws Exception {
    String filepath = TestUtils.DATA_DIR + "vcf/HC_MOD_CAPS.VCF";
    ResourceLocator locator = new ResourceLocator(filepath);
    TestUtils.createIndex(filepath);

    List<Track> tracks = trackLoader.load(locator, genome);
    assertEquals(1, tracks.size());
    assertTrue("VCF file loaded incorrect track type", tracks.get(0) instanceof VariantTrack);
  }
  @Test
  public void shouldNotSaveMotherOrChildFormsIfNullAndEmpty() {
    careService.processAndSaveForms(null, new ArrayList<Map<String, String>>());

    List<MotherCase> mothers = template.loadAll(MotherCase.class);
    assertTrue(mothers.isEmpty());

    List<ChildCase> children = template.loadAll(ChildCase.class);
    assertTrue(children.isEmpty());
  }
Exemple #9
0
  @Test
  public void testWigAndBigWig() throws Exception {
    String wigPath = TestUtils.DATA_DIR + "wig/test_fixedStep.wig";
    String bigWigPath = TestUtils.DATA_DIR + "wig/test_fixedStep.bigwig";
    List<Track> wigtracks = tstLoadFi(wigPath, 1, false);
    List<Track> bigWigtracks = tstLoadFi(bigWigPath, 1, false);

    String chr = "chr19";
    int start = 5930725;
    int end = 5930764;
    int zoom = 21;

    DataSourceTrack wigTrack = (DataSourceTrack) wigtracks.get(0);
    DataSourceTrack bigWigTrack = (DataSourceTrack) bigWigtracks.get(0);

    int trials = 10;

    for (int ii = 0; ii < trials; ii++) {
      int strt = start + ii;
      List<LocusScore> wigScores = wigTrack.getSummaryScores(chr, strt, end, zoom);
      List<LocusScore> bigWigScores = bigWigTrack.getSummaryScores(chr, strt, end, zoom);
      assertEquals(wigScores.size(), bigWigScores.size());
      int ind = 0;
      for (LocusScore ws : wigScores) {
        LocusScore bws = bigWigScores.get(ind);
        assertEquals(ws.getScore(), bws.getScore());
        ind++;
      }
    }
  }
  @After
  public void resetServices() {
    final List<TaskModel> tasks = taskServiceStub.cleanup();
    final StringBuffer msg = new StringBuffer();
    for (final TaskModel task : tasks) {
      final ProcessTaskModel processTask = (ProcessTaskModel) task;

      msg.append(processTask.getAction()).append(", ");
    }

    assertTrue("tasks should be empty after test execution. Left: " + msg, tasks.isEmpty());
  }
  @Test
  public void shouldSaveFlwOnceForMotherAndChild() {
    final String flwId = "89fda0284e008d2e0c980fb13fa0e5bb";
    Flw flw = new FlwBuilder().flwId(flwId).build();
    final String instanceId = "e34707f8-80c8-4198-bf99-c11c90ba5c98";
    HashMap<String, String> motherCase =
        new HashMap<String, String>() {
          {
            put("caseId", "3e8998ce-b19f-4fa7-b1a1-721b6951e3cf");
            put("userId", flwId);
            put("flw", flwId);
            put("instanceId", instanceId);
            put("xmlns", "http://bihar.commcarehq.org/pregnancy/registration");
          }
        };

    final HashMap<String, String> child1 =
        new HashMap<String, String>() {
          {
            put("caseId", "3e8998ce-b19f-4fa7-b1a1-721b6951e3c1");
            put("userId", flwId);
            put("flw", flwId);
            put("instanceId", instanceId);
            put("xmlns", "http://bihar.commcarehq.org/pregnancy/registration");
          }
        };

    final HashMap<String, String> child2 =
        new HashMap<String, String>() {
          {
            put("caseId", "3e8998ce-b19f-4fa7-b1a1-721b6951e3c2");
            put("userId", flwId);
            put("flw", flwId);
            put("instanceId", instanceId);
            put("xmlns", "http://bihar.commcarehq.org/pregnancy/registration");
          }
        };

    careService.processAndSaveForms(
        motherCase,
        new ArrayList<Map<String, String>>() {
          {
            add(child1);
            add(child2);
          }
        });

    List<Flw> actualFlws = template.loadAll(Flw.class);
    assertEquals(1, actualFlws.size());

    assertReflectionEqualsWithIgnore(
        flw, actualFlws.get(0), new String[] {"id", "creationTime", "lastModifiedTime"});
  }
 public static void assertColumns(ColumnFamily cf, String... columnNames) {
   Collection<IColumn> columns = cf == null ? new TreeSet<IColumn>() : cf.getSortedColumns();
   List<String> L = new ArrayList<String>();
   for (IColumn column : columns) {
     L.add(new String(column.name()));
   }
   assert Arrays.equals(L.toArray(new String[columns.size()]), columnNames)
       : "Columns ["
           + ((cf == null) ? "" : cf.getComparator().getColumnsString(columns))
           + "]"
           + " is not expected ["
           + StringUtils.join(columnNames, ",")
           + "]";
 }
Exemple #13
0
  @Test
  public void testBedAndBigBed() throws Exception {
    String bedPath = TestUtils.DATA_DIR + "bed/Unigene.sample.nolong.bed";
    String bigBedPath = TestUtils.DATA_DIR + "bed/Unigene.sample.nolong.bigbed";

    File bigBedFile = new File(bigBedPath);

    // Need to index so query of bed file is accurate
    TestUtils.createIndex(bedPath);

    List<Track> bedtracks = tstLoadFi(bedPath, 1, false);
    List<Track> bigBedtracks = tstLoadFi(bigBedPath, 1, false);

    String chr = "chr2";
    int start = 178711404 - 1;
    int end = 179189619 + 1;

    FeatureTrack bedTrack = (FeatureTrack) bedtracks.get(0);
    FeatureTrack bigBedTrack = (FeatureTrack) bigBedtracks.get(0);

    // Multiple trials because we're concerned about file open/close issues
    int trials = 10;

    for (int ii = 0; ii < trials; ii++) {
      int strt = start + ii;
      List<Feature> bedFeatures = bedTrack.getFeatures(chr, strt, end);
      List<Feature> bigBedFeatures = bigBedTrack.getFeatures(chr, strt, end);
      TestUtils.assertFeatureListsEqual(bedFeatures.iterator(), bigBedFeatures.iterator());

      // NOT FOOLPROOF
      assertTrue(bigBedFile.canWrite());
    }
  }
  @Test
  public void shouldCreateNewFlw() {
    Flw newFlw =
        flw(
            "5ba9a0928dde95d187544babf6c0ad24",
            "FirstName1",
            flwGroupWithNameAndId("64a9a0928dde95d187544babf6c0ad38", "oldGroupName"));

    careService.saveOrUpdateAllByExternalPrimaryKey(Flw.class, Arrays.asList(newFlw));

    List<Flw> flwsFromDb = template.loadAll(Flw.class);
    assertEquals(1, flwsFromDb.size());
    assertReflectionContains(newFlw, flwsFromDb, new String[] {"id"});
  }
 private String stateMessage(StringBuilder builder) {
   for (Call receivedCall : receivedCalls) builder.append("\n  Received ").append(receivedCall);
   builder.append("\n");
   if (pendingCalls.isEmpty()) builder.append("\n  Awaiting no further calls");
   else for (Call pendingCall : pendingCalls) builder.append("\n  Awaiting ").append(pendingCall);
   return builder.toString();
 }
Exemple #16
0
  /**
   * Test loading segmented data file from a sql database, using a profile
   *
   * @throws Exception
   */
  @Test
  public void testLoadSegProfile() throws Exception {
    String path = TestUtils.DATA_DIR + "sql/seg_canFam2_profile.dbxml";

    int expectedTracks = 6;
    List<Track> tracks = trackLoader.load(new ResourceLocator(path), genome);
    assertEquals(expectedTracks, tracks.size());
    Set<String> expSampleIds =
        new HashSet<String>(
            Arrays.asList("0123-A", "0123-B-1", "0123-C-1", "0123-C-2", "0123-C-3"));
    Set<String> actSampleIds = new HashSet<String>(5);
    for (Track track : tracks) {
      if (track instanceof DataSourceTrack) {
        actSampleIds.add(track.getName());
      }
    }
    assertEquals(expSampleIds, actSampleIds);
  }
  @Test
  public void shouldSaveNewGroup() throws Exception {
    FlwGroup newGroup =
        new FlwGroupBuilder()
            .groupId("5ba9a0928dde95d187544babf6c0ad24")
            .name("amir team 1")
            .domain("care-mp")
            .awcCode("007")
            .caseSharing(true)
            .reporting(true)
            .build();

    careService.saveOrUpdateAllByExternalPrimaryKey(FlwGroup.class, Arrays.asList(newGroup));

    List<FlwGroup> flwGroupsFromDb = template.loadAll(FlwGroup.class);
    assertEquals(1, flwGroupsFromDb.size());
    assertReflectionContains(newGroup, flwGroupsFromDb, new String[] {"id"});
  }
  @Test
  public void
      shouldSaveChildFormByDeletingOlderFormIfFormWithSameInstanceIdAndCaseIdExistsAlready() {
    final String instanceId = "e34707f8-80c8-4198-bf99-c11c90ba5c98";
    final String caseId = "3e8998ce-b19f-4fa7-b1a1-721b6951e3cf";
    final Date oldFormModifiedDate = DateTime.parse("2012-07-10T12:02:59.923+05:30").toDate();

    ChildCase persistedChildCase = new ChildCase();
    persistedChildCase.setCaseId(caseId);

    final DeathChildForm persistedForm = new DeathChildForm();
    persistedForm.setInstanceId(instanceId);
    persistedForm.setChildCase(persistedChildCase);
    persistedForm.setDateModified(oldFormModifiedDate);
    persistedForm.setServerDateModified(oldFormModifiedDate);
    template.save(persistedForm);

    final String newFormModifiedOn = "2012-07-20T12:02:59.923+05:30";
    final Date newFormModifiedDate = DateTime.parse(newFormModifiedOn).toDate();
    final HashMap<String, String> deathChildFormValues =
        new HashMap<String, String>() {
          {
            put("caseId", caseId);
            put("dateModified", newFormModifiedOn);
            put("serverDateModified", newFormModifiedOn);
            put("userId", "89fda0284e008d2e0c980fb13fa0e5bb");
            put("close", "true");
            put("instanceId", instanceId);
            put("xmlns", "http://bihar.commcarehq.org/pregnancy/death");
          }
        };

    careService.processAndSaveForms(
        null,
        new ArrayList<Map<String, String>>() {
          {
            add(deathChildFormValues);
          }
        });

    List<DeathChildForm> deathChildForms = template.loadAll(DeathChildForm.class);
    assertEquals(1, deathChildForms.size());
    assertEquals(newFormModifiedDate, deathChildForms.get(0).getDateModified());
  }
  @Test
  public void shouldSaveMotherFormForExistingCase() {
    MotherCase motherCase = new MotherCase();
    motherCase.setCaseId("94d5374f-290e-409f-bc57-86c2e4bcc43f");
    template.save(motherCase);
    Flw flw = new Flw();
    flw.setFlwId("89fda0284e008d2e0c980fb13fa0e5bb");
    template.save(flw);
    Map<String, String> motherForm = motherFormValues(motherCase.getCaseId(), flw.getFlwId());

    careService.processAndSaveForms(motherForm, new ArrayList<Map<String, String>>());

    List<MotherCase> persistedMotherCases = template.loadAll(MotherCase.class);
    assertEquals(1, persistedMotherCases.size());
    List<NewForm> newForms = template.loadAll(NewForm.class);
    assertEquals(1, newForms.size());
    NewForm expectedForm = expectedForm(motherCase, flw);
    assertReflectionEqualsWithIgnore(
        expectedForm, newForms.get(0), new String[] {"id", "creationTime", "lastModifiedTime"});
  }
  @Test
  public void shouldInsertAnEntityByExternalPrimaryKeyWhenDoesNotExists() throws Exception {
    HashMap<String, String> flwValues =
        new HashMap<String, String>() {
          {
            put("flwId", "5ba9a0928dde95d187544babf6c0ad24");
            put("firstName", "FirstName1");
          }
        };
    careService.saveByExternalPrimaryKey(Flw.class, flwValues);

    List<Flw> flws = template.loadAll(Flw.class);

    Flw expectedFlw = flw("5ba9a0928dde95d187544babf6c0ad24", "FirstName1", null);
    assertEquals(1, flws.size());
    assertReflectionEqualsWithIgnore(
        expectedFlw,
        flws.get(0),
        new String[] {"id", "flwGroups", "creationTime", "lastModifiedTime"});
  }
  @Test
  public void shouldSaveChildForm() {
    ArrayList<Map<String, String>> childFormValues = new ArrayList<>();
    HashMap<String, String> childFormValue = new HashMap<>();
    childFormValue.put("caseId", "94d5374f-290e-409f-bc57-86c2e4bcc43f");
    childFormValue.put("xmlns", "http://bihar.commcarehq.org/pregnancy/registration");
    childFormValue.put("childName", "suraj");
    childFormValue.put("birthStatus", "healthy");
    childFormValue.put("instanceId", "ff2eb090-03a9-4f23-afed-cf6012784c55");
    childFormValue.put("flw", "89fda0284e008d2e0c980fb13fa0e5bb");
    childFormValue.put("timeStart", "2013-03-03T10:31:51.045+05:30");
    childFormValue.put("timeEnd", "2013-03-03T10:38:52.804+05:30");
    childFormValue.put("dateModified", "2013-03-03T10:38:52.804+05:30");

    childFormValues.add(childFormValue);

    careService.processAndSaveForms(null, childFormValues);

    List<RegistrationChildForm> registrationChildForms =
        template.loadAll(RegistrationChildForm.class);
    assertEquals(1, registrationChildForms.size());

    RegistrationChildForm expectedForm = getExpectedForm("94d5374f-290e-409f-bc57-86c2e4bcc43f");

    assertReflectionEqualsWithIgnore(
        expectedForm,
        registrationChildForms.get(0),
        new String[] {"id", "flw", "childCase", "creationTime", "lastModifiedTime"});

    List<Flw> flws = template.loadAll(Flw.class);
    assertEquals(1, flws.size());
    assertEquals("89fda0284e008d2e0c980fb13fa0e5bb", flws.get(0).getFlwId());
  }
Exemple #22
0
  @Test
  public void testLoadGFFAliasedChrs() throws Exception {
    String filepath = TestUtils.DATA_DIR + "gff/aliased.unsorted.gff";
    Genome genome =
        IgvTools.loadGenome(TestUtils.DATA_DIR + "genomes/hg18_truncated_aliased.genome");
    List<Track> tracks = trackLoader.load(new ResourceLocator(filepath), genome);
    assertEquals(1, tracks.size());
    FeatureTrack track = (FeatureTrack) tracks.get(0);

    assertEquals("aliased.unsorted.gff", track.getName());

    List<Feature> features = track.getFeatures("chr1", 0, Integer.MAX_VALUE);
    assertEquals(56, features.size());

    features = track.getFeatures("chr5", 0, Integer.MAX_VALUE);
    assertEquals(16, features.size());

    // Non-aliased
    features = track.getFeatures("NC_007072.3", 0, Integer.MAX_VALUE);
    assertEquals(30, features.size());
  }
  @Test
  public void shouldSaveMotherFormAndCreateNewCase() {
    Map<String, String> motherForm =
        motherFormValues(
            "94d5374f-290e-409f-bc57-86c2e4bcc43f", "89fda0284e008d2e0c980fb13fa0e5bb");

    careService.processAndSaveForms(motherForm, new ArrayList<Map<String, String>>());

    List<MotherCase> persistedMotherCases = template.loadAll(MotherCase.class);
    assertEquals(1, persistedMotherCases.size());
    List<NewForm> newForms = template.loadAll(NewForm.class);
    assertEquals(1, newForms.size());
    NewForm expectedForm =
        expectedForm(
            new MotherCaseBuilder().caseId("94d5374f-290e-409f-bc57-86c2e4bcc43f").build(),
            new FlwBuilder().flwId("89fda0284e008d2e0c980fb13fa0e5bb").build());
    assertReflectionEqualsWithIgnore(
        expectedForm, newForms.get(0), new String[] {"id", "creationTime", "flw", "motherCase"});
    assertEquals(
        "94d5374f-290e-409f-bc57-86c2e4bcc43f", newForms.get(0).getMotherCase().getCaseId());
    assertEquals("89fda0284e008d2e0c980fb13fa0e5bb", newForms.get(0).getFlw().getFlwId());
  }
Exemple #24
0
  @Test
  public void testLoadGFF() throws Exception {
    String filepath = TestUtils.DATA_DIR + "gff/simfeatures.gff3";
    List<Track> tracks = trackLoader.load(new ResourceLocator(filepath), genome);
    assertEquals(1, tracks.size());
    FeatureTrack track = (FeatureTrack) tracks.get(0);

    assertEquals("notmeaningful", track.getName());

    List<Feature> features = track.getFeatures("chr1", 0, Integer.MAX_VALUE);
    assertEquals(2, features.size());

    IGVFeature feat0 = (IGVFeature) features.get(0);
    IGVFeature feat1 = (IGVFeature) features.get(1);

    assertEquals(707 - 1, feat0.getStart());
    assertEquals(943, feat0.getEnd());
    assertEquals(7563 - 1, feat1.getStart());
    assertEquals(7938, feat1.getEnd());
  }
Exemple #25
0
  /**
   * Test loading sample information file from a sql database, using a profile
   *
   * @throws Exception
   */
  @Test
  public void testLoadSampleInfoProfile() throws Exception {

    AttributeManager.getInstance().clearAllAttributes();
    String path = TestUtils.DATA_DIR + "sql/sampleinfo_brca_sif_profile.dbxml";

    int expectedTracks = 0;
    List<Track> tracks = trackLoader.load(new ResourceLocator(path), genome);
    assertEquals(expectedTracks, tracks.size());

    String[] attrNames =
        "TCGA_EXPERIMENT	TCGA_BATCH	TUMOR_NORMAL	BIRDSEED_GENDER	LEVEL2_NOISE	LEVEL3_SEGMENT_COUNT	PURITY	PLOIDY	DELTA	CANCER_DNA_FRACTION	SUBCLONAL_GENOME_FRACTION"
            .split("\\s+");
    Set<String> expAttrNames = new HashSet<String>(Arrays.asList(attrNames));
    List<String> actAttrNames = AttributeManager.getInstance().getAttributeNames();
    actAttrNames.remove("NAME");
    actAttrNames.remove("DATA TYPE");
    actAttrNames.remove("DATA FILE");
    assertEquals(actAttrNames.size(), expAttrNames.size());
    for (String attrName : actAttrNames) {
      assertTrue(expAttrNames.contains(attrName));
    }
  }
 @Test
 public void testDataConsumption() throws Exception {
   List<SampleData> ginzburg = create("ginzburg", 10, 10);
   assertEquals(ginzburg.size(), 10);
 }
 public void expect(Call call) {
   pendingCalls.add(call);
 }
 public void assertExpectationsMet() throws AssertionFailedError {
   assertTrue(
       stateMessage(new StringBuilder("Expected call never received")), pendingCalls.isEmpty());
 }
  public void call(Call call) throws AssertionFailedError {
    if (pendingCalls.isEmpty() || !pendingCalls.get(0).equals(call))
      fail(stateMessage(new StringBuilder("Unexpected call: ").append(call)));

    receivedCalls.add(pendingCalls.remove(0));
  }
  @Test
  public void insertEventsFromMultipleStreams() {
    try {
      // save stream defn 1
      cassandraConnector.saveStreamDefinitionToStore(getCluster(), streamDefinition1);

      // save stream defn 3
      cassandraConnector.saveStreamDefinitionToStore(getCluster(), streamDefinition3);
    } catch (StreamDefinitionStoreException e) {
      e.printStackTrace();
      fail();
    }

    List<Event> eventList = new ArrayList<Event>();
    // retrieve stream id 1
    eventList.addAll(
        EventConverterUtils.convertFromJson(
            CassandraTestConstants.multipleProperEvent1, streamDefinition1.getStreamId()));

    // retrieve stream id 3
    eventList.addAll(
        EventConverterUtils.convertFromJson(
            CassandraTestConstants.multipleProperEvent3, streamDefinition3.getStreamId()));

    Map<String, Event> insertedEvents = new HashMap<String, Event>();
    int eventCounter = 0;
    for (Event event : eventList) {
      try {
        String rowKey = insertEvent(cluster, event, eventCounter++);
        // inserts row key only if event is valid, i.e. only proper events will add a row key
        insertedEvents.put(rowKey, event);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    assertEquals(4, insertedEvents.size());

    Map<String, Event> retrievedEvents = new HashMap<String, Event>();

    for (Map.Entry<String, Event> eventProps : insertedEvents.entrySet()) {
      try {
        retrievedEvents.put(
            eventProps.getKey(),
            getEvent(cluster, eventProps.getValue().getStreamId(), eventProps.getKey()));
      } catch (EventProcessingException e) {
        e.printStackTrace();
        fail();
      }
    }

    for (Map.Entry<String, Event> rowKeyAndEvent : retrievedEvents.entrySet()) {
      Event retrievedEvent = rowKeyAndEvent.getValue();
      Event originialEvent = insertedEvents.get(rowKeyAndEvent.getKey());
      System.out.println(
          "Retrieved Event : " + retrievedEvent + "\n Original Event : " + originialEvent + "\n\n");
      if (streamDefinition1.getStreamId().equals(originialEvent.getStreamId())) {
        assertTrue(DataBridgeUtils.equals(originialEvent, retrievedEvent, streamDefinition1));
      } else if (streamDefinition2.getStreamId().equals(originialEvent.getStreamId())) {
        assertTrue(DataBridgeUtils.equals(originialEvent, retrievedEvent, streamDefinition3));
      }
    }
  }