DDRRecordAgent extends ScheduleAgent implements DDRRecordAgentInterface { public void generateDefaultDDRTypes() { for ( DDRTypeCategory ddrCategory : DDRTypeCategory.values() ) { if ( !ddrCategory.equals( DDRTypeCategory.OTHER ) ) { try { DDRType ddrType = DDRType.getDDRType( ddrCategory ); if ( ddrType == null ) { ddrType = new DDRType(); ddrType.setCategory( ddrCategory ); ddrType.setName( "DEFAULT - " + ddrCategory.name() ); ddrType.createOrUpdate(); } } catch ( Exception e ) { log.severe( String.format( "DDRType creation failed for type: %s. Error: %s", ddrCategory.name(), e.getLocalizedMessage() ) ); } } } }  void generateDefaultDDRTypes(); Object getDDRRecord(@Name("ddrRecordId") String id, @Name("accountId") String accountId,
        @Name("shouldGenerateCosts") @Optional Boolean shouldGenerateCosts,
        @Name("shouldIncludeServiceCosts") @Optional Boolean shouldIncludeServiceCosts); @Override Object getDDRRecords(@Name("accountId") String accountId,
        @Name("adapterTypes") @Optional Collection<AdapterType> adapterTypes,
        @Name("adapterIds") @Optional Collection<String> adapterIds, @Name("fromAddress") @Optional String fromAddress,
        @Name("toAddress") @Optional String toAddress, @Name("typeId") @Optional Collection<String> typeIds,
        @Name("communicationStatus") @Optional String status, @Name("startTime") @Optional Long startTime,
        @Name("endTime") @Optional Long endTime, @Name("sessionKeys") @Optional Collection<String> sessionKeys,
        @Name("offset") @Optional Integer offset, @Name("limit") @Optional Integer limit,
        @Name("shouldGenerateCosts") @Optional Boolean shouldGenerateCosts,
        @Name("shouldIncludeServiceCosts") @Optional Boolean shouldIncludeServiceCosts); @Override RestResponse getDDRRecordsQuantity(@Name("accountId") String accountId,
        @Name("adapterTypes") @Optional Collection<AdapterType> adapterTypes,
        @Name("adapterIds") @Optional Collection<String> adapterIds, @Name("fromAddress") @Optional String fromAddress,
        @Name("toAddress") @Optional String toAddress, @Name("typeId") @Optional Collection<String> typeIds,
        @Name("communicationStatus") @Optional CommunicationStatus status, @Name("startTime") Long startTime,
        @Name("endTime") Long endTime, @Name("sessionKeys") @Optional Collection<String> sessionKeys,
        @Name("offset") @Optional Integer offset); @Override Object getDDRRecordsRecursively(@Name("accountId") String accountId,
        @Name("adapterTypes") @Optional Collection<AdapterType> adapterTypes,
        @Name("adapterIds") @Optional Collection<String> adapterIds, @Name("fromAddress") @Optional String fromAddress,
        @Name("toAddress") @Optional String toAddress, @Name("typeId") @Optional Collection<String> typeIds,
        @Name("communicationStatus") @Optional String status, @Name("startTime") Long startTime,
        @Name("endTime") Long endTime, @Name("sessionKeys") @Optional Collection<String> sessionKeys,
        @Name("offset") @Optional Integer offset, @Name("limit") @Optional Integer limit,
        @Name("shouldGenerateCosts") @Optional Boolean shouldGenerateCosts,
        @Name("shouldIncludeServiceCosts") @Optional Boolean shouldIncludeServiceCosts); Object createDDRType(@Name("nameForDDR") String name,
                                                  @Name("ddrTypeCategory") String categoryString); @Override Object getAllDDRTypes(@Name("name") @Optional String name,
        @Name("category") @Optional DDRTypeCategory category); Object updateDDRType(@Name("id") String id, @Name("name") String name); @Override Object getDDRType(@Name("id") String id); Object createDDRPrice( @Name( "ddrTypeId" ) String ddrTypeId, @Name( "startTime" ) @Optional Long startTime,
        @Name( "endTime" ) @Optional Long endTime, @Name( "price" ) Double price,
        @Name( "staffleStart" ) @Optional Integer staffleStart, @Name( "staffleEnd" ) @Optional Integer staffleEnd,
        @Name( "unit" ) @Optional Integer unit, @Name( "unitType" ) @Optional String unitTypeString,
        @Name( "adapterType" ) @Optional String adapterTypeString, @Name( "adapterId" ) @Optional String adapterId,
        @Name( "keyword" ) @Optional String keyword ); Object createDDRPriceWithNewDDRType(@Name("nameForDDR") String name,
                                               @Name("ddrTypeCategory") String categoryString,
                                               @Name("startTime") @Optional Long startTime,
                                               @Name("endTime") @Optional Long endTime, @Name("price") Double price,
                                               @Name("staffleStart") @Optional Integer staffleStart,
                                               @Name("staffleEnd") @Optional Integer staffleEnd,
                                               @Name("unit") @Optional Integer unit,
                                               @Name("unitType") @Optional String unitTypeString,
                                               @Name("adapterType") @Optional String adapterTypeString,
                                               @Name("adapterId") @Optional String adapterid,
                                               @Name("keyword") @Optional String keyword); void removeDDRPrice(@Name( "id" ) String id); Object getDDRPrice(@Name( "id" ) String id); @Override Object getDDRPrices( @Name( "ddrTypeId" ) @Optional String ddrTypeId,
        @Name( "adapterType" ) @Optional String adapterTypeString, @Name( "adapterId" ) @Optional String adapterId,
        @Name( "unitType" ) @Optional String unitTypeString, @Name( "keyword" ) @Optional String keyword ); @Override Object getDDRPricesWithCategory(@Name("ddrTypeId") @Optional String ddrTypeId,
        @Name("adapterType") @Optional String adapterTypeString, @Name("adapterId") @Optional String adapterId,
        @Name("unitType") @Optional String unitTypeString, @Name("keyword") @Optional String keyword,
        @Name("searchCode") @Optional String code); ArrayList<String> startSchedulerForSubscriptions(); ArrayList<String> stopSchedulerForSubscriptions(@Name("adapterId") @Optional String adapterId,
        @Name("ddrPriceId") @Optional String ddrPriceId, @Name("deleteDDRPrice") @Optional Boolean deleteDDRPrice); void applySubscriptionChargesForAdapters(@Name("adapterIds") @Optional Collection<String> adapterIds,
        @Name("adapterTypes") @Optional Collection<String> adapterTypes); ArrayList<ScheduledTask> getSubsriptionCostScedulerDetails(@Name("ddrPriceId") @Optional String ddrPriceId); double updateDDRRecordsWithAdapterType();  }
