@Test public void convert_shouldConvertString() { DrugReference drugRef1 = converter.convert("C$84309AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); Assert.assertTrue(drugRef1.isConceptOnly()); Assert.assertEquals(Context.getConceptService().getConceptByUuid("84309AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), drugRef1.getConcept()); DrugReference drugRef2 = converter.convert("D$97810e6b-cfcf-44fa-b63c-5d3e12cbe8d7"); Assert.assertFalse(drugRef2.isConceptOnly()); Assert.assertEquals(Context.getConceptService().getDrugByUuid("97810e6b-cfcf-44fa-b63c-5d3e12cbe8d7"), drugRef2.getDrug()); Assert.assertNull(converter.convert("xxxx")); Assert.assertNull(converter.convert("B$123")); }
@Override public DrugReference convert(String source) { String[] tokens = source.split("\\$"); if (tokens.length != 2) { return null; } if (tokens[0].equals("C")) { return DrugReference.fromConceptUuid(tokens[1]); } else if (tokens[0].equals("D")) { return DrugReference.fromDrugUuid(tokens[1]); } else { return null; } }
StringToDrugReferenceConverter implements Converter<String, DrugReference> { @Override public DrugReference convert(String source) { String[] tokens = source.split("\\$"); if (tokens.length != 2) { return null; } if (tokens[0].equals("C")) { return DrugReference.fromConceptUuid(tokens[1]); } else if (tokens[0].equals("D")) { return DrugReference.fromDrugUuid(tokens[1]); } else { return null; } } }
StringToDrugReferenceConverter implements Converter<String, DrugReference> { @Override public DrugReference convert(String source) { String[] tokens = source.split("\\$"); if (tokens.length != 2) { return null; } if (tokens[0].equals("C")) { return DrugReference.fromConceptUuid(tokens[1]); } else if (tokens[0].equals("D")) { return DrugReference.fromDrugUuid(tokens[1]); } else { return null; } }  }
StringToDrugReferenceConverter implements Converter<String, DrugReference> { @Override public DrugReference convert(String source) { String[] tokens = source.split("\\$"); if (tokens.length != 2) { return null; } if (tokens[0].equals("C")) { return DrugReference.fromConceptUuid(tokens[1]); } else if (tokens[0].equals("D")) { return DrugReference.fromDrugUuid(tokens[1]); } else { return null; } }  @Override DrugReference convert(String source); }
StringToDrugReferenceConverter implements Converter<String, DrugReference> { @Override public DrugReference convert(String source) { String[] tokens = source.split("\\$"); if (tokens.length != 2) { return null; } if (tokens[0].equals("C")) { return DrugReference.fromConceptUuid(tokens[1]); } else if (tokens[0].equals("D")) { return DrugReference.fromDrugUuid(tokens[1]); } else { return null; } }  @Override DrugReference convert(String source);  }