WindowsSettingsGenerator implements ResourceGenerator<UserCredentials> { @NotNull @Override public String create(@NotNull final UserCredentials userCredentials) { final StringBuilder sb = new StringBuilder(); final String user = userCredentials.getUser(); if(!StringUtil.isEmptyOrSpaces(user)) { sb.append(USER_CMD_KEY); sb.append(userCredentials.getUser()); } if(userCredentials.getWindowsIntegrityLevel() != WindowsIntegrityLevel.Auto) { if(sb.length() > 0) { sb.append(LINE_SEPARATOR); } sb.append(INTEGRITY_LEVEL_CMD_KEY); sb.append(userCredentials.getWindowsIntegrityLevel().getValue()); } if(userCredentials.getLoggingLevel() != LoggingLevel.Off) { if(sb.length() > 0) { sb.append(LINE_SEPARATOR); } sb.append(LOGGING_LEVEL_CMD_KEY); sb.append(userCredentials.getLoggingLevel().getValue()); } if(sb.length() > 0 && userCredentials.getAdditionalArgs().size() > 0) { sb.append(LINE_SEPARATOR); } sb.append( StringUtil.join( CollectionsUtil.convertCollection( userCredentials.getAdditionalArgs(), new Converter<String, CommandLineArgument>() { @Override public String createFrom(@NotNull final CommandLineArgument commandLineArgument) { return commandLineArgument.getValue(); } }), LINE_SEPARATOR)); return sb.toString(); }  @NotNull @Override String create(@NotNull final UserCredentials userCredentials);  }
@Test() public void shouldGenerateContent() { final String expectedContent = "-u:nik" + ourlineSeparator + "arg1" + ourlineSeparator + "arg 2"; final List<CommandLineArgument> additionalArgs = Arrays.asList(new CommandLineArgument("arg1", CommandLineArgument.Type.PARAMETER), new CommandLineArgument("arg 2", CommandLineArgument.Type.PARAMETER)); final ResourceGenerator<UserCredentials> instance = createInstance(); final String content = instance.create(new UserCredentials("someprofile", "nik", "aaa", WindowsIntegrityLevel.Auto, LoggingLevel.Off, additionalArgs)); myCtx.assertIsSatisfied(); then(content.trim().replace("\n", " ").replace("\r", "")).isEqualTo(expectedContent.trim().replace("\n", " ").replace("\r", "")); }