Search in sources :

Example 11 with Parameters

use of org.alfresco.rest.framework.resource.parameters.Parameters in project alfresco-remote-api by Alfresco.

the class QuickShareLinksImpl method getParamsWithCreatedStatus.

private Parameters getParamsWithCreatedStatus() {
    String filterStatusCreated = "(" + Renditions.PARAM_STATUS + "='" + Rendition.RenditionStatus.CREATED + "')";
    Query whereQuery = getWhereClause(filterStatusCreated);
    Params.RecognizedParams recParams = new Params.RecognizedParams(null, null, null, null, null, null, whereQuery, null, false);
    Parameters params = Params.valueOf(recParams, null, null, null);
    return params;
}
Also used : Parameters(org.alfresco.rest.framework.resource.parameters.Parameters) SearchParameters(org.alfresco.service.cmr.search.SearchParameters) Query(org.alfresco.rest.framework.resource.parameters.where.Query) Params(org.alfresco.rest.framework.resource.parameters.Params)

Example 12 with Parameters

use of org.alfresco.rest.framework.resource.parameters.Parameters in project alfresco-remote-api by Alfresco.

the class ProcessesImplTest method queryMatchesProcesses.

private CollectionWithPagingInfo<ProcessInfo> queryMatchesProcesses(String matchesString) {
    Query query = getWhereClause(String.format(QUERY_WORKFLOWDESCRIPTION_MATCHES, matchesString));
    Parameters parameters = Params.valueOf(new RecognizedParams(null, Paging.valueOf(0, ACTIVE_WORKFLOWS_INITIAL_AMOUNT), null, null, null, null, query, null, false), null, null, null);
    return processes.getProcesses(parameters);
}
Also used : Parameters(org.alfresco.rest.framework.resource.parameters.Parameters) RecognizedParams(org.alfresco.rest.framework.resource.parameters.Params.RecognizedParams) Query(org.alfresco.rest.framework.resource.parameters.where.Query)

Example 13 with Parameters

use of org.alfresco.rest.framework.resource.parameters.Parameters in project records-management by Alfresco.

the class RMSitesImplUnitTest method createRMStandardSite.

