/** * Provides information of all business transactions of an application. * * <p> * <i> Example URL: /bc/app/{id}/btx</i> * </p> * * @param id * Application ID. * * @return a list of {@link BusinessTransactionData}. */ @RequestMapping(method = GET, value = "{id}/btx") @ResponseBody public Collection<BusinessTransactionData> getBusinessTransactions(@PathVariable int id) { return businessContextManagementService.getBusinessTransactions(id); }
/** * Reloads the business context data. */ private void refreshBusinessContext() { applicationMap.clear(); businessTransactionsMap.clear(); for (BusinessTransactionData businessTx : businessContextService.getBusinessTransactions()) { businessTransactionsMap.put(new Pair<Integer, Integer>(businessTx.getApplication().getId(), businessTx.getId()), businessTx); } for (ApplicationData application : businessContextService.getApplications()) { applicationMap.put(application.getId(), application); } }
/** * Writes current {@link BusinessContextDefinition} data of the corresponding CMR to storage. * * @throws IOException * thrown if storing business context fails */ protected void writeBusinessContextData() throws IOException { Collection<BusinessTransactionData> businessTransactions = businessContextService.getBusinessTransactions(); super.writeNonDefaultDataObject(businessTransactions, StorageFileType.BUSINESS_CONTEXT_FILE.getDefaultFileName() + StorageFileType.BUSINESS_CONTEXT_FILE.getExtension()); }
@Test public void testBusinessContextCache() throws BusinessException { assertThat(cachedDataService.getApplicationForId(FIRST_APPLICATION_ID), is(equalTo(firstApplication))); assertThat(cachedDataService.getApplicationForId(SECOND_APPLICATION_ID), is(equalTo(secondApplication))); assertThat(cachedDataService.getBusinessTransactionForId(FIRST_APPLICATION_ID, FIRST_BUSINESS_TX_ID), is(equalTo(firstBusinessTx))); assertThat(cachedDataService.getBusinessTransactionForId(FIRST_APPLICATION_ID, SECOND_BUSINESS_TX_ID), is(equalTo(secondBusinessTx))); assertThat(cachedDataService.getBusinessTransactionForId(SECOND_APPLICATION_ID, THIRD_BUSINESS_TX_ID), is(equalTo(thirdBusinessTx))); verify(businessContextService, times(1)).getBusinessTransactions(); verify(businessContextService, times(1)).getApplications(); assertThat(cachedDataService.getApplicationForId(1), is(nullValue())); assertThat(cachedDataService.getApplicationForId(1), is(nullValue())); assertThat(cachedDataService.getBusinessTransactionForId(SECOND_APPLICATION_ID, FIRST_BUSINESS_TX_ID), is(nullValue())); assertThat(cachedDataService.getBusinessTransactionForId(FIRST_APPLICATION_ID, THIRD_BUSINESS_TX_ID), is(nullValue())); assertThat(cachedDataService.getBusinessTransactionForId(1, THIRD_BUSINESS_TX_ID), is(nullValue())); assertThat(cachedDataService.getBusinessTransactionForId(1, 1), is(nullValue())); verify(businessContextService, times(7)).getBusinessTransactions(); verify(businessContextService, times(7)).getApplications(); } }
@BeforeMethod public void initialize() throws BusinessException { firstApplication = new ApplicationData(FIRST_APPLICATION_ID, FIRST_APPLICATION_ID, "firstApplication"); firstBusinessTx = new BusinessTransactionData(FIRST_BUSINESS_TX_ID, FIRST_BUSINESS_TX_ID, firstApplication, "firstBusinessTx"); secondBusinessTx = new BusinessTransactionData(SECOND_BUSINESS_TX_ID, SECOND_BUSINESS_TX_ID, firstApplication, "secondBusinessTx"); secondApplication = new ApplicationData(SECOND_APPLICATION_ID, SECOND_APPLICATION_ID, "secondApplication"); thirdBusinessTx = new BusinessTransactionData(THIRD_BUSINESS_TX_ID, THIRD_BUSINESS_TX_ID, secondApplication, "thirdBusinessTx"); List<BusinessTransactionData> businessTxs = new ArrayList<>(); businessTxs.add(firstBusinessTx); businessTxs.add(secondBusinessTx); businessTxs.add(thirdBusinessTx); List<ApplicationData> applications = new ArrayList<>(); applications.add(firstApplication); applications.add(secondApplication); when(businessContextService.getBusinessTransactions()).thenReturn(businessTxs); when(businessContextService.getApplications()).thenReturn(applications); }