use of org.candlepin.model.PermissionBlueprint in project candlepin by candlepin.
the class ConsumerResourceCreationTest method init.
@Before
public void init() throws Exception {
this.i18n = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.FALLBACK);
this.modelTranslator = new StandardTranslator(this.consumerTypeCurator, this.environmentCurator, this.ownerCurator);
testMigration = new GuestMigration(consumerCurator);
migrationProvider = Providers.of(testMigration);
this.config = initConfig();
this.resource = new ConsumerResource(this.consumerCurator, this.consumerTypeCurator, null, this.subscriptionService, this.ownerService, null, this.idCertService, null, this.i18n, this.sink, null, null, null, this.userService, null, null, this.ownerCurator, this.activationKeyCurator, null, this.complianceRules, this.deletedConsumerCurator, null, null, this.config, null, null, null, this.consumerBindUtil, null, null, new FactValidator(this.config, this.i18n), null, consumerEnricher, migrationProvider, modelTranslator);
this.system = this.initConsumerType();
this.mockConsumerType(this.system);
this.systemDto = this.modelTranslator.translate(this.system, ConsumerTypeDTO.class);
owner = new Owner("test_owner");
owner.setId(TestUtil.randomString());
user = new User(USER, "");
PermissionBlueprint p = new PermissionBlueprint(PermissionType.OWNER, owner, Access.ALL);
role = new Role();
role.addPermission(p);
role.addUser(user);
when(consumerCurator.create(any(Consumer.class))).thenAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return invocation.getArguments()[0];
}
});
when(consumerCurator.create(any(Consumer.class), any(Boolean.class))).thenAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return invocation.getArguments()[0];
}
});
when(userService.findByLogin(USER)).thenReturn(user);
IdentityCertificate cert = new IdentityCertificate();
cert.setKey("testKey");
cert.setCert("testCert");
cert.setId("testId");
cert.setSerial(new CertificateSerial(new Date()));
when(idCertService.generateIdentityCert(any(Consumer.class))).thenReturn(cert);
when(ownerCurator.lookupByKey(owner.getKey())).thenReturn(owner);
when(complianceRules.getStatus(any(Consumer.class), any(Date.class), any(Boolean.class), any(Boolean.class))).thenReturn(new ComplianceStatus(new Date()));
}
Aggregations