@Test
public void createRMStandardSite() throws Exception {
    RMSite toCreate = new RMSite();
    toCreate.setTitle(RM_SITE_TITLE);
    toCreate.setDescription(RM_SITE_DESCRIPTION);
    // mocked SiteInfo
    SiteInfo mockedSiteInfo = mock(SiteInfo.class);
    NodeRef siteNodeRef = AlfMock.generateNodeRef(mockedNodeService);
    when(mockedSiteInfo.getShortName()).thenReturn(RM_SITE_ID);
    when(mockedSiteInfo.getNodeRef()).thenReturn(siteNodeRef);
    when(mockedSiteInfo.getDescription()).thenReturn(RM_SITE_DESCRIPTION);
    when(mockedSiteInfo.getTitle()).thenReturn(RM_SITE_TITLE);
    when(mockedSiteInfo.getVisibility()).thenReturn(SiteVisibility.PUBLIC);
    when(mockedSiteService.createSite(any(String.class), any(String.class), any(String.class), any(String.class), any(SiteVisibility.class), any(QName.class))).thenReturn(mockedSiteInfo);
    // mock Parameters
    Parameters mockedParameters = mock(Parameters.class);
    // call createRMSite method
    RMSite createdRMSite = rmSitesImpl.createRMSite(toCreate, mockedParameters);
    // check siteService.createSite parameters
    ArgumentCaptor<String> sitePresetCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> idCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> titleCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> descriptionCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<SiteVisibility> visibilityCaptor = ArgumentCaptor.forClass(SiteVisibility.class);
    ArgumentCaptor<QName> siteTypeCaptor = ArgumentCaptor.forClass(QName.class);
    verify(mockedSiteService, times(1)).createSite(sitePresetCaptor.capture(), idCaptor.capture(), titleCaptor.capture(), descriptionCaptor.capture(), visibilityCaptor.capture(), siteTypeCaptor.capture());
    assertEquals(RM_SITE_PRESET, sitePresetCaptor.getValue());
    assertEquals(RM_SITE_ID, idCaptor.getValue());
    assertEquals(RM_SITE_TITLE, titleCaptor.getValue());
    assertEquals(RM_SITE_DESCRIPTION, descriptionCaptor.getValue());
    assertEquals(SiteVisibility.PUBLIC, visibilityCaptor.getValue());
    assertEquals(RecordsManagementModel.TYPE_RM_SITE, siteTypeCaptor.getValue());
    verify(mockedImporterService, times(1)).importView(any(SiteImportPackageHandler.class), any(Location.class), any(ImporterBinding.class), eq(null));
    verify(mockedSiteService, times(1)).createContainer(RM_SITE_ID, SiteService.DOCUMENT_LIBRARY, ContentModel.TYPE_FOLDER, null);
    verify(mockedFavouritesService, times(1)).addFavourite(any(String.class), any(NodeRef.class));
    // verify returned values for RM site are the right ones
    assertEquals(RMSiteCompliance.STANDARD, createdRMSite.getCompliance());
    assertEquals(null, createdRMSite.getRole());
    assertEquals(RM_SITE_ID, createdRMSite.getId());
    assertEquals(siteNodeRef.getId(), createdRMSite.getGuid());
    assertEquals(RM_SITE_DESCRIPTION, createdRMSite.getDescription());
    assertEquals(RM_SITE_TITLE, createdRMSite.getTitle());
    assertEquals(SiteVisibility.PUBLIC, createdRMSite.getVisibility());
}
Also used : SiteInfo(org.alfresco.service.cmr.site.SiteInfo) Parameters(org.alfresco.rest.framework.resource.parameters.Parameters) QName(org.alfresco.service.namespace.QName) ImporterBinding(org.alfresco.service.cmr.view.ImporterBinding) NodeRef(org.alfresco.service.cmr.repository.NodeRef) RMSite(org.alfresco.rm.rest.api.model.RMSite) SiteImportPackageHandler(org.alfresco.rest.api.impl.SiteImportPackageHandler) SiteVisibility(org.alfresco.service.cmr.site.SiteVisibility) Location(org.alfresco.service.cmr.view.Location) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest) Test(org.junit.Test)

Example 14 with Parameters

use of org.alfresco.rest.framework.resource.parameters.Parameters in project records-management by Alfresco.

the class RMSitesImplUnitTest method updateRMSite.

