Search in sources :

Example 11 with UpstreamConsumer

use of org.candlepin.model.UpstreamConsumer in project candlepin by candlepin.

the class ConsumerImporterTest method importConsumerWithSameUuidOnAnotherOwnerShouldThrowException.

@Test(expected = SyncDataFormatException.class)
public void importConsumerWithSameUuidOnAnotherOwnerShouldThrowException() throws ImporterException {
    Owner owner = new Owner();
    UpstreamConsumer uc = new UpstreamConsumer("test-uuid");
    owner.setUpstreamConsumer(uc);
    ConsumerDTO consumer = new ConsumerDTO();
    consumer.setUuid("test-uuid");
    Owner anotherOwner = new Owner("other", "Other");
    anotherOwner.setId("blah");
    anotherOwner.setUpstreamConsumer(uc);
    when(curator.lookupWithUpstreamUuid(consumer.getUuid())).thenReturn(anotherOwner);
    importer.store(owner, consumer, new ConflictOverrides(), null);
}
Also used : Owner(org.candlepin.model.Owner) ConsumerDTO(org.candlepin.dto.manifest.v1.ConsumerDTO) UpstreamConsumer(org.candlepin.model.UpstreamConsumer) Test(org.junit.Test)

Example 12 with UpstreamConsumer

use of org.candlepin.model.UpstreamConsumer in project candlepin by candlepin.

the class UpstreamConsumerTranslatorTest method initSourceObject.

@Override
protected UpstreamConsumer initSourceObject() {
    UpstreamConsumer consumer = new UpstreamConsumer();
    consumer.setId("consumer_id");
    consumer.setUuid("consumer_uuid");
    consumer.setName("consumer_name");
    consumer.setApiUrl("http://www.url.com");
    consumer.setWebUrl("http://www.url.com");
    consumer.setOwnerId("owner_id");
    consumer.setType(this.consumerTypeTranslatorTest.initSourceObject());
    consumer.setIdCert((IdentityCertificate) this.certificateTranslatorTest.initSourceObject());
    return consumer;
}
Also used : UpstreamConsumer(org.candlepin.model.UpstreamConsumer)

Example 13 with UpstreamConsumer

use of org.candlepin.model.UpstreamConsumer in project candlepin by candlepin.

the class OwnerTranslator method populate.

/**
 * {@inheritDoc}
 */
@Override
public OwnerDTO populate(ModelTranslator translator, Owner source, OwnerDTO dest) {
    dest = super.populate(translator, source, dest);
    dest.setId(source.getId());
    dest.setKey(source.getKey());
    dest.setDisplayName(source.getDisplayName());
    dest.setContentPrefix(source.getContentPrefix());
    dest.setDefaultServiceLevel(source.getDefaultServiceLevel());
    dest.setLogLevel(source.getLogLevel());
    dest.setAutobindDisabled(source.isAutobindDisabled());
    dest.setContentAccessMode(source.getContentAccessMode());
    dest.setContentAccessModeList(source.getContentAccessModeList());
    dest.setLastRefreshed(source.getLastRefreshed());
    // TODO: Should this actually follow the nested child rules of all the other objects?
    Owner parent = source.getParentOwner();
    dest.setParentOwner(parent != null ? this.translate(translator, parent) : null);
    // Process nested objects if we have a model translator to use to the translation...
    if (translator != null) {
        UpstreamConsumer consumer = source.getUpstreamConsumer();
        dest.setUpstreamConsumer(translator.translate(consumer, UpstreamConsumerDTO.class));
    } else {
        dest.setUpstreamConsumer(null);
    }
    return dest;
}
Also used : Owner(org.candlepin.model.Owner) UpstreamConsumer(org.candlepin.model.UpstreamConsumer)

Example 14 with UpstreamConsumer

use of org.candlepin.model.UpstreamConsumer in project candlepin by candlepin.

the class OwnerTranslator method populate.

/**
 * {@inheritDoc}
 */
@Override
public OwnerDTO populate(ModelTranslator translator, Owner source, OwnerDTO dest) {
    dest = super.populate(translator, source, dest);
    dest.setId(source.getId());
    dest.setKey(source.getKey());
    dest.setDisplayName(source.getDisplayName());
    dest.setContentPrefix(source.getContentPrefix());
    dest.setDefaultServiceLevel(source.getDefaultServiceLevel());
    dest.setLogLevel(source.getLogLevel());
    dest.setAutobindDisabled(source.isAutobindDisabled());
    dest.setContentAccessMode(source.getContentAccessMode());
    dest.setContentAccessModeList(source.getContentAccessModeList());
    dest.setLastRefreshed(source.getLastRefreshed());
    // TODO: Should this actually follow the nested child rules of all the other objects?
    Owner parent = source.getParentOwner();
    dest.setParentOwner(parent != null ? this.translate(translator, parent) : null);
    // Process nested objects if we have a model translator to use to the translation...
    if (translator != null) {
        UpstreamConsumer consumer = source.getUpstreamConsumer();
        dest.setUpstreamConsumer(translator.translate(consumer, UpstreamConsumerDTO.class));
    } else {
        dest.setUpstreamConsumer(null);
    }
    return dest;
}
Also used : Owner(org.candlepin.model.Owner) UpstreamConsumer(org.candlepin.model.UpstreamConsumer)

Aggregations

UpstreamConsumer (org.candlepin.model.UpstreamConsumer)14 Owner (org.candlepin.model.Owner)12 Test (org.junit.Test)7 ConsumerDTO (org.candlepin.dto.manifest.v1.ConsumerDTO)4 Principal (org.candlepin.auth.Principal)3 ConsumerTypeDTO (org.candlepin.dto.manifest.v1.ConsumerTypeDTO)3 OwnerDTO (org.candlepin.dto.manifest.v1.OwnerDTO)3 CertificateSerial (org.candlepin.model.CertificateSerial)3 ConsumerType (org.candlepin.model.ConsumerType)3 Date (java.util.Date)2 UserPrincipal (org.candlepin.auth.UserPrincipal)2 UpstreamConsumerDTO (org.candlepin.dto.api.v1.UpstreamConsumerDTO)2 ExporterMetadata (org.candlepin.model.ExporterMetadata)2 IdentityCertificate (org.candlepin.model.IdentityCertificate)2 ImportRecord (org.candlepin.model.ImportRecord)2 ImportUpstreamConsumer (org.candlepin.model.ImportUpstreamConsumer)2 Pool (org.candlepin.model.Pool)2 Transactional (com.google.inject.persist.Transactional)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1