@Test public void saveDDRRecordTest() throws Exception { AdapterConfig adapterConfig = createBroadsoftAdapter(); Session session = createSession(adapterConfig, remoteAddressVoice); new DDRRecordAgent().generateDefaultDDRTypes(); createTestDDRPrice(DDRTypeCategory.OUTGOING_COMMUNICATION_COST, 0.1, "test", UnitType.MINUTE, AdapterType.CALL, null); DDRUtils.createDDRRecordOnOutgoingCommunication(adapterConfig, TEST_PUBLIC_KEY, remoteAddressVoice, 1, "some test message", session); List<DDRRecord> ddrRecords = getAllDdrRecords(TEST_PUBLIC_KEY); DDRRecord ddrRecord = ddrRecords.iterator().next(); Map<String, String> toAddress = new HashMap<String, String>(1); toAddress.put(session.getRemoteAddress(), ""); assertThat(ddrRecord.getToAddress(), Matchers.is(toAddress)); String secondRemoteAddress = "0612345678"; toAddress.put(secondRemoteAddress, ""); ddrRecord.addToAddress(secondRemoteAddress); ddrRecord.createOrUpdate(); ddrRecords = getAllDdrRecords(TEST_PUBLIC_KEY); ddrRecord = ddrRecords.iterator().next(); assertThat(ddrRecord.getToAddress(), Matchers.is(toAddress)); }