use of org.candlepin.dto.api.v1.EnvironmentDTO.EnvironmentContentDTO in project candlepin by candlepin.
the class EnvironmentTranslator method populate.
/**
* {@inheritDoc}
*/
@Override
public EnvironmentDTO populate(ModelTranslator translator, Environment source, EnvironmentDTO dest) {
dest = super.populate(translator, source, dest);
dest.setId(source.getId());
dest.setName(source.getName());
dest.setDescription(source.getDescription());
if (translator != null) {
dest.setOwner(translator.translate(source.getOwner(), OwnerDTO.class));
Set<EnvironmentContent> envContents = source.getEnvironmentContent();
if (envContents != null) {
Collection<EnvironmentContent> envContent = source.getEnvironmentContent();
dest.setEnvironmentContent(Collections.<EnvironmentContentDTO>emptyList());
if (envContent != null) {
ObjectTranslator<Content, ContentDTO> contentTranslator = translator.findTranslatorByClass(Content.class, ContentDTO.class);
for (EnvironmentContent ec : envContent) {
if (ec != null) {
ContentDTO dto = contentTranslator.translate(translator, ec.getContent());
if (dto != null) {
dest.addContent(dto, ec.getEnabled());
}
}
}
}
}
} else {
dest.setOwner(null);
dest.setEnvironmentContent(null);
}
return dest;
}
use of org.candlepin.dto.api.v1.EnvironmentDTO.EnvironmentContentDTO in project candlepin by candlepin.
the class EnvironmentTranslatorTest method verifyOutput.
@Override
protected void verifyOutput(Environment source, EnvironmentDTO dto, boolean childrenGenerated) {
if (source != null) {
assertEquals(source.getId(), dto.getId());
assertEquals(source.getName(), dto.getName());
assertEquals(source.getDescription(), dto.getDescription());
if (childrenGenerated) {
this.ownerTranslatorTest.verifyOutput(source.getOwner(), dto.getOwner(), childrenGenerated);
assertNotNull(dto.getEnvironmentContent());
for (EnvironmentContent ec : source.getEnvironmentContent()) {
for (EnvironmentContentDTO ecdto : dto.getEnvironmentContent()) {
Content content = ec.getContent();
ContentDTO cdto = ecdto.getContent();
assertNotNull(cdto);
assertNotNull(cdto.getUuid());
if (cdto.getUuid().equals(content.getUuid())) {
assertEquals(ec.getEnabled(), ecdto.isEnabled());
// Pass the content off to the ContentTranslatorTest to verify it
this.contentTranslatorTest.verifyOutput(content, cdto, childrenGenerated);
}
}
}
} else {
assertNull(dto.getEnvironmentContent());
assertNull(dto.getOwner());
}
} else {
assertNull(dto);
}
}
Aggregations