use of org.apache.syncope.core.persistence.api.entity.resource.ExternalResource in project syncope by apache.
the class ResourceTest method findAll.
@Test
public void findAll() {
List<GrantedAuthority> authorities = StandardEntitlement.values().stream().map(entitlement -> new SyncopeGrantedAuthority(entitlement, SyncopeConstants.ROOT_REALM)).collect(Collectors.toList());
UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken(new org.springframework.security.core.userdetails.User("admin", "FAKE_PASSWORD", authorities), "FAKE_PASSWORD", authorities);
auth.setDetails(new SyncopeAuthenticationDetails("Master"));
SecurityContextHolder.getContext().setAuthentication(auth);
try {
List<ExternalResource> resources = resourceDAO.findAll();
assertNotNull(resources);
assertFalse(resources.isEmpty());
} finally {
SecurityContextHolder.getContext().setAuthentication(null);
}
}
use of org.apache.syncope.core.persistence.api.entity.resource.ExternalResource in project syncope by apache.
the class TaskTest method delete.
@Test
public void delete() {
PropagationTask task = taskDAO.find("1e697572-b896-484c-ae7f-0c8f63fcbc6c");
assertNotNull(task);
ExternalResource resource = task.getResource();
assertNotNull(resource);
taskDAO.delete(task);
task = taskDAO.find("1e697572-b896-484c-ae7f-0c8f63fcbc6c");
assertNull(task);
resource = resourceDAO.find(resource.getKey());
assertNotNull(resource);
assertFalse(taskDAO.findAll(TaskType.PROPAGATION, resource, null, null, null, -1, -1, Collections.<OrderByClause>emptyList()).contains(task));
}
use of org.apache.syncope.core.persistence.api.entity.resource.ExternalResource in project syncope by apache.
the class VirSchemaTest method save.
@Test
public void save() {
ExternalResource csv = resourceDAO.find("resource-csv");
Provision provision = csv.getProvision(ObjectClass.ACCOUNT).get();
assertNotNull(provision);
VirSchema virSchema = entityFactory.newEntity(VirSchema.class);
virSchema.setKey("virtual");
virSchema.setProvision(provision);
virSchema.setReadonly(true);
virSchema.setExtAttrName("EXT_ATTR");
virSchemaDAO.save(virSchema);
VirSchema actual = virSchemaDAO.find("virtual");
assertNotNull(actual);
assertTrue(actual.isReadonly());
assertEquals("EXT_ATTR", actual.getExtAttrName());
}
use of org.apache.syncope.core.persistence.api.entity.resource.ExternalResource in project syncope by apache.
the class ResourceHistoryConfTest method createDelete.
@Test
public void createDelete() {
ExternalResource ldapResource = resourceDAO.find("resource-ldap");
assertNotNull(ldapResource);
ExternalResourceHistoryConf ldapHistory = entityFactory.newEntity(ExternalResourceHistoryConf.class);
ldapHistory.setCreation(new Date());
ldapHistory.setCreator("me");
ldapHistory.setEntity(ldapResource);
ldapHistory.setConf(new ResourceTO());
ldapHistory = resourceHistoryConfDAO.save(ldapHistory);
assertNotNull(ldapHistory.getKey());
resourceHistoryConfDAO.flush();
List<ExternalResourceHistoryConf> history = resourceHistoryConfDAO.findByEntity(ldapResource);
assertEquals(1, history.size());
assertEquals(ldapHistory, history.get(0));
resourceHistoryConfDAO.delete(ldapHistory.getKey());
resourceHistoryConfDAO.flush();
assertNull(resourceHistoryConfDAO.find(ldapHistory.getKey()));
assertTrue(resourceHistoryConfDAO.findByEntity(ldapResource).isEmpty());
}
use of org.apache.syncope.core.persistence.api.entity.resource.ExternalResource in project syncope by apache.
the class TaskTest method issueSYNCOPE144.
@Test
public void issueSYNCOPE144() {
ExternalResource resource = resourceDAO.find("ws-target-resource-1");
assertNotNull(resource);
Implementation pullActions = entityFactory.newEntity(Implementation.class);
pullActions.setKey("syncope144");
pullActions.setEngine(ImplementationEngine.JAVA);
pullActions.setType(ImplementationType.PULL_ACTIONS);
pullActions.setBody(PullActions.class.getName());
pullActions = implementationDAO.save(pullActions);
PullTask task = entityFactory.newEntity(PullTask.class);
task.setResource(resource);
task.setName("issueSYNCOPE144");
task.setDescription("issueSYNCOPE144 Description");
task.setActive(true);
task.setPullMode(PullMode.FULL_RECONCILIATION);
task.add(pullActions);
task.setMatchingRule(MatchingRule.UPDATE);
task.setUnmatchingRule(UnmatchingRule.PROVISION);
task = taskDAO.save(task);
assertNotNull(task);
PullTask actual = taskDAO.find(task.getKey());
assertEquals(task, actual);
assertEquals("issueSYNCOPE144", actual.getName());
assertEquals("issueSYNCOPE144 Description", actual.getDescription());
actual.setName("issueSYNCOPE144_2");
actual.setDescription("issueSYNCOPE144 Description_2");
actual = taskDAO.save(actual);
assertNotNull(actual);
assertEquals("issueSYNCOPE144_2", actual.getName());
assertEquals("issueSYNCOPE144 Description_2", actual.getDescription());
}
Aggregations