ReferenceMetadataMapper { public ReferenceMetadata convert(ApplicationMetadataEntity applicationMetadataEntity) { final ReferenceMetadata applicationReferenceMetadata = new ReferenceMetadata(); applicationReferenceMetadata.setApplication(applicationMetadataEntity.getApplicationId()); applicationReferenceMetadata.setDefaultValue(applicationMetadataEntity.getDefaultValue()); if (applicationMetadataEntity.getFormat() != null) { applicationReferenceMetadata.setFormat(ReferenceMetadataFormatType.valueOf(applicationMetadataEntity.getFormat().name())); } else { applicationReferenceMetadata.setFormat(ReferenceMetadataFormatType.STRING); } applicationReferenceMetadata.setKey(applicationMetadataEntity.getKey()); applicationReferenceMetadata.setName(applicationMetadataEntity.getName()); applicationReferenceMetadata.setValue(applicationMetadataEntity.getValue()); return applicationReferenceMetadata; }  ReferenceMetadata convert(ApplicationMetadataEntity applicationMetadataEntity); NewApplicationMetadataEntity convert(ReferenceMetadataInput applicationReferenceMetadataInput, String applicationId); UpdateApplicationMetadataEntity convert(ReferenceMetadataInput applicationReferenceMetadataInput, String applicationId, String metadataId);  }
@Test public void testConvertEntityToPojo() { ApplicationMetadataEntity applicationMetadataEntity = new ApplicationMetadataEntity(); applicationMetadataEntity.setApplicationId(METADATA_APPLICATION_ID); applicationMetadataEntity.setDefaultValue(METADATA_DEFAULT_VALUE); applicationMetadataEntity.setValue(METADATA_VALUE); applicationMetadataEntity.setFormat(MetadataFormat.valueOf(METADATA_FORMAT)); applicationMetadataEntity.setKey(METADATA_KEY); applicationMetadataEntity.setName(METADATA_NAME); final ReferenceMetadata referenceMetadata = referenceMetadataMapper.convert(applicationMetadataEntity); assertNotNull(referenceMetadata); assertEquals(METADATA_APPLICATION_ID, referenceMetadata.getApplication()); assertEquals(METADATA_DEFAULT_VALUE, referenceMetadata.getDefaultValue()); assertEquals(METADATA_KEY, referenceMetadata.getKey()); assertEquals(METADATA_NAME, referenceMetadata.getName()); assertEquals(METADATA_VALUE, referenceMetadata.getValue()); assertEquals(ReferenceMetadataFormatType.valueOf(METADATA_FORMAT), referenceMetadata.getFormat()); }
@Test public void testConvertInputToNewMetadataEntity() { ReferenceMetadataInput metadataInput = new ReferenceMetadataInput(); metadataInput.setDefaultValue(METADATA_DEFAULT_VALUE); metadataInput.setValue(METADATA_VALUE); metadataInput.setFormat(ReferenceMetadataFormatType.valueOf(METADATA_FORMAT)); metadataInput.setName(METADATA_NAME); final NewApplicationMetadataEntity newApplicationMetadataEntity = referenceMetadataMapper.convert(metadataInput, METADATA_APPLICATION_ID); assertNotNull(newApplicationMetadataEntity); assertEquals(METADATA_APPLICATION_ID, newApplicationMetadataEntity.getApplicationId()); assertEquals(METADATA_DEFAULT_VALUE, newApplicationMetadataEntity.getDefaultValue()); assertEquals(METADATA_NAME, newApplicationMetadataEntity.getName()); assertEquals(METADATA_VALUE, newApplicationMetadataEntity.getValue()); assertEquals(MetadataFormat.valueOf(METADATA_FORMAT), newApplicationMetadataEntity.getFormat()); }
@Test public void testConvertInputToUpdateMetadataEntity() { ReferenceMetadataInput metadataInput = new ReferenceMetadataInput(); metadataInput.setDefaultValue(METADATA_DEFAULT_VALUE); metadataInput.setValue(METADATA_VALUE); metadataInput.setFormat(ReferenceMetadataFormatType.valueOf(METADATA_FORMAT)); metadataInput.setName(METADATA_NAME); final UpdateApplicationMetadataEntity updateApplicationMetadataEntity = referenceMetadataMapper.convert(metadataInput, METADATA_APPLICATION_ID, METADATA_KEY); assertNotNull(updateApplicationMetadataEntity); assertEquals(METADATA_APPLICATION_ID, updateApplicationMetadataEntity.getApplicationId()); assertEquals(METADATA_DEFAULT_VALUE, updateApplicationMetadataEntity.getDefaultValue()); assertEquals(METADATA_NAME, updateApplicationMetadataEntity.getName()); assertEquals(METADATA_KEY, updateApplicationMetadataEntity.getKey()); assertEquals(METADATA_VALUE, updateApplicationMetadataEntity.getValue()); assertEquals(MetadataFormat.valueOf(METADATA_FORMAT), updateApplicationMetadataEntity.getFormat()); }