@Test
 public void shouldApplyCurrentCurrency() throws Exception {
   // given
   FieldComponent field = mock(FieldComponent.class);
   Long currencyId = 1L;
   when(view.getComponentByReference("currency")).thenReturn(field);
   when(currencyService.getCurrentCurrency()).thenReturn(currency);
   when(currency.getId()).thenReturn(currencyId);
   // when
   currencyViewService.applyCurrentCurrency(view);
   // then
   Mockito.verify(field).setFieldValue(currencyId);
 }
  public void fillCurrencyFields(
      final ViewDefinitionState viewDefinitionState, final Set<String> fieldNames) {
    checkArgument(viewDefinitionState != null, L_VIEW_DEFINITION_STATE_IS_NULL);

    FormComponent form = (FormComponent) viewDefinitionState.getComponentByReference(L_FORM);
    clearAndDisabledFields(viewDefinitionState, fieldNames);
    if (form == null || form.getEntityId() == null) {
      return;
    }
    String currency = currencyService.getCurrencyAlphabeticCode();
    if (currency == null) {
      return;
    }
    for (String fieldName : fieldNames) {
      FieldComponent currencyField =
          (FieldComponent) viewDefinitionState.getComponentByReference(fieldName);
      fillField(currencyField, currency);
    }
  }