Threshold { @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append( "Threshold[" ); builder.append( "dosAttack=" ).append( minimum.getName() ); List<DoSParam<?>> minParams = minimum.getCurrentParams(); List<DoSParam<?>> maxParams = maximum.getCurrentParams(); for ( int index = 0; index < minParams.size(); index++ ) { DoSParam<?> minParam = minParams.get( index ); DoSParam<?> maxParam = maxParams.get( index ); if ( !minParam.getValueAsString().equals( maxParam.getValueAsString() ) ) { builder.append( ", " ).append( minParam.getDescription() ).append( "=" ).append( minParam.getValueAsString() ).append( "-" ).append( maxParam.getValueAsString() ); } } builder.append( "]" ); return builder.toString(); } Threshold( DoSAttack minimum, DoSAttack maximum ); DoSAttack getMinimum(); DoSAttack getMaximum(); @Override String toString();  }
@Test public void test() { DoSAttack minimum = mock(DoSAttack.class); when(minimum.getName()).thenReturn("test"); List<DoSParam<?>> value = new ArrayList<>(); DoSParam<Integer> dp = new DoSParam<Integer>("abc", 123); value.add(dp); when(minimum.getCurrentParams()).thenReturn(value); DoSAttack maximum = mock(DoSAttack.class); value = new ArrayList<>(); when(maximum.getCurrentParams()).thenReturn(value); dp = new DoSParam<Integer>("abc", 456); value.add(dp); Threshold threshold = new Threshold(minimum, maximum); assertThat(threshold.toString(), is("Threshold[dosAttack=test, abc=123-456]")); }