@Test
public void updateRMSite() throws Exception {
    String siteId = RM_SITE_ID;
    SiteInfo mockedSiteInfo = mock(SiteInfo.class);
    NodeRef siteNodeRef = AlfMock.generateNodeRef(mockedNodeService);
    // mock SiteInfo
    when(mockedSiteInfo.getShortName()).thenReturn(siteId);
    when(mockedSiteInfo.getNodeRef()).thenReturn(siteNodeRef);
    when(mockedSiteInfo.getDescription()).thenReturn(RM_SITE_DESCRIPTION).thenReturn(RM_SITE_DESCRIPTION_AFTER_UPDATE);
    when(mockedSiteInfo.getTitle()).thenReturn(RM_SITE_TITLE).thenReturn(RM_SITE_TITLE_AFTER_UPDATE);
    when(mockedSiteInfo.getVisibility()).thenReturn(SiteVisibility.PUBLIC);
    when(mockedNodeService.getType(siteNodeRef)).thenReturn(RecordsManagementModel.TYPE_RM_SITE);
    when(mockedSiteService.getSite(siteId)).thenReturn(mockedSiteInfo);
    when(mockedSiteService.getMembersRole(eq(siteId), any(String.class))).thenReturn(RM_SITE_MANAGER_ROLE);
    // mock UpdateSite
    SiteUpdate mockedSiteUpdate = mock(SiteUpdate.class);
    when(mockedSiteUpdate.getDescription()).thenReturn(RM_SITE_DESCRIPTION_AFTER_UPDATE);
    when(mockedSiteUpdate.getTitle()).thenReturn(RM_SITE_TITLE_AFTER_UPDATE);
    when(mockedSiteUpdate.getVisibility()).thenReturn(null);
    when(mockedSiteUpdate.wasSet(Site.TITLE)).thenReturn(true);
    when(mockedSiteUpdate.wasSet(Site.DESCRIPTION)).thenReturn(true);
    // mock Parameters
    Parameters mockedParameters = mock(Parameters.class);
    // call updateRMSite method
    RMSite updatedRMSite = rmSitesImpl.updateRMSite(siteId, mockedSiteUpdate, mockedParameters);
    // check if the new title is set to siteInfo
    ArgumentCaptor<String> titleCaptor = ArgumentCaptor.forClass(String.class);
    verify(mockedSiteInfo, times(1)).setTitle(titleCaptor.capture());
    assertEquals(RM_SITE_TITLE_AFTER_UPDATE, titleCaptor.getValue());
    // check that new description is set to siteInfo
    ArgumentCaptor<String> descriptionCaptor = ArgumentCaptor.forClass(String.class);
    verify(mockedSiteInfo, times(1)).setDescription(descriptionCaptor.capture());
    assertEquals(RM_SITE_DESCRIPTION_AFTER_UPDATE, descriptionCaptor.getValue());
    // check that site visibility is not changed
    verify(mockedSiteInfo, never()).setVisibility(any(SiteVisibility.class));
    // check that updateSite is called
    verify(mockedSiteService, times(1)).updateSite(any(SiteInfo.class));
    // verify returned values for RM site are the right ones
    assertEquals(RMSiteCompliance.STANDARD, updatedRMSite.getCompliance());
    assertEquals(RM_SITE_MANAGER_ROLE, updatedRMSite.getRole());
    assertEquals(siteId, updatedRMSite.getId());
    assertEquals(siteNodeRef.getId(), updatedRMSite.getGuid());
    assertEquals(RM_SITE_DESCRIPTION_AFTER_UPDATE, updatedRMSite.getDescription());
    assertEquals(RM_SITE_TITLE_AFTER_UPDATE, updatedRMSite.getTitle());
    assertEquals(SiteVisibility.PUBLIC, updatedRMSite.getVisibility());
}
Also used : SiteInfo(org.alfresco.service.cmr.site.SiteInfo) NodeRef(org.alfresco.service.cmr.repository.NodeRef) Parameters(org.alfresco.rest.framework.resource.parameters.Parameters) RMSite(org.alfresco.rm.rest.api.model.RMSite) SiteUpdate(org.alfresco.rest.api.model.SiteUpdate) SiteVisibility(org.alfresco.service.cmr.site.SiteVisibility) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest) Test(org.junit.Test)

Example 15 with Parameters

use of org.alfresco.rest.framework.resource.parameters.Parameters in project records-management by Alfresco.

the class RMSitesImplUnitTest method createRMDOD5015Site.

