@Test public void getFieldValueModelTest() { String descriptor = "description1"; String context = "context1"; String keyValid = "Key1"; String keyBad = "This key is not in the Field Model"; FieldValueModel testFieldValueModel = Mockito.mock(FieldValueModel.class); Map<String, FieldValueModel> keyToValues = new HashMap<>(); keyToValues.put(keyValid, testFieldValueModel); FieldModel testFieldModel = new FieldModel(descriptor, context, keyToValues); Optional<FieldValueModel> verifyFieldValueModel = testFieldModel.getFieldValueModel(keyValid); assertTrue(verifyFieldValueModel.isPresent()); assertEquals(testFieldValueModel, verifyFieldValueModel.get()); verifyFieldValueModel = testFieldModel.getFieldValueModel(keyBad); assertFalse(verifyFieldValueModel.isPresent()); }
public Optional<FieldValueModel> getFieldValueModel(final String key) { return Optional.ofNullable(keyToValues.get(key)); }
FieldModel extends Config { public Optional<FieldValueModel> getFieldValueModel(final String key) { return Optional.ofNullable(keyToValues.get(key)); } }
FieldModel extends Config { public Optional<FieldValueModel> getFieldValueModel(final String key) { return Optional.ofNullable(keyToValues.get(key)); } private  FieldModel();  FieldModel(String descriptorName, String context, Map<String, FieldValueModel> keyToValues);  FieldModel(String configId, String descriptorName, String context, Map<String, FieldValueModel> keyToValues);  FieldModel(String descriptorName, String context, String createdAt, String lastUpdated, Map<String, FieldValueModel> keyToValues);  FieldModel(String configId, String descriptorName, String context, String createdAt, String lastUpdated, Map<String, FieldValueModel> keyToValues); }
FieldModel extends Config { public Optional<FieldValueModel> getFieldValueModel(final String key) { return Optional.ofNullable(keyToValues.get(key)); } private  FieldModel();  FieldModel(String descriptorName, String context, Map<String, FieldValueModel> keyToValues);  FieldModel(String configId, String descriptorName, String context, Map<String, FieldValueModel> keyToValues);  FieldModel(String descriptorName, String context, String createdAt, String lastUpdated, Map<String, FieldValueModel> keyToValues);  FieldModel(String configId, String descriptorName, String context, String createdAt, String lastUpdated, Map<String, FieldValueModel> keyToValues); String getDescriptorName(); String getContext(); String getCreatedAt(); String getLastUpdated(); Map<String, FieldValueModel> getKeyToValues(); void setKeyToValues(final Map<String, FieldValueModel> keyToValues); Optional<FieldValueModel> getFieldValueModel(final String key); Optional<String> getFieldValue(final String key); void putField(final String key, final FieldValueModel field); void removeField(final String key); FieldModel fill(final FieldModel fieldModel); }
FieldModel extends Config { public Optional<FieldValueModel> getFieldValueModel(final String key) { return Optional.ofNullable(keyToValues.get(key)); } private  FieldModel();  FieldModel(String descriptorName, String context, Map<String, FieldValueModel> keyToValues);  FieldModel(String configId, String descriptorName, String context, Map<String, FieldValueModel> keyToValues);  FieldModel(String descriptorName, String context, String createdAt, String lastUpdated, Map<String, FieldValueModel> keyToValues);  FieldModel(String configId, String descriptorName, String context, String createdAt, String lastUpdated, Map<String, FieldValueModel> keyToValues); String getDescriptorName(); String getContext(); String getCreatedAt(); String getLastUpdated(); Map<String, FieldValueModel> getKeyToValues(); void setKeyToValues(final Map<String, FieldValueModel> keyToValues); Optional<FieldValueModel> getFieldValueModel(final String key); Optional<String> getFieldValue(final String key); void putField(final String key, final FieldValueModel field); void removeField(final String key); FieldModel fill(final FieldModel fieldModel);  }