@Test
  public void shouldSearchForExistingGroupBeforeUpdating() throws Exception {
    FlwGroup toBeUpdatedGroup =
        new FlwGroupBuilder()
            .groupId("5ba9a0928dde95d187544babf6c0ad24")
            .name("afrisis team 1")
            .domain("care-bihar")
            .awcCode("001")
            .caseSharing(true)
            .reporting(true)
            .build();
    FlwGroup notToBeUpdatedGroup =
        flwGroupWithNameAndId("5ba9a0928dde95d187544babf6c0af36", "ashok team 1");

    template.saveOrUpdateAll(Arrays.asList(toBeUpdatedGroup, notToBeUpdatedGroup));

    FlwGroup updatedGroup = updatedGroup();

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

    FlwGroup loadedFlwGroup = template.load(FlwGroup.class, toBeUpdatedGroup.getId());
    FlwGroup unchangedFlwGroup = template.load(FlwGroup.class, notToBeUpdatedGroup.getId());
    assertReflectionEqualsWithIgnore(
        updatedGroup(), loadedFlwGroup, new String[] {"id", "creationTime", "lastModifiedTime"});
    assertDateIgnoringSeconds(new Date(), loadedFlwGroup.getCreationTime());
    assertDateIgnoringSeconds(new Date(), loadedFlwGroup.getLastModifiedTime());
    assertEquals("ashok team 1", unchangedFlwGroup.getName());
  }
Exemple #2
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));
    }
  }
  @Test
  public void shouldSearchExistingFlwsAndUpdateFlw() {
    Flw toBeUpdatedFlw =
        flw(
            "5ba9a0928dde95d187544babf6c0ad24",
            "FirstName1",
            flwGroupWithNameAndId("64a9a0928dde95d187544babf6c0ad38", "oldGroupName"));
    Flw notToBeUpdateFlw = flw("5ba9a0928dde95d187544babf6c0ad25", "FirstName2", new FlwGroup());
    template.saveOrUpdateAll(Arrays.asList(toBeUpdatedFlw, notToBeUpdateFlw));

    Flw newFlw =
        flw(
            "5ba9a0928dde95d187544babf6c0ad24",
            "FirstName3",
            flwGroupWithNameAndId("38a9a0928dde95d187544babf6c0ad64", "newGroupName"));
    ArrayList<Flw> flwsToUpdate = new ArrayList<>();
    flwsToUpdate.add(newFlw);

    careService.saveOrUpdateAllByExternalPrimaryKey(Flw.class, flwsToUpdate);

    Flw updatedFlw = template.load(Flw.class, toBeUpdatedFlw.getId());
    assertReflectionEqualsWithIgnore(
        newFlw, updatedFlw, new String[] {"id", "creationTime", "lastModifiedTime"});
    assertDateIgnoringSeconds(new Date(), updatedFlw.getCreationTime());
    assertDateIgnoringSeconds(new Date(), updatedFlw.getLastModifiedTime());

    Flw unchangedFlw = template.load(Flw.class, notToBeUpdateFlw.getId());
    assertEquals("FirstName2", unchangedFlw.getFirstName());
  }
  @BeforeClass
  public static void prepare() throws Exception // NOPMD
      {
    Registry.activateStandaloneMode();
    Utilities.setJUnitTenant();
    LOG.debug("Preparing...");

    final ApplicationContext appCtx = Registry.getGlobalApplicationContext();

    assertTrue(
        "Application context of type "
            + appCtx.getClass()
            + " is not a subclass of "
            + ConfigurableApplicationContext.class,
        appCtx instanceof ConfigurableApplicationContext);

    final ConfigurableApplicationContext applicationContext =
        (ConfigurableApplicationContext) appCtx;
    final ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory();
    assertTrue(
        "Bean Factory of type "
            + beanFactory.getClass()
            + " is not of type "
            + BeanDefinitionRegistry.class,
        beanFactory instanceof BeanDefinitionRegistry);
    final XmlBeanDefinitionReader xmlReader =
        new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory);
    xmlReader.setDocumentReaderClass(ScopeTenantIgnoreDocReader.class);
    xmlReader.loadBeanDefinitions(
        new ClassPathResource(
            "/merchandisefulfilmentprocess/test/merchandisefulfilmentprocess-spring-test.xml"));
    xmlReader.loadBeanDefinitions(
        new ClassPathResource(
            "/merchandisefulfilmentprocess/test/merchandisefulfilmentprocess-spring-test-fraudcheck.xml"));
    xmlReader.loadBeanDefinitions(
        new ClassPathResource(
            "/merchandisefulfilmentprocess/test/process/order-process-spring.xml"));
    modelService = (ModelService) getBean("modelService");
    processService = (DefaultBusinessProcessService) getBean("businessProcessService");
    definitonFactory = processService.getProcessDefinitionFactory();

    LOG.warn("Prepare Process Definition factory...");
    definitonFactory.add(
        "classpath:/merchandisefulfilmentprocess/test/process/payment-process.xml");

    // setup command factory to mock
    final DefaultCommandFactoryRegistryImpl commandFactoryReg =
        appCtx.getBean(DefaultCommandFactoryRegistryImpl.class);
    commandFactoryReg.setCommandFactoryList(
        Arrays.asList((CommandFactory) appCtx.getBean("mockupCommandFactory")));

    taskServiceStub = appCtx.getBean(TaskServiceStub.class);
    productService = appCtx.getBean("defaultProductService", DefaultProductService.class);
    cartService = appCtx.getBean("defaultCartService", DefaultCartService.class);
    userService = appCtx.getBean("defaultUserService", DefaultUserService.class);
  }
  @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"});
  }
Exemple #6
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"});
  }
Exemple #8
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));
    }
  }