@Test
public void createRMDOD5015Site() throws Exception {
    RMSite toCreate = new RMSite();
    toCreate.setTitle(RM_SITE_TITLE);
    toCreate.setDescription(RM_SITE_DESCRIPTION);
    toCreate.setCompliance(RMSiteCompliance.DOD5015);
    // mocked SiteInfo
    SiteInfo mockedSiteInfo = mock(SiteInfo.class);
    NodeRef siteNodeRef = AlfMock.generateNodeRef(mockedNodeService);
    when(mockedSiteInfo.getShortName()).thenReturn(RM_SITE_ID);
    when(mockedSiteInfo.getNodeRef()).thenReturn(siteNodeRef);
    when(mockedSiteInfo.getDescription()).thenReturn(RM_SITE_DESCRIPTION);
    when(mockedSiteInfo.getTitle()).thenReturn(RM_SITE_TITLE);
    when(mockedSiteInfo.getVisibility()).thenReturn(SiteVisibility.PUBLIC);
    when(mockedSiteService.createSite(any(String.class), any(String.class), any(String.class), any(String.class), any(SiteVisibility.class), any(QName.class))).thenReturn(mockedSiteInfo);
    // mock Parameters
    Parameters mockedParameters = mock(Parameters.class);
    // call createRMSite method
    RMSite createdRMSite = rmSitesImpl.createRMSite(toCreate, mockedParameters);
    // check siteService.createSite parameters
    ArgumentCaptor<String> sitePresetCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> idCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> titleCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> descriptionCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<SiteVisibility> visibilityCaptor = ArgumentCaptor.forClass(SiteVisibility.class);
    ArgumentCaptor<QName> siteTypeCaptor = ArgumentCaptor.forClass(QName.class);
    verify(mockedSiteService, times(1)).createSite(sitePresetCaptor.capture(), idCaptor.capture(), titleCaptor.capture(), descriptionCaptor.capture(), visibilityCaptor.capture(), siteTypeCaptor.capture());
    assertEquals(RM_SITE_PRESET, sitePresetCaptor.getValue());
    assertEquals(RM_SITE_ID, idCaptor.getValue());
    assertEquals(RM_SITE_TITLE, titleCaptor.getValue());
    assertEquals(RM_SITE_DESCRIPTION, descriptionCaptor.getValue());
    assertEquals(SiteVisibility.PUBLIC, visibilityCaptor.getValue());
    assertEquals(DOD5015Model.TYPE_DOD_5015_SITE, siteTypeCaptor.getValue());
    verify(mockedImporterService, times(1)).importView(any(SiteImportPackageHandler.class), any(Location.class), any(ImporterBinding.class), eq(null));
    verify(mockedSiteService, times(1)).createContainer(RM_SITE_ID, SiteService.DOCUMENT_LIBRARY, ContentModel.TYPE_FOLDER, null);
    verify(mockedFavouritesService, times(1)).addFavourite(any(String.class), any(NodeRef.class));
    // verify returned values for RM site are the right ones
    assertEquals(RMSiteCompliance.DOD5015, createdRMSite.getCompliance());
    assertEquals(null, createdRMSite.getRole());
    assertEquals(RM_SITE_ID, createdRMSite.getId());
    assertEquals(siteNodeRef.getId(), createdRMSite.getGuid());
    assertEquals(RM_SITE_DESCRIPTION, createdRMSite.getDescription());
    assertEquals(RM_SITE_TITLE, createdRMSite.getTitle());
    assertEquals(SiteVisibility.PUBLIC, createdRMSite.getVisibility());
}
Also used : SiteInfo(org.alfresco.service.cmr.site.SiteInfo) Parameters(org.alfresco.rest.framework.resource.parameters.Parameters) QName(org.alfresco.service.namespace.QName) ImporterBinding(org.alfresco.service.cmr.view.ImporterBinding) NodeRef(org.alfresco.service.cmr.repository.NodeRef) RMSite(org.alfresco.rm.rest.api.model.RMSite) SiteImportPackageHandler(org.alfresco.rest.api.impl.SiteImportPackageHandler) SiteVisibility(org.alfresco.service.cmr.site.SiteVisibility) Location(org.alfresco.service.cmr.view.Location) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest) Test(org.junit.Test)

Aggregations

Parameters (org.alfresco.rest.framework.resource.parameters.Parameters)18 BaseUnitTest (org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest)11 RMSite (org.alfresco.rm.rest.api.model.RMSite)11 Test (org.junit.Test)11 Params (org.alfresco.rest.framework.resource.parameters.Params)9 SiteUpdate (org.alfresco.rest.api.model.SiteUpdate)8 InvalidArgumentException (org.alfresco.rest.framework.core.exceptions.InvalidArgumentException)6 NodeRef (org.alfresco.service.cmr.repository.NodeRef)6 Query (org.alfresco.rest.framework.resource.parameters.where.Query)4 SiteInfo (org.alfresco.service.cmr.site.SiteInfo)4 SiteVisibility (org.alfresco.service.cmr.site.SiteVisibility)4 SiteImportPackageHandler (org.alfresco.rest.api.impl.SiteImportPackageHandler)3 EntityNotFoundException (org.alfresco.rest.framework.core.exceptions.EntityNotFoundException)3 SearchParameters (org.alfresco.service.cmr.search.SearchParameters)3 ImporterBinding (org.alfresco.service.cmr.view.ImporterBinding)3 Location (org.alfresco.service.cmr.view.Location)3 QName (org.alfresco.service.namespace.QName)3 InvalidParameterException (java.security.InvalidParameterException)1 Collator (java.text.Collator)1 AbstractList (java.util.AbstractList)1