### Question:
DnFieldHelper { public List<DnFieldValue> processDnParameters(CertificateProfileInfo profile, Map<String, String> dnParameters) throws InvalidDnParameterException { Set<String> unprocessedParameters = new HashSet<>(dnParameters.keySet()); List<DnFieldValue> dnValues = new ArrayList<>(); for (DnFieldDescription description: profile.getSubjectFields()) { String fieldValue = null; boolean parameterIsMissing = StringUtils.isBlank(dnParameters.get(description.getId())); if (description.isRequired() && (!description.isReadOnly()) && parameterIsMissing) { throw new InvalidDnParameterException("missing parameter: " + description.getId()); } if (description.isReadOnly() || parameterIsMissing) { fieldValue = description.getDefaultValue(); } else { fieldValue = dnParameters.get(description.getId()); } dnValues.add(new DnFieldValueImpl(description.getId(), fieldValue)); unprocessedParameters.remove(description.getId()); } if (!unprocessedParameters.isEmpty()) { throw new InvalidDnParameterException("extraneous parameters: " + unprocessedParameters); } for (DnFieldValue dnValue: dnValues) { try { profile.validateSubjectField(dnValue); } catch (Exception e) { throw new InvalidDnParameterException(e); } } return dnValues; }  String createSubjectName(List<DnFieldValue> dnFieldValues); List<DnFieldValue> processDnParameters(CertificateProfileInfo profile, Map<String, String> dnParameters);  }### Answer:
@Test public void processDnParameters() throws Exception { DnFieldDescription field1ReadOnly = new DnFieldDescriptionImpl(FIELD_1, "x", FIELD_1_DEFAULT) .setReadOnly(true); DnFieldDescription field2Editable = new DnFieldDescriptionImpl(FIELD_2, "x", FIELD_2_DEFAULT) .setReadOnly(false); List<DnFieldValue> values = helper.processDnParameters( new DnFieldTestCertificateProfileInfo(field1ReadOnly, true), new HashMap<>()); assertTrue(values.size() == 1); assertEquals(new DnFieldValueImpl(FIELD_1, FIELD_1_DEFAULT), values.iterator().next()); values = helper.processDnParameters( new DnFieldTestCertificateProfileInfo(field1ReadOnly, true), ImmutableMap.of(FIELD_1, "bar")); assertTrue(values.size() == 1); assertEquals(new DnFieldValueImpl(FIELD_1, FIELD_1_DEFAULT), values.iterator().next()); try { helper.processDnParameters(new DnFieldTestCertificateProfileInfo(field1ReadOnly, true), ImmutableMap.of("foo", "bar")); fail("should throw exception"); } catch (DnFieldHelper.InvalidDnParameterException expected) { } try { helper.processDnParameters( new DnFieldTestCertificateProfileInfo(field2Editable, true), new HashMap<>()); fail("should throw exception"); } catch (DnFieldHelper.InvalidDnParameterException expected) { } values = helper.processDnParameters( new DnFieldTestCertificateProfileInfo(field2Editable, true), ImmutableMap.of(FIELD_2, "bar")); assertTrue(values.size() == 1); assertEquals(new DnFieldValueImpl(FIELD_2, "bar"), values.iterator().next()); try { helper.processDnParameters(new DnFieldTestCertificateProfileInfo(field2Editable, true), ImmutableMap.of("foo", "bar")); fail("should throw exception"); } catch (DnFieldHelper.InvalidDnParameterException expected) { } try { helper.processDnParameters(new DnFieldTestCertificateProfileInfo(field2Editable, true), ImmutableMap.of(FIELD_2, "bar", "foo", "bar2")); fail("should throw exception"); } catch (DnFieldHelper.InvalidDnParameterException expected) { } try { values = helper.processDnParameters( new DnFieldTestCertificateProfileInfo(field2Editable, false), ImmutableMap.of(FIELD_2, "bar")); fail("should throw exception"); } catch (DnFieldHelper.InvalidDnParameterException expected) { } }