DDRRecordAgent extends ScheduleAgent implements DDRRecordAgentInterface { @Override public 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) throws Exception { CommunicationStatus communicationStatus = status != null && !status.isEmpty() ? CommunicationStatus.fromJson(status) : null; return DDRRecord.getDDRRecords(accountId, adapterTypes, adapterIds, fromAddress, toAddress, typeIds, communicationStatus, startTime, endTime, sessionKeys, offset, limit, shouldGenerateCosts, shouldIncludeServiceCosts); }  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 adapterPurchaseTest() throws Exception { DDRPrice ddrPrice = getTestDDRPrice(DDRTypeCategory.ADAPTER_PURCHASE, 10.0, "Test", UnitType.PART, AdapterType.EMAIL, null); assertThat(ddrPrice.getDdrTypeId(), Matchers.notNullValue()); String createAdapter = adapterAgent.createEmailAdapter("test@test.com", "test", null, null, null, null, null, null, null, TEST_ACCOUNT_ID, null, null, null); Object ddrRecords = ddrRecordAgent.getDDRRecords(TEST_ACCOUNT_ID, null, null, null, null, null, null, null, null, null, null, null, true, true); TypeUtil<Collection<DDRRecord>> typesInjector = new TypeUtil<Collection<DDRRecord>>() { }; Collection<DDRRecord> allDdrRecords = typesInjector.inject(ddrRecords); assertThat(allDdrRecords.size(), Matchers.is(1)); DDRRecord ddrRecord = allDdrRecords.iterator().next(); assertThat(ddrRecord.getAccountId(), Matchers.is(TEST_ACCOUNT_ID)); assertThat(ddrRecord.getAdapterId(), Matchers.is(createAdapter)); assertThat(DDRUtils.calculateDDRCost(ddrRecord), Matchers.is(10.0)); }
@Test public void adapterNotOwnedCreateTest() throws Exception { DDRPrice ddrPrice = getTestDDRPrice(DDRTypeCategory.ADAPTER_PURCHASE, 10.0, "Test", UnitType.PART, AdapterType.EMAIL, null); assertThat(ddrPrice.getDdrTypeId(), Matchers.notNullValue()); adapterAgent.createEmailAdapter("test@test.com", "test", null, null, null, null, null, null, null, null, null, null, null); Object ddrRecords = ddrRecordAgent.getDDRRecords(TEST_ACCOUNT_ID, null, null, null, null, null, null, null, null, null, null, null, null, null); TypeUtil<Collection<DDRRecord>> typesInjector = new TypeUtil<Collection<DDRRecord>>() { }; Collection<DDRRecord> allDdrRecords = typesInjector.inject(ddrRecords); assertThat(allDdrRecords.size(), Matchers.is(0)); }