protected Map<String, DecisionRequirementsDefinition> getDecisionRequirementsDefinitionsForTenant(List<DecisionRequirementsDefinition> definitions) { Map<String, DecisionRequirementsDefinition> definitionsForTenant = new HashMap<String, DecisionRequirementsDefinition>(); for (DecisionRequirementsDefinition definition : definitions) { definitionsForTenant.put(definition.getTenantId(), definition); } return definitionsForTenant; }
public DecisionRequirementsDefinition build() { DecisionRequirementsDefinition mockDefinition = mock(DecisionRequirementsDefinition.class); when(mockDefinition.getId()).thenReturn(id); when(mockDefinition.getCategory()).thenReturn(category); when(mockDefinition.getName()).thenReturn(name); when(mockDefinition.getKey()).thenReturn(key); when(mockDefinition.getVersion()).thenReturn(version); when(mockDefinition.getResourceName()).thenReturn(resource); when(mockDefinition.getDiagramResourceName()).thenReturn(diagramResource); when(mockDefinition.getDeploymentId()).thenReturn(deploymentId); when(mockDefinition.getTenantId()).thenReturn(tenantId); return mockDefinition; }
@Test public void querySortingDesc() { // exclude definitions without tenant id because of database-specific ordering List<DecisionRequirementsDefinition> DecisionRequirementsDefinitions = repositoryService .createDecisionRequirementsDefinitionQuery() .tenantIdIn(TENANT_ONE, TENANT_TWO) .orderByTenantId() .desc() .list(); assertThat(DecisionRequirementsDefinitions.size(), is(2)); assertThat(DecisionRequirementsDefinitions.get(0).getTenantId(), is(TENANT_TWO)); assertThat(DecisionRequirementsDefinitions.get(1).getTenantId(), is(TENANT_ONE)); }
@Test public void getDecisionRequirementsDefinitionWithAuthenticatedTenant() { identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); DecisionRequirementsDefinition definition = repositoryService.getDecisionRequirementsDefinition(decisionRequirementsDefinitionId); assertThat(definition.getTenantId(), is(TENANT_ONE)); }
@Test public void querySortingAsc() { // exclude definitions without tenant id because of database-specific ordering List<DecisionRequirementsDefinition> DecisionRequirementsDefinitions = repositoryService .createDecisionRequirementsDefinitionQuery() .tenantIdIn(TENANT_ONE, TENANT_TWO) .orderByTenantId() .asc() .list(); assertThat(DecisionRequirementsDefinitions.size(), is(2)); assertThat(DecisionRequirementsDefinitions.get(0).getTenantId(), is(TENANT_ONE)); assertThat(DecisionRequirementsDefinitions.get(1).getTenantId(), is(TENANT_TWO)); }
public static DecisionRequirementsDefinitionDto fromDecisionRequirementsDefinition(DecisionRequirementsDefinition definition) { DecisionRequirementsDefinitionDto dto = new DecisionRequirementsDefinitionDto(); dto.id = definition.getId(); dto.key = definition.getKey(); dto.category = definition.getCategory(); dto.name = definition.getName(); dto.version = definition.getVersion(); dto.resource = definition.getResourceName(); dto.deploymentId = definition.getDeploymentId(); dto.tenantId = definition.getTenantId(); return dto; }
public static DecisionRequirementsDefinitionDto fromDecisionRequirementsDefinition(DecisionRequirementsDefinition definition) { DecisionRequirementsDefinitionDto dto = new DecisionRequirementsDefinitionDto(); dto.id = definition.getId(); dto.key = definition.getKey(); dto.category = definition.getCategory(); dto.name = definition.getName(); dto.version = definition.getVersion(); dto.resource = definition.getResourceName(); dto.deploymentId = definition.getDeploymentId(); dto.tenantId = definition.getTenantId(); return dto; }
@Test public void getDecisionRequirementsDefinitionDisabledTenantCheck() { processEngineConfiguration.setTenantCheckEnabled(false); identityService.setAuthentication("user", null, null); DecisionRequirementsDefinition definition = repositoryService.getDecisionRequirementsDefinition(decisionRequirementsDefinitionId); assertThat(definition.getTenantId(), is(TENANT_ONE)); }
@Test public void queryByLatestWithoutTenantId() { // deploy a second version without tenant id testRule.deploy(DMN); DecisionRequirementsDefinitionQuery query = repositoryService .createDecisionRequirementsDefinitionQuery() .decisionRequirementsDefinitionKey(DECISION_REQUIREMENTS_DEFINITION_KEY) .latestVersion() .withoutTenantId(); assertThat(query.count(), is(1L)); DecisionRequirementsDefinition DecisionRequirementsDefinition = query.singleResult(); assertThat(DecisionRequirementsDefinition.getTenantId(), is(nullValue())); assertThat(DecisionRequirementsDefinition.getVersion(), is(2)); }
@Test public void queryByLatestWithTenantId() { // deploy a second version for tenant one testRule.deployForTenant(TENANT_ONE, DMN); DecisionRequirementsDefinitionQuery query = repositoryService .createDecisionRequirementsDefinitionQuery() .decisionRequirementsDefinitionKey(DECISION_REQUIREMENTS_DEFINITION_KEY) .latestVersion() .tenantIdIn(TENANT_ONE); assertThat(query.count(), is(1L)); DecisionRequirementsDefinition DecisionRequirementsDefinition = query.singleResult(); assertThat(DecisionRequirementsDefinition.getTenantId(), is(TENANT_ONE)); assertThat(DecisionRequirementsDefinition.getVersion(), is(2)); query = repositoryService .createDecisionRequirementsDefinitionQuery() .decisionRequirementsDefinitionKey(DECISION_REQUIREMENTS_DEFINITION_KEY) .latestVersion() .tenantIdIn(TENANT_TWO); assertThat(query.count(), is(1L)); DecisionRequirementsDefinition = query.singleResult(); assertThat(DecisionRequirementsDefinition.getTenantId(), is(TENANT_TWO)); assertThat(DecisionRequirementsDefinition.getVersion(), is(1)); }
protected Map<String, DecisionRequirementsDefinition> getDecisionRequirementsDefinitionsForTenant(List<DecisionRequirementsDefinition> definitions) { Map<String, DecisionRequirementsDefinition> definitionsForTenant = new HashMap<String, DecisionRequirementsDefinition>(); for (DecisionRequirementsDefinition definition : definitions) { definitionsForTenant.put(definition.getTenantId(), definition); } return definitionsForTenant; }
@Test public void getDecisionRequirementsDefinitionWithAuthenticatedTenant() { identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); DecisionRequirementsDefinition definition = repositoryService.getDecisionRequirementsDefinition(decisionRequirementsDefinitionId); assertThat(definition.getTenantId(), is(TENANT_ONE)); }
@Test public void querySortingAsc() { // exclude definitions without tenant id because of database-specific ordering List<DecisionRequirementsDefinition> DecisionRequirementsDefinitions = repositoryService .createDecisionRequirementsDefinitionQuery() .tenantIdIn(TENANT_ONE, TENANT_TWO) .orderByTenantId() .asc() .list(); assertThat(DecisionRequirementsDefinitions.size(), is(2)); assertThat(DecisionRequirementsDefinitions.get(0).getTenantId(), is(TENANT_ONE)); assertThat(DecisionRequirementsDefinitions.get(1).getTenantId(), is(TENANT_TWO)); }
@Test public void querySortingDesc() { // exclude definitions without tenant id because of database-specific ordering List<DecisionRequirementsDefinition> DecisionRequirementsDefinitions = repositoryService .createDecisionRequirementsDefinitionQuery() .tenantIdIn(TENANT_ONE, TENANT_TWO) .orderByTenantId() .desc() .list(); assertThat(DecisionRequirementsDefinitions.size(), is(2)); assertThat(DecisionRequirementsDefinitions.get(0).getTenantId(), is(TENANT_TWO)); assertThat(DecisionRequirementsDefinitions.get(1).getTenantId(), is(TENANT_ONE)); }
public static DecisionRequirementsDefinitionDto fromDecisionRequirementsDefinition(DecisionRequirementsDefinition definition) { DecisionRequirementsDefinitionDto dto = new DecisionRequirementsDefinitionDto(); dto.id = definition.getId(); dto.key = definition.getKey(); dto.category = definition.getCategory(); dto.name = definition.getName(); dto.version = definition.getVersion(); dto.resource = definition.getResourceName(); dto.deploymentId = definition.getDeploymentId(); dto.tenantId = definition.getTenantId(); return dto; }
@Test public void getDecisionRequirementsDefinitionDisabledTenantCheck() { processEngineConfiguration.setTenantCheckEnabled(false); identityService.setAuthentication("user", null, null); DecisionRequirementsDefinition definition = repositoryService.getDecisionRequirementsDefinition(decisionRequirementsDefinitionId); assertThat(definition.getTenantId(), is(TENANT_ONE)); }
@Test public void queryByLatestWithoutTenantId() { // deploy a second version without tenant id testRule.deploy(DMN); DecisionRequirementsDefinitionQuery query = repositoryService .createDecisionRequirementsDefinitionQuery() .decisionRequirementsDefinitionKey(DECISION_REQUIREMENTS_DEFINITION_KEY) .latestVersion() .withoutTenantId(); assertThat(query.count(), is(1L)); DecisionRequirementsDefinition DecisionRequirementsDefinition = query.singleResult(); assertThat(DecisionRequirementsDefinition.getTenantId(), is(nullValue())); assertThat(DecisionRequirementsDefinition.getVersion(), is(2)); }
@Test public void queryByLatestWithTenantId() { // deploy a second version for tenant one testRule.deployForTenant(TENANT_ONE, DMN); DecisionRequirementsDefinitionQuery query = repositoryService .createDecisionRequirementsDefinitionQuery() .decisionRequirementsDefinitionKey(DECISION_REQUIREMENTS_DEFINITION_KEY) .latestVersion() .tenantIdIn(TENANT_ONE); assertThat(query.count(), is(1L)); DecisionRequirementsDefinition DecisionRequirementsDefinition = query.singleResult(); assertThat(DecisionRequirementsDefinition.getTenantId(), is(TENANT_ONE)); assertThat(DecisionRequirementsDefinition.getVersion(), is(2)); query = repositoryService .createDecisionRequirementsDefinitionQuery() .decisionRequirementsDefinitionKey(DECISION_REQUIREMENTS_DEFINITION_KEY) .latestVersion() .tenantIdIn(TENANT_TWO); assertThat(query.count(), is(1L)); DecisionRequirementsDefinition = query.singleResult(); assertThat(DecisionRequirementsDefinition.getTenantId(), is(TENANT_TWO)); assertThat(DecisionRequirementsDefinition.getVersion(), is(1)); }