public void testFailQueryByTenantIdNull() { try { repositoryService.createDeploymentQuery() .tenantIdIn((String) null); fail("expected exception"); } catch (NullValueException e) { } }
query.tenantIdIn(tenantIds.toArray(new String[tenantIds.size()]));
query.tenantIdIn(tenantIds.toArray(new String[tenantIds.size()]));
public void testQueryByTenantId() { DeploymentQuery query = repositoryService .createDeploymentQuery() .tenantIdIn(TENANT_ONE); assertThat(query.count(), is(1L)); query = repositoryService .createDeploymentQuery() .tenantIdIn(TENANT_TWO); assertThat(query.count(), is(1L)); }
public void testQueryByNonExistingTenantId() { DeploymentQuery query = repositoryService .createDeploymentQuery() .tenantIdIn("nonExisting"); assertThat(query.count(), is(0L)); }
public void testQueryByTenantIds() { DeploymentQuery query = repositoryService .createDeploymentQuery() .tenantIdIn(TENANT_ONE, TENANT_TWO); assertThat(query.count(), is(2L)); }
public void testQueryAuthenticatedTenant() { identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); DeploymentQuery query = repositoryService.createDeploymentQuery(); assertThat(query.count(), is(2L)); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(0L)); assertThat(query.tenantIdIn(TENANT_ONE, TENANT_TWO).includeDeploymentsWithoutTenantId().count(), is(2L)); }
public void testQueryAuthenticatedTenants() { identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE, TENANT_TWO)); DeploymentQuery query = repositoryService.createDeploymentQuery(); assertThat(query.count(), is(3L)); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(1L)); assertThat(query.withoutTenantId().count(), is(1L)); }
public void testQuerySortingAsc() { // exclude deployments without tenant id because of database-specific ordering List<Deployment> deployments = repositoryService.createDeploymentQuery() .tenantIdIn(TENANT_ONE, TENANT_TWO) .orderByTenantId() .asc() .list(); assertThat(deployments.size(), is(2)); assertThat(deployments.get(0).getTenantId(), is(TENANT_ONE)); assertThat(deployments.get(1).getTenantId(), is(TENANT_TWO)); }
public void testQuerySortingDesc() { // exclude deployments without tenant id because of database-specific ordering List<Deployment> deployments = repositoryService.createDeploymentQuery() .tenantIdIn(TENANT_ONE, TENANT_TWO) .orderByTenantId() .desc() .list(); assertThat(deployments.size(), is(2)); assertThat(deployments.get(0).getTenantId(), is(TENANT_TWO)); assertThat(deployments.get(1).getTenantId(), is(TENANT_ONE)); }
public void testQueryByTenantIdsIncludeDeploymentsWithoutTenantId() { DeploymentQuery query = repositoryService .createDeploymentQuery() .tenantIdIn(TENANT_ONE) .includeDeploymentsWithoutTenantId(); assertThat(query.count(), is(2L)); query = repositoryService .createDeploymentQuery() .tenantIdIn(TENANT_TWO) .includeDeploymentsWithoutTenantId(); assertThat(query.count(), is(2L)); query = repositoryService .createDeploymentQuery() .tenantIdIn(TENANT_ONE, TENANT_TWO) .includeDeploymentsWithoutTenantId(); assertThat(query.count(), is(3L)); }
@Test public void deleteDeploymentWithAuthenticatedTenant() { Deployment deployment = testRule.deployForTenant(TENANT_ONE, emptyProcess); identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); repositoryService.deleteDeployment(deployment.getId()); identityService.clearAuthentication(); DeploymentQuery query = repositoryService.createDeploymentQuery(); assertThat(query.count(), is(0L)); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(0L)); }
@Test public void deleteDeploymentDisabledTenantCheck() { Deployment deploymentOne = testRule.deployForTenant(TENANT_ONE, emptyProcess); Deployment deploymentTwo = testRule.deployForTenant(TENANT_TWO, startEndProcess); processEngineConfiguration.setTenantCheckEnabled(false); identityService.setAuthentication("user", null, null); repositoryService.deleteDeployment(deploymentOne.getId()); repositoryService.deleteDeployment(deploymentTwo.getId()); DeploymentQuery query = repositoryService.createDeploymentQuery(); assertThat(query.count(), is(0L)); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(0L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(0L)); }
@Test public void createDeploymentWithAuthenticatedTenant() { identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); repositoryService.createDeployment().addModelInstance("emptyProcess.bpmn", emptyProcess) .tenantId(TENANT_ONE).deploy(); identityService.clearAuthentication(); DeploymentQuery query = repositoryService.createDeploymentQuery(); assertThat(query.count(), is(1L)); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L)); }
@Test public void createDeploymentDisabledTenantCheck() { processEngineConfiguration.setTenantCheckEnabled(false); identityService.setAuthentication("user", null, null); repositoryService.createDeployment().addModelInstance("emptyProcessOne", emptyProcess).tenantId(TENANT_ONE).deploy(); repositoryService.createDeployment().addModelInstance("emptyProcessTwo", startEndProcess).tenantId(TENANT_TWO).deploy(); DeploymentQuery query = repositoryService.createDeploymentQuery(); assertThat(query.count(), is(2L)); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(1L)); }
@Test public void createDeploymentForAnotherTenant() { identityService.setAuthentication("user", null, null); repositoryService.createDeployment().addModelInstance("emptyProcess.bpmn", emptyProcess) .tenantId(TENANT_ONE).deploy(); identityService.clearAuthentication(); DeploymentQuery query = repositoryService.createDeploymentQuery(); assertThat(query.count(), is(1L)); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L)); }
@Test public void redeployForDifferentAuthenticatedTenantsDisabledTenantCheck() { Deployment deploymentOne = repositoryService.createDeployment() .addModelInstance("emptyProcess.bpmn", emptyProcess) .addModelInstance("startEndProcess.bpmn", startEndProcess) .tenantId(TENANT_ONE) .deploy(); identityService.setAuthentication("user", null, null); processEngineConfiguration.setTenantCheckEnabled(false); repositoryService.createDeployment() .addDeploymentResources(deploymentOne.getId()) .tenantId(TENANT_TWO) .deploy(); DeploymentQuery query = repositoryService.createDeploymentQuery(); assertThat(query.count(), is(2L)); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(1L)); }
@Test public void redeployForTheSameAuthenticatedTenant() { Deployment deploymentOne = repositoryService.createDeployment() .addModelInstance("emptyProcess.bpmn", emptyProcess) .addModelInstance("startEndProcess.bpmn", startEndProcess) .tenantId(TENANT_ONE) .deploy(); identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); repositoryService.createDeployment() .addDeploymentResources(deploymentOne.getId()) .tenantId(TENANT_ONE) .deploy(); DeploymentQuery query = repositoryService.createDeploymentQuery(); assertThat(query.count(), is(2L)); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(2L)); }
@Test public void testDeploymentTenantIdIncludeDefinitionsWithoutTenantid() { List<Deployment> mockDeployments = Arrays.asList( MockProvider.createMockDeployment(null), MockProvider.createMockDeployment(MockProvider.EXAMPLE_TENANT_ID)); mockedQuery = setUpMockDeploymentQuery(mockDeployments); Response response = given() .queryParam("tenantIdIn", MockProvider.EXAMPLE_TENANT_ID) .queryParam("includeDeploymentsWithoutTenantId", true) .then().expect() .statusCode(Status.OK.getStatusCode()) .when() .get(DEPLOYMENT_QUERY_URL); verify(mockedQuery).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID); verify(mockedQuery).includeDeploymentsWithoutTenantId(); verify(mockedQuery).list(); String content = response.asString(); List<String> definitions = from(content).getList(""); assertThat(definitions).hasSize(2); String returnedTenantId1 = from(content).getString("[0].tenantId"); String returnedTenantId2 = from(content).getString("[1].tenantId"); assertThat(returnedTenantId1).isEqualTo(null); assertThat(returnedTenantId2).isEqualTo(MockProvider.EXAMPLE_TENANT_ID); }
@Test public void testDeploymentTenantIdList() { List<Deployment> deployments = Arrays.asList( MockProvider.createMockDeployment(MockProvider.EXAMPLE_TENANT_ID), MockProvider.createMockDeployment(MockProvider.ANOTHER_EXAMPLE_TENANT_ID)); mockedQuery = setUpMockDeploymentQuery(deployments); Response response = given() .queryParam("tenantIdIn", MockProvider.EXAMPLE_TENANT_ID_LIST) .then().expect() .statusCode(Status.OK.getStatusCode()) .when() .get(DEPLOYMENT_QUERY_URL); verify(mockedQuery).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID, MockProvider.ANOTHER_EXAMPLE_TENANT_ID); verify(mockedQuery).list(); String content = response.asString(); List<String> definitions = from(content).getList(""); assertThat(definitions).hasSize(2); String returnedTenantId1 = from(content).getString("[0].tenantId"); String returnedTenantId2 = from(content).getString("[1].tenantId"); assertThat(returnedTenantId1).isEqualTo(MockProvider.EXAMPLE_TENANT_ID); assertThat(returnedTenantId2).isEqualTo(MockProvider.ANOTHER_EXAMPLE_TENANT_ID); }