use of org.apereo.cas.mgmt.services.web.factory.AttributeFormDataPopulator in project cas by apereo.
the class RegisteredServiceSimpleFormControllerTests method verifyEditMockRegisteredService.
@Test
public void verifyEditMockRegisteredService() throws Exception {
this.registeredServiceFactory = new DefaultRegisteredServiceFactory(new DefaultAccessStrategyMapper(), policyMapper, new DefaultProxyPolicyMapper(), new MockRegisteredServiceMapper(), new DefaultUsernameAttributeProviderMapper(), Collections.singletonList(new AttributeFormDataPopulator(this.repository)));
this.controller = new RegisteredServiceSimpleFormController(this.manager, this.registeredServiceFactory);
final MockRegisteredService r = new MockRegisteredService();
r.setId(1000);
r.setName("Test Service");
r.setServiceId(TEST_ID);
r.setDescription(DESCRIPTION);
this.manager.save(r);
r.setServiceId("serviceId1");
final RegisteredServiceEditBean.ServiceData data = registeredServiceFactory.createServiceData(r);
this.controller.saveService(new MockHttpServletRequest(), new MockHttpServletResponse(), data, mock(BindingResult.class));
assertFalse(this.manager.getAllServices().isEmpty());
final RegisteredService r2 = this.manager.findServiceBy(1000);
assertEquals("serviceId1", r2.getServiceId());
assertTrue(r2 instanceof MockRegisteredService);
}
use of org.apereo.cas.mgmt.services.web.factory.AttributeFormDataPopulator in project cas by apereo.
the class RegisteredServiceSimpleFormControllerTests method verifyAddMockRegisteredService.
@Test
public void verifyAddMockRegisteredService() throws Exception {
this.registeredServiceFactory = new DefaultRegisteredServiceFactory(new DefaultAccessStrategyMapper(), policyMapper, new DefaultProxyPolicyMapper(), new MockRegisteredServiceMapper(), new DefaultUsernameAttributeProviderMapper(), Collections.singletonList(new AttributeFormDataPopulator(this.repository)));
this.controller = new RegisteredServiceSimpleFormController(this.manager, this.registeredServiceFactory);
final MockRegisteredService svc = new MockRegisteredService();
svc.setDescription(DESCRIPTION);
svc.setServiceId("^serviceId");
svc.setName(NAME);
svc.setId(1000);
svc.setEvaluationOrder(1000);
final RegisteredServiceEditBean.ServiceData data = registeredServiceFactory.createServiceData(svc);
this.controller.saveService(new MockHttpServletRequest(), new MockHttpServletResponse(), data, mock(BindingResult.class));
final Collection<RegisteredService> services = this.manager.getAllServices();
assertEquals(1, services.size());
this.manager.getAllServices().forEach(rs -> assertTrue(rs instanceof MockRegisteredService));
}
use of org.apereo.cas.mgmt.services.web.factory.AttributeFormDataPopulator in project cas by apereo.
the class RegisteredServiceSimpleFormControllerTests method setUp.
@Before
public void setUp() throws Exception {
final Map<String, List<Object>> attributes = new HashMap<>();
attributes.put(TEST_ID, Arrays.asList(new Object[] { TEST_ID }));
this.repository = new StubPersonAttributeDao();
this.repository.setBackingMap(attributes);
this.registeredServiceFactory = new DefaultRegisteredServiceFactory(new DefaultAccessStrategyMapper(), policyMapper, new DefaultProxyPolicyMapper(), new DefaultRegisteredServiceMapper(), new DefaultUsernameAttributeProviderMapper(), Collections.singletonList(new AttributeFormDataPopulator(this.repository)));
this.manager = new DefaultServicesManager(new InMemoryServiceRegistry());
this.controller = new RegisteredServiceSimpleFormController(this.manager, this.registeredServiceFactory);
}
Aggregations