use of uk.nhs.digital.common.components.apispecification.handlebars.OptionsStub.Hash in project hippo by NHS-digital-website.
the class IndentationHelperTest method returnsWeightedIndentationLevel_whenWeightingSet.
@Test
public void returnsWeightedIndentationLevel_whenWeightingSet() {
// given
final int ancestorCount = RandomUtils.nextInt();
final double weighting = 1.5;
final String expectedIndentationLevel = String.format("%.1f", ancestorCount * weighting);
final Context context = Context.newContext(new Object());
final ContextModelsStack contextModelsStack = mock(ContextModelsStack.class);
given(contextModelsStack.ancestorModelsCount()).willReturn(ancestorCount);
final ContextModelsStack.Factory contextStackFactory = mock(ContextModelsStack.Factory.class);
given(contextStackFactory.from(context)).willReturn(contextModelsStack);
final IndentationHelper indentationHelper = IndentationHelper.with(contextStackFactory);
final Hash hash = Hash.of("weighting", weighting);
final Options options = OptionsStub.with(context, hash);
// when
final String actualIndentationLevel = indentationHelper.apply(null, options);
// then
assertThat("Total number of ancestor Contexts is returned.", actualIndentationLevel, is(expectedIndentationLevel));
}