### Question:
FlowLoggerProfile { public static FlowLoggerProfile convert(ServiceProfile<?> profile) { if (profile == null) { throw new IllegalArgumentException("profile must not be null"); } Map<String, String> copy = new TreeMap<>(profile.getConfiguration()); String dirString = extract(profile, copy, KEY_DIRECTORY, null); String encString = extract(profile, copy, KEY_ENCODING, DEFAULT_ENCODING); String dfString = extract(profile, copy, KEY_DATE_FORMAT, DEFAULT_DATE_FORMAT); double stepUnit = extractDouble(profile, copy, KEY_STEP_UNIT, DEFAULT_STEP_UNIT); boolean reportJob = extractBoolean(profile, copy, KEY_REPORT_JOB, DEFAULT_REPORT_JOB); boolean deleteOnSetup = extractBoolean(profile, copy, KEY_DELETE_ON_SETUP, DEFAULT_DELETE_ON_SETUP); boolean deleteOnCleanup = extractBoolean(profile, copy, KEY_DELETE_ON_CLEANUP, DEFAULT_DELETE_ON_CLEANUP); if (copy.isEmpty() == false) { throw new IllegalArgumentException(MessageFormat.format( "Unknown profile parameters in {0} ({1})", profile.getPrefix(), copy)); } File file = new File(dirString); Charset encoding; try { encoding = Charset.forName(encString); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(MessageFormat.format( "Invalid charset in {0}.{1} ({2})", profile.getPrefix(), KEY_ENCODING, encString), e); } DateFormat dateFormat; try { dateFormat = new SimpleDateFormat(dfString); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(MessageFormat.format( "Invalid date format in {0}.{1} ({2})", profile.getPrefix(), KEY_DATE_FORMAT, dfString), e); } return new FlowLoggerProfile( file, encoding, dateFormat, stepUnit, reportJob, deleteOnSetup, deleteOnCleanup); } FlowLoggerProfile(
            File directory,
            Charset encoding,
            DateFormat dateFormat,
            double stepUnit,
            boolean reportJob,
            boolean deleteOnSetup,
            boolean deleteOnCleanup); File getDirectory(); Charset getEncoding(); DateFormat getDateFormat(); double getStepUnit(); boolean isReportJob(); boolean isDeleteOnSetup(); boolean isDeleteOnCleanup(); File getLogFile(ExecutionContext context); File getEscapeFile(ExecutionContext context); static FlowLoggerProfile convert(ServiceProfile<?> profile);  }### Answer:
@Test public void convert() throws Exception { Map<String, String> conf = map(KEY_DIRECTORY, folder.getRoot().getAbsolutePath()); Map<String, String> vars = map(); ServiceProfile<FlowLoggerProvider> sp = profile(conf, vars); FlowLoggerProfile profile = FlowLoggerProfile.convert(sp); assertThat(profile.getDirectory().getCanonicalFile(), is(folder.getRoot().getCanonicalFile())); assertThat(profile.getEncoding(), is(Charset.forName(DEFAULT_ENCODING))); assertThat(profile.getDateFormat(), is((DateFormat) new SimpleDateFormat(DEFAULT_DATE_FORMAT))); assertThat(profile.getStepUnit(), closeTo(Double.parseDouble(DEFAULT_STEP_UNIT), 0.00001)); assertThat(profile.isReportJob(), is(Boolean.parseBoolean(DEFAULT_REPORT_JOB))); assertThat(profile.isDeleteOnSetup(), is(Boolean.parseBoolean(DEFAULT_DELETE_ON_SETUP))); assertThat(profile.isDeleteOnCleanup(), is(Boolean.parseBoolean(DEFAULT_DELETE_ON_CLEANUP))); }
@Test(expected = IllegalArgumentException.class) public void convert_empty() { Map<String, String> conf = map(); Map<String, String> vars = map(); ServiceProfile<FlowLoggerProvider> sp = profile(conf, vars); FlowLoggerProfile.convert(sp); }