@Test public final void shouldThrowExceptionWhenTryToInsertWrongConversion() { final String unitTo = "unitTo"; final String unitFrom = "wrong" + UNIT_FROM; try { possibleUnitConversionsImpl.addConversion(mockUnitConversion(unitFrom, BigDecimal.ONE, unitTo)); Assert.fail(); } catch (Exception e) { } }
@Override public void addConversion(final UnitConversion unitConversion) { Preconditions.checkArgument(unitFrom.equals(unitConversion.getUnitFrom()), "Wrong source unit!"); final String unit = unitConversion.getUnitTo(); if (!isDefinedFor(unit)) { targetUnitToFactor.put(unitConversion.getUnitTo(), unitConversion.getRatio()); } }
PossibleUnitConversionsImpl implements InternalPossibleUnitConversions { @Override public void addConversion(final UnitConversion unitConversion) { Preconditions.checkArgument(unitFrom.equals(unitConversion.getUnitFrom()), "Wrong source unit!"); final String unit = unitConversion.getUnitTo(); if (!isDefinedFor(unit)) { targetUnitToFactor.put(unitConversion.getUnitTo(), unitConversion.getRatio()); } } }
PossibleUnitConversionsImpl implements InternalPossibleUnitConversions { @Override public void addConversion(final UnitConversion unitConversion) { Preconditions.checkArgument(unitFrom.equals(unitConversion.getUnitFrom()), "Wrong source unit!"); final String unit = unitConversion.getUnitTo(); if (!isDefinedFor(unit)) { targetUnitToFactor.put(unitConversion.getUnitTo(), unitConversion.getRatio()); } } PossibleUnitConversionsImpl(final String unitFrom, final NumberService numberService,
            final DataDefinition unitConversionItemDD, DictionaryService dictionaryService); }
PossibleUnitConversionsImpl implements InternalPossibleUnitConversions { @Override public void addConversion(final UnitConversion unitConversion) { Preconditions.checkArgument(unitFrom.equals(unitConversion.getUnitFrom()), "Wrong source unit!"); final String unit = unitConversion.getUnitTo(); if (!isDefinedFor(unit)) { targetUnitToFactor.put(unitConversion.getUnitTo(), unitConversion.getRatio()); } } PossibleUnitConversionsImpl(final String unitFrom, final NumberService numberService,
            final DataDefinition unitConversionItemDD, DictionaryService dictionaryService); @Override void addConversion(final UnitConversion unitConversion); @Override boolean isEmpty(); @Override boolean isDefinedFor(final String unit); @Override Set<String> getSupportedUnits(); @Override BigDecimal convertTo(final BigDecimal quantityFrom, final String unitTo); @Override BigDecimal convertTo(BigDecimal quantityFrom, String unitTo, int roundMode); @Override String getUnitFrom(); @Override Map<String, BigDecimal> asUnitToConversionMap(); @Override List<Entity> asEntities(final String ownerFieldName, final Entity ownerEntity); }
PossibleUnitConversionsImpl implements InternalPossibleUnitConversions { @Override public void addConversion(final UnitConversion unitConversion) { Preconditions.checkArgument(unitFrom.equals(unitConversion.getUnitFrom()), "Wrong source unit!"); final String unit = unitConversion.getUnitTo(); if (!isDefinedFor(unit)) { targetUnitToFactor.put(unitConversion.getUnitTo(), unitConversion.getRatio()); } } PossibleUnitConversionsImpl(final String unitFrom, final NumberService numberService,
            final DataDefinition unitConversionItemDD, DictionaryService dictionaryService); @Override void addConversion(final UnitConversion unitConversion); @Override boolean isEmpty(); @Override boolean isDefinedFor(final String unit); @Override Set<String> getSupportedUnits(); @Override BigDecimal convertTo(final BigDecimal quantityFrom, final String unitTo); @Override BigDecimal convertTo(BigDecimal quantityFrom, String unitTo, int roundMode); @Override String getUnitFrom(); @Override Map<String, BigDecimal> asUnitToConversionMap(); @Override List<Entity> asEntities(final String ownerFieldName, final Entity ownerEntity);  }