SampleWrapper implements BioMoleculeWrapperI { @Override public List<SampleMeta> getAllSampleMeta(){ List<SampleMeta> sm = new ArrayList<SampleMeta>(); if (sample.getSampleMeta() != null && !sample.getSampleMeta().isEmpty()) sm.addAll(sample.getSampleMeta()); if (parent != null) sm.addAll(parent.getAllSampleMeta()); return sm; } SampleWrapper(Sample sample); @Override List<SampleMeta> getAllSampleMeta(); @Override Sample getSampleObject(); @Override SampleWrapper getParentWrapper(); @Override Set<String> getAllSampleMetaAreas(); @Override List<SampleMeta> getMetaTemplatedToSampleSybtype(SampleSubtype sampleSubtype); @Override void setParent(Sample parentSample); @Override List<SampleMeta> updateMetaToList(List<SampleMeta> inputMetaList, SampleMetaDao sampleMetaDao); @Override void saveAll(SampleService sampleService);  }
@Test (groups = "unit-tests", dependsOnMethods = {"testSampleWrapperConstruct"}) public void testSampleWrapperGetAllSampleMeta() { SampleWrapper managedSample = new SampleWrapper(sample); List<SampleMeta> allMeta = managedSample.getAllSampleMeta(); Assert.assertEquals(allMeta.size(), 4); Map<String, Integer> results = new HashMap<String, Integer>(); for (SampleMeta m: allMeta){ logger.debug(m.toString()); try{ results.put(m.getK(), Integer.valueOf(m.getV())); } catch(NumberFormatException e){ Assert.fail("couldn't get integer value of " +m.getV()+ " for key "+m.getK() ); } } Assert.assertTrue(results.containsKey("sampleMeta1.key1")); Assert.assertTrue(results.containsKey("sampleMeta1.key2")); Assert.assertTrue(results.containsKey("parentSampleMeta2.key3")); Assert.assertTrue(results.containsKey("parentSampleMeta2.key4")); Assert.assertTrue(results.get("sampleMeta1.key1").intValue() == 1); Assert.assertTrue(results.get("sampleMeta1.key2").intValue() == 2); Assert.assertTrue(results.get("parentSampleMeta2.key3").intValue() == 3); Assert.assertTrue(results.get("parentSampleMeta2.key4").intValue() == 4); }