Search in sources :

Example 1 with ReferenceMetadata

use of io.gravitee.rest.api.portal.rest.model.ReferenceMetadata in project gravitee-management-rest-api by gravitee-io.

the class ReferenceMetadataMapper method convert.

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;
}
Also used : ReferenceMetadata(io.gravitee.rest.api.portal.rest.model.ReferenceMetadata)

Example 2 with ReferenceMetadata

use of io.gravitee.rest.api.portal.rest.model.ReferenceMetadata in project gravitee-management-rest-api by gravitee-io.

the class ReferenceMetadataMapperTest method testConvertEntityToPojo.

@Test
public void testConvertEntityToPojo() {
    // init
    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);
    // Test
    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());
}
Also used : NewApplicationMetadataEntity(io.gravitee.rest.api.model.NewApplicationMetadataEntity) UpdateApplicationMetadataEntity(io.gravitee.rest.api.model.UpdateApplicationMetadataEntity) ApplicationMetadataEntity(io.gravitee.rest.api.model.ApplicationMetadataEntity) ReferenceMetadata(io.gravitee.rest.api.portal.rest.model.ReferenceMetadata) Test(org.junit.Test)

Aggregations

ReferenceMetadata (io.gravitee.rest.api.portal.rest.model.ReferenceMetadata)2 ApplicationMetadataEntity (io.gravitee.rest.api.model.ApplicationMetadataEntity)1 NewApplicationMetadataEntity (io.gravitee.rest.api.model.NewApplicationMetadataEntity)1 UpdateApplicationMetadataEntity (io.gravitee.rest.api.model.UpdateApplicationMetadataEntity)1 Test (org.junit.Test)1