コード例 #1
0
  @Test
  public void testConvertNetworkMetaAnalysis()
      throws Exception, InstantiationException, InvocationTargetException, NoSuchMethodException {
    Domain domain = new DomainImpl();
    ExampleData.initDefaultData(domain);
    String name = "CGI network meta-analysis";
    MetaAnalysisWithStudies ma = d_jaxbConverterTest.buildNetworkMetaAnalysis(name);

    List<Study> studies = new ArrayList<Study>();
    for (org.drugis.addis.entities.data.Study study : ma.d_studies) {
      Study studyEnt = JAXBConvertor.convertStudy(study, domain);
      domain.getStudies().add(studyEnt);
      studies.add(studyEnt);
    }

    TreatmentDefinition combi =
        TreatmentDefinition.createTrivial(
            Arrays.asList(ExampleData.buildDrugFluoxetine(), ExampleData.buildDrugSertraline()));
    TreatmentDefinition parox =
        TreatmentDefinition.createTrivial(ExampleData.buildDrugParoxetine());
    TreatmentDefinition sertr =
        TreatmentDefinition.createTrivial(ExampleData.buildDrugSertraline());
    SortedSet<TreatmentDefinition> alternatives = new TreeSet<TreatmentDefinition>();
    alternatives.add(combi);
    alternatives.add(parox);
    alternatives.add(sertr);
    Map<Study, Map<TreatmentDefinition, Arm>> armMap =
        new HashMap<Study, Map<TreatmentDefinition, Arm>>();
    Map<TreatmentDefinition, Arm> study1map = new HashMap<TreatmentDefinition, Arm>();
    study1map.put(combi, studies.get(0).getArms().get(0));
    study1map.put(sertr, studies.get(0).getArms().get(1));
    armMap.put(studies.get(0), study1map);
    Map<TreatmentDefinition, Arm> study2map = new HashMap<TreatmentDefinition, Arm>();
    study2map.put(parox, studies.get(1).getArms().get(0));
    study2map.put(sertr, studies.get(1).getArms().get(1));
    armMap.put(studies.get(1), study2map);
    Map<TreatmentDefinition, Arm> study3map = new HashMap<TreatmentDefinition, Arm>();
    study3map.put(sertr, studies.get(2).getArms().get(0));
    study3map.put(parox, studies.get(2).getArms().get(1));
    study3map.put(combi, studies.get(2).getArms().get(2));
    armMap.put(studies.get(2), study3map);

    Collections.sort(
        studies); // So the reading *by definition* puts the studies in their natural order
    NetworkMetaAnalysis expected =
        new NetworkMetaAnalysis(
            name,
            ExampleData.buildIndicationDepression(),
            ExampleData.buildEndpointCgi(),
            studies,
            alternatives,
            armMap);

    assertEntityEquals(expected, NetworkMetaAnalysisConverter.load(ma.d_nwma, domain));
    assertEquals(ma.d_nwma, NetworkMetaAnalysisConverter.save(expected));
  }
コード例 #2
0
 private static InputStream getTransformedSavedResultsData()
     throws TransformerException, IOException {
   return JAXBConvertorTest.getTestData(TEST_DATA_WITH_RESULTS);
 }
コード例 #3
0
 @Before
 public void setUp() throws JAXBException {
   d_jaxbConverterTest = new JAXBConvertorTest();
   d_jaxbConverterTest.setup();
 }
コード例 #4
0
 @Test
 public void testRoundTrip()
     throws JAXBException, ConversionException, TransformerException, IOException, SAXException {
   d_jaxbConverterTest.doRoundTripTest(getTransformedSavedResultsData(), false);
 }