List of usage examples for java.math RoundingMode UP
RoundingMode UP
To view the source code for java.math RoundingMode UP.
Click Source Link
From source file:de.tudarmstadt.ukp.dkpro.keyphrases.core.evaluator.util.KeyphrasePerformanceCounter.java
public Double getMeanAveragePrecision() { BigDecimal meanAveragePrecision = new BigDecimal("0.0"); for (FilePerformance filePerformance : fileName2performanceMap.values()) { meanAveragePrecision = meanAveragePrecision.add(filePerformance.calculateAveragePrecision()); }/*from ww w . j a va 2 s . c o m*/ if (fileName2performanceMap.size() == 0) { return 0d; } meanAveragePrecision = meanAveragePrecision.divide( new BigDecimal(String.valueOf(fileName2performanceMap.size())), NBR_FLOATING_POINTS, RoundingMode.UP); return meanAveragePrecision.doubleValue(); }
From source file:com.alivenet.dmvtaxi.Activity_ConfirmMybooking.java
protected void validateGET_TIME(double latitude, double longitude, double destLat, double destLong) { int Time = (int) (new Date().getTime() / 1000); System.out.println("Integer : " + Time); String GET_TIMEFROMGOOGLEMAP = "https://maps.googleapis.com/maps/api/distancematrix/json?"; StringBuilder builder = new StringBuilder(); AsyncHttpClient client = new AsyncHttpClient(); client.addHeader("Content-Type", "application/x-www-form-urlencoded"); RequestParams params = new RequestParams(); builder.append(GET_TIMEFROMGOOGLEMAP); builder.append("origins="); builder.append(latitude);//from ww w.j av a 2 s . c o m builder.append(","); builder.append(longitude); builder.append("&"); builder.append("destinations="); builder.append(destLat); builder.append(","); builder.append(destLong); builder.append("&mode="); builder.append("driving&departure_time="); builder.append(Time); builder.append("&traffic_model=best_guess&language=en-US&key=AIzaSyA35oihmkDaMt8O_FcQZXRhmIVcIFGo-Ag"); client.post(builder.toString(), null, new JsonHttpResponseHandler() { @Override public void onStart() { super.onStart(); } @Override public void onSuccess(int statusCode, Header[] headers, JSONObject responseCode) { super.onSuccess(statusCode, headers, responseCode); Log.e("", "On Success of NoTs"); try { JSONObject object = new JSONObject(responseCode.toString()); Log.e("responseGetTime", ":-" + object.toString(2)); } catch (Exception e) { e.printStackTrace(); } DriverTime driverTime = parseResultGteTime(responseCode.toString()); if (driverTime != null) { Log.e("duration and time", driverTime.getDistance() + "," + driverTime.getDuration()); if (driverTime.getDurationvalue() != null) { double duration = Double.parseDouble(driverTime.getDurationvalue()) / 3600; double trafficduration = Double.parseDouble(driverTime.getDuration_in_trafficvalue()) / 3600; // double distanceTotal = Double.parseDouble(driverTime.getDistacevalue()) / 1000; double distanceTotal = Double.parseDouble(driverTime.getDistacevalue()) / 1609.344; // hourlyCharge = Math.round(ceil($totaltimeSec/900)*($additionHourcharge/15)); double ChargeDistace = distanceTotal - baseFareDistance; double totlaEstimation, totlaEstimationmax; if (ChargeDistace < 0) { totlaEstimation = baseFare + (duration * waitingCharge); } else { totlaEstimation = baseFare + (ChargeDistace * perKm) + (duration * waitingCharge); } double totlaEstimationTraffic = baseFare + (ChargeDistace * perKm) + (trafficduration * waitingCharge); totlaEstimationmax = totlaEstimationTraffic + am_additionHourcharge + am_passengerSurgcharge + am_luggagecharge + am_airportSurcharge + am_perpassengercharge + am_snowcharge + am_telephone_dispatch + am_additioncharge; double totlaEstimationTrafficnewKB = Math.round(totlaEstimationTraffic * 100.0) / 100.0; double totlaEstimationnewKB = Math.round(totlaEstimation * 100.0) / 100.0; totlaEstimationnewKB = totlaEstimationnewKB + am_telephone_dispatch + am_additioncharge; Log.e("Estimation", "==" + totlaEstimationnewKB + "," + totlaEstimationTrafficnewKB); df2.setRoundingMode(RoundingMode.UP); mtvestimateprice.setText(" $ " + "" + df2.format((totlaEstimationnewKB)) + " $" + " " + df2.format((totlaEstimationmax))); } } } @Override public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { } @Override public void onFinish() { super.onFinish(); } }); }
From source file:com.inkubator.hrm.service.impl.PayTempKalkulasiServiceImpl.java
@Override @Transactional(readOnly = false, isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) public List<PayTempKalkulasi> getAllDataCalculatedPayment(Date startPeriodDate, Date endPeriodDate, Date createdOn, String createdBy) throws Exception { //initial//from w w w . j a va 2 s. c o m PaySalaryComponent totalIncomeComponent = paySalaryComponentDao .getEntityBySpecificModelComponent(HRMConstant.MODEL_COMP_TAKE_HOME_PAY); PaySalaryComponent taxComponent = paySalaryComponentDao .getEntityBySpecificModelComponent(HRMConstant.MODEL_COMP_TAX); PaySalaryComponent ceilComponent = paySalaryComponentDao .getEntityBySpecificModelComponent(HRMConstant.MODEL_COMP_CEIL); List<PayTempKalkulasi> datas = new ArrayList<PayTempKalkulasi>(); ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine jsEngine = mgr.getEngineByName("JavaScript"); Double basicSalary = null; Double workingDay = null; Double lessTime = null; Double moreTime = null; Double overTIme = null; Double totalDay = this.getDefaultWorkingDay(startPeriodDate, endPeriodDate); //total working day dari kelompok kerja DEFAULT(reguler) Double outPut = null; //Start calculation List<EmpData> totalEmployee = empDataDao.getAllDataNotTerminateAndJoinDateLowerThan(endPeriodDate); /*List<EmpData> totalEmployee = new ArrayList<EmpData>(); EmpData emp = empDataDao.getEntiyByPK((long)130); totalEmployee.add(emp);*/ for (EmpData empData : totalEmployee) { LOGGER.info( " ============= EMPLOYEE : " + empData.getBioData().getFirstName() + " ====================="); /** * Set initial variabel untuk masing2 karyawan, * yang akan dibutuhkan untuk perhitungan model komponen FORMULA (if any) * */ basicSalary = Double.parseDouble(empData.getBasicSalaryDecrypted()); PayTempOvertime payTempOvertime = payTempOvertimeDao.getEntityByEmpDataId(empData.getId()); overTIme = payTempOvertime != null ? payTempOvertime.getOvertime() : 0.0; PayTempAttendanceStatus payTempAttendanceStatus = payTempAttendanceStatusDao .getEntityByEmpDataId(empData.getId()); workingDay = payTempAttendanceStatus != null ? (double) payTempAttendanceStatus.getTotalAttendance() : 0.0; lessTime = ((workingDay > 0) && (workingDay < totalDay)) ? totalDay - workingDay : 0.0; moreTime = (workingDay > totalDay) ? workingDay - totalDay : 0.0; /** * Saat ini totalIncome masih temporary, karena belum dikurangi * pajak dan pembulatan CSR Sedangkan untuk final totalIncome (take * home pay) ada di proses(step) selanjutnya di batch proses, * silahkan lihat batch-config.xml */ BigDecimal totalIncome = new BigDecimal(0); List<PayComponentDataException> payComponentExceptions = payComponentDataExceptionDao .getAllByEmpId(empData.getId()); for (PayComponentDataException dataException : payComponentExceptions) { PayTempKalkulasi kalkulasi = new PayTempKalkulasi(); kalkulasi.setId(Long.parseLong(RandomNumberUtil.getRandomNumber(12))); kalkulasi.setEmpData(empData); kalkulasi.setPaySalaryComponent(dataException.getPaySalaryComponent()); kalkulasi.setFactor( this.getFactorBasedCategory(dataException.getPaySalaryComponent().getComponentCategory())); kalkulasi.setNominal(dataException.getNominal()); kalkulasi.setCreatedBy(createdBy); kalkulasi.setCreatedOn(createdOn); datas.add(kalkulasi); totalIncome = this.calculateTotalIncome(totalIncome, kalkulasi); //calculate totalIncome temporary LOGGER.info("Save By ComponentDataException - " + dataException.getPaySalaryComponent().getName() + ", nominal : " + dataException.getNominal()); } int timeTmb = DateTimeUtil.getTotalDay(empData.getJoinDate(), createdOn); List<Long> componentIds = Lambda.extract(payComponentExceptions, Lambda.on(PayComponentDataException.class).getPaySalaryComponent().getId()); List<PaySalaryComponent> listPayComponetNotExcp = paySalaryComponentDao .getAllDataByEmpTypeIdAndActiveFromTmAndIdNotIn(empData.getEmployeeType().getId(), timeTmb, componentIds); if (null == Lambda.selectFirst(listPayComponetNotExcp, Lambda.having(Lambda.on(PaySalaryComponent.class).getModelComponent().getSpesific(), Matchers.equalTo(HRMConstant.MODEL_COMP_BASIC_SALARY))) && null == Lambda.selectFirst(payComponentExceptions, Lambda.having( Lambda.on(PayComponentDataException.class).getPaySalaryComponent() .getModelComponent().getSpesific(), Matchers.equalTo(HRMConstant.MODEL_COMP_BASIC_SALARY)))) { throw new BussinessException("global.error_user_does_not_have_basic_salary", empData.getNikWithFullName()); } for (PaySalaryComponent paySalaryComponent : listPayComponetNotExcp) { if (paySalaryComponent.getModelComponent().getSpesific().equals(HRMConstant.MODEL_COMP_UPLOAD)) { PayTempUploadData payUpload = this.payTempUploadDataDao .getEntityByEmpIdAndComponentId(empData.getId(), paySalaryComponent.getId()); if (payUpload != null) { PayTempKalkulasi kalkulasi = new PayTempKalkulasi(); kalkulasi.setId(Long.parseLong(RandomNumberUtil.getRandomNumber(12))); kalkulasi.setEmpData(empData); kalkulasi.setPaySalaryComponent(payUpload.getPaySalaryComponent()); kalkulasi.setFactor(this .getFactorBasedCategory(payUpload.getPaySalaryComponent().getComponentCategory())); BigDecimal nominal = new BigDecimal(payUpload.getNominalValue()); kalkulasi.setNominal(nominal); kalkulasi.setCreatedBy(createdBy); kalkulasi.setCreatedOn(createdOn); datas.add(kalkulasi); totalIncome = this.calculateTotalIncome(totalIncome, kalkulasi); //calculate totalIncome temporary LOGGER.info("Save By Upload - " + payUpload.getPaySalaryComponent().getName() + ", nominal : " + nominal); } } else if (paySalaryComponent.getModelComponent().getSpesific() .equals(HRMConstant.MODEL_COMP_BASIC_SALARY)) { PayTempKalkulasi kalkulasi = new PayTempKalkulasi(); kalkulasi.setId(Long.parseLong(RandomNumberUtil.getRandomNumber(12))); kalkulasi.setEmpData(empData); kalkulasi.setPaySalaryComponent(paySalaryComponent); kalkulasi.setFactor(this.getFactorBasedCategory(paySalaryComponent.getComponentCategory())); BigDecimal nominal = new BigDecimal(empData.getBasicSalaryDecrypted()); if ((timeTmb / 30) < 1) { //jika TMB belum memenuhi satu bulan, jadi basic salary dibagi pro-rate nominal = nominal.divide(new BigDecimal(timeTmb), RoundingMode.UP); } kalkulasi.setNominal(nominal); kalkulasi.setCreatedBy(createdBy); kalkulasi.setCreatedOn(createdOn); datas.add(kalkulasi); totalIncome = this.calculateTotalIncome(totalIncome, kalkulasi); //calculate totalIncome temporary LOGGER.info("Save By Basic Salary " + (((timeTmb / 30) < 1) ? "Not Full" : "Full") + ", nominal : " + nominal); } else if (paySalaryComponent.getModelComponent().getSpesific() .equals(HRMConstant.MODEL_COMP_LOAN)) { //cek apakah modelReferensi di paySalaryComponent valid atau tidak LoanNewType loanType = loanNewTypeDao .getEntiyByPK((long) paySalaryComponent.getModelReffernsil()); if (loanType == null) { throw new BussinessException("salaryCalculation.error_salary_component_reference", paySalaryComponent.getName()); } List<LoanNewApplicationInstallment> installments = loanNewApplicationInstallmentDao .getAllDataDisbursedByEmpDataIdAndLoanTypeIdAndPeriodDate(empData.getId(), loanType.getId(), startPeriodDate, endPeriodDate); for (LoanNewApplicationInstallment installment : installments) { PayTempKalkulasi kalkulasi = new PayTempKalkulasi(); kalkulasi.setId(Long.parseLong(RandomNumberUtil.getRandomNumber(12))); kalkulasi.setEmpData(empData); kalkulasi.setPaySalaryComponent(paySalaryComponent); kalkulasi.setFactor(this.getFactorBasedCategory(paySalaryComponent.getComponentCategory())); BigDecimal nominal = new BigDecimal(installment.getTotalPayment()); nominal = nominal.setScale(0, RoundingMode.UP); kalkulasi.setNominal(nominal); //set detail loan int termin = installment.getLoanNewApplication().getTermin(); long cicilanKe = termin - installment.getNumOfInstallment(); kalkulasi.setDetail(cicilanKe + "/" + termin); kalkulasi.setCreatedBy(createdBy); kalkulasi.setCreatedOn(createdOn); datas.add(kalkulasi); totalIncome = this.calculateTotalIncome(totalIncome, kalkulasi); //calculate totalIncome temporary LOGGER.info("Save By Loan - " + paySalaryComponent.getName() + ", nominal : " + nominal); } } else if (paySalaryComponent.getModelComponent().getSpesific() .equals(HRMConstant.MODEL_COMP_REIMBURSEMENT)) { //cek apakah modelReferensi di paySalaryComponent valid atau tidak RmbsType rmbsType = rmbsTypeDao.getEntiyByPK((long) paySalaryComponent.getModelReffernsil()); if (rmbsType == null) { throw new BussinessException("salaryCalculation.error_salary_component_reference", paySalaryComponent.getName()); } List<RmbsApplication> reimbursments = rmbsApplicationDao .getAllDataDisbursedByEmpDataIdAndRmbsTypeIdAndPeriodDate(empData.getId(), rmbsType.getId(), startPeriodDate, endPeriodDate); for (RmbsApplication reimbursment : reimbursments) { PayTempKalkulasi kalkulasi = new PayTempKalkulasi(); kalkulasi.setId(Long.parseLong(RandomNumberUtil.getRandomNumber(12))); kalkulasi.setEmpData(empData); kalkulasi.setPaySalaryComponent(paySalaryComponent); kalkulasi.setFactor(this.getFactorBasedCategory(paySalaryComponent.getComponentCategory())); kalkulasi.setNominal(reimbursment.getNominal()); //set detail reimbursement kalkulasi.setDetail(reimbursment.getCode()); kalkulasi.setCreatedBy(createdBy); kalkulasi.setCreatedOn(createdOn); datas.add(kalkulasi); totalIncome = this.calculateTotalIncome(totalIncome, kalkulasi); //calculate totalIncome temporary LOGGER.info("Save By Reimbursment, nominal : " + reimbursment.getNominal()); } } else if (paySalaryComponent.getModelComponent().getSpesific() .equals(HRMConstant.MODEL_COMP_FORMULA)) { String formulaOne = paySalaryComponent.getFormula(); if (formulaOne != null) { jsEngine.put("bS", basicSalary); jsEngine.put("wD", workingDay); jsEngine.put("lT", lessTime); jsEngine.put("mT", moreTime); jsEngine.put("oT", overTIme); jsEngine.put("tD", totalDay); outPut = (Double) jsEngine.eval(formulaOne); PayTempKalkulasi kalkulasi = new PayTempKalkulasi(); kalkulasi.setId(Long.parseLong(RandomNumberUtil.getRandomNumber(12))); kalkulasi.setEmpData(empData); kalkulasi.setPaySalaryComponent(paySalaryComponent); kalkulasi.setFactor(this.getFactorBasedCategory(paySalaryComponent.getComponentCategory())); BigDecimal nominal = new BigDecimal(outPut); kalkulasi.setNominal(nominal); kalkulasi.setCreatedBy(createdBy); kalkulasi.setCreatedOn(createdOn); datas.add(kalkulasi); totalIncome = this.calculateTotalIncome(totalIncome, kalkulasi); //calculate totalIncome temporary LOGGER.info("Save By Formula, nominal : " + nominal); } } else if (paySalaryComponent.getModelComponent().getSpesific() .equals(HRMConstant.MODEL_COMP_BENEFIT_TABLE)) { //cek apakah modelReferensi di paySalaryComponent valid atau tidak BenefitGroup benefitGroup = benefitGroupDao .getEntiyByPK((long) paySalaryComponent.getModelReffernsil()); if (benefitGroup == null) { throw new BussinessException("salaryCalculation.error_salary_component_reference", paySalaryComponent.getName()); } //cek apakah tunjangan yg didapatkan sesuai dengan hak dari golonganJabatan karyawan BenefitGroupRate benefitGroupRate = benefitGroupRateDao .getEntityByBenefitGroupIdAndGolJabatanId(benefitGroup.getId(), empData.getGolonganJabatan().getId()); if (benefitGroupRate != null) { PayTempKalkulasi kalkulasi = new PayTempKalkulasi(); kalkulasi.setId(Long.parseLong(RandomNumberUtil.getRandomNumber(12))); kalkulasi.setEmpData(empData); kalkulasi.setPaySalaryComponent(paySalaryComponent); kalkulasi.setFactor(this.getFactorBasedCategory(paySalaryComponent.getComponentCategory())); //nominal untuk benefit dikali nilai dari measurement BigDecimal nominal = new BigDecimal(benefitGroupRate.getNominal()).multiply(this .getMultiplierFromMeasurement(benefitGroupRate.getBenefitGroup().getMeasurement())); kalkulasi.setNominal(nominal); //set detail benefit kalkulasi.setDetail(benefitGroupRate.getGolonganJabatan().getCode()); kalkulasi.setCreatedBy(createdBy); kalkulasi.setCreatedOn(createdOn); datas.add(kalkulasi); totalIncome = this.calculateTotalIncome(totalIncome, kalkulasi); //calculate totalIncome temporary LOGGER.info("Save By Benefit - " + paySalaryComponent.getName() + ", nominal : " + nominal); } } } //create totalIncome Kalkulasi, hasil penjumlahan nominal dari semua component di atas PayTempKalkulasi totalIncomeKalkulasi = new PayTempKalkulasi(); totalIncomeKalkulasi.setId(Long.parseLong(RandomNumberUtil.getRandomNumber(12))); totalIncomeKalkulasi.setEmpData(empData); totalIncomeKalkulasi.setPaySalaryComponent(totalIncomeComponent); totalIncomeKalkulasi .setFactor(this.getFactorBasedCategory(totalIncomeComponent.getComponentCategory())); totalIncomeKalkulasi.setNominal(totalIncome); totalIncomeKalkulasi.setCreatedBy(createdBy); totalIncomeKalkulasi.setCreatedOn(createdOn); datas.add(totalIncomeKalkulasi); //create initial tax Kalkulasi, set nominal 0. Akan dibutuhkan di batch proses step selanjutnya PayTempKalkulasi taxKalkulasi = new PayTempKalkulasi(); taxKalkulasi.setId(Long.parseLong(RandomNumberUtil.getRandomNumber(12))); taxKalkulasi.setEmpData(empData); taxKalkulasi.setPaySalaryComponent(taxComponent); taxKalkulasi.setFactor(this.getFactorBasedCategory(taxComponent.getComponentCategory())); taxKalkulasi.setNominal(new BigDecimal(0)); taxKalkulasi.setCreatedBy(createdBy); taxKalkulasi.setCreatedOn(createdOn); datas.add(taxKalkulasi); //create initial ceil Kalkulasi, set nominal 0. Akan dibutuhkan di batch proses step selanjutnya PayTempKalkulasi ceilKalkulasi = new PayTempKalkulasi(); ceilKalkulasi.setId(Long.parseLong(RandomNumberUtil.getRandomNumber(12))); ceilKalkulasi.setEmpData(empData); ceilKalkulasi.setPaySalaryComponent(ceilComponent); ceilKalkulasi.setFactor(this.getFactorBasedCategory(ceilComponent.getComponentCategory())); ceilKalkulasi.setNominal(new BigDecimal(0)); ceilKalkulasi.setCreatedBy(createdBy); ceilKalkulasi.setCreatedOn(createdOn); datas.add(ceilKalkulasi); } return datas; }
From source file:jp.furplag.util.commons.NumberUtilsTest.java
/** * {@link jp.furplag.util.commons.NumberUtils#divide(java.lang.Object, java.lang.Number, java.lang.Number, java.math.RoundingMode, java.lang.Class)}. *//* w ww. ja v a 2 s. c om*/ @SuppressWarnings("unchecked") @Test public void testDivideTNumberNumberRoundingModeClassOfT() { assertEquals("null", null, divide(null, null, null, null, null)); assertEquals("null", null, divide(10, 5, 0, null, null)); assertEquals("null", null, divide(10, 5, null, null, null)); assertEquals("null", null, divide(10, 3, 2, RoundingMode.DOWN, null)); assertEquals("null", (Object) 3.33f, divide(10, 3, 2, RoundingMode.DOWN, float.class)); try { for (Class<?> type : PRIMITIVES) { Object expected = ClassUtils.primitiveToWrapper(type).getMethod("valueOf", String.class) .invoke(null, "0"); assertEquals("fallback: " + type.getSimpleName(), expected, divide(null, null, null, null, (Class<? extends Number>) type)); } for (Class<?> type : NUMBERS) { Object expected = valueOf(3.33, (Class<? extends Number>) type); assertEquals("10 / 3: " + type.getSimpleName(), expected, divide(10, 3, 2, RoundingMode.DOWN, (Class<? extends Number>) type)); assertEquals("10 / 3: " + type.getSimpleName(), expected, divide(10, 3, 2, RoundingMode.HALF_EVEN, (Class<? extends Number>) type)); assertEquals("10 / 3: " + type.getSimpleName(), expected, divide(10, 3, 2, RoundingMode.HALF_UP, (Class<? extends Number>) type)); assertEquals("10 / 3: " + type.getSimpleName(), expected, divide(10, 3, 2, RoundingMode.FLOOR, (Class<? extends Number>) type)); expected = valueOf(3.34, (Class<? extends Number>) type); assertEquals("10 / 3: " + type.getSimpleName(), expected, divide(10, 3, 2, RoundingMode.UP, (Class<? extends Number>) type)); assertEquals("10 / 3: " + type.getSimpleName(), expected, divide(10, 3, 2, RoundingMode.CEILING, (Class<? extends Number>) type)); } } catch (Exception e) { e.printStackTrace(); fail(e.getMessage() + "\n" + Arrays.toString(e.getStackTrace())); } }
From source file:jp.furplag.util.commons.NumberUtils.java
/** * {@link java.math.RoundingMode#UP}/*from w w w .j a va 2 s .c o m*/ * * @param o the object, number or string. * @param scale scale of fraction. * @param type return type. * @return {@code floor(o)}. Return null if o could not convertible to number. */ public static <T extends Number> T up(final Object o, final Number scale, final Class<T> type) { return setScale(o, scale, RoundingMode.UP, type); }
From source file:io.openvidu.test.e2e.OpenViduTestAppE2eTest.java
private void checkMultimediaFile(File file, boolean hasAudio, boolean hasVideo, double duration, String resolution, String audioDecoder, String videoDecoder, boolean checkAudio) throws IOException { // Check tracks, duration, resolution, framerate and decoders MultimediaFileMetadata metadata = new MultimediaFileMetadata(file.getAbsolutePath()); if (hasVideo) { if (checkAudio) { if (hasAudio) { Assert.assertTrue("Media file " + file.getAbsolutePath() + " should have audio", metadata.hasAudio() && metadata.hasVideo()); Assert.assertTrue(metadata.getAudioDecoder().toLowerCase().contains(audioDecoder)); } else { Assert.assertTrue("Media file " + file.getAbsolutePath() + " should have video", metadata.hasVideo()); Assert.assertFalse(metadata.hasAudio()); }//from w ww . ja va 2s. c o m } if (resolution != null) { Assert.assertEquals(resolution, metadata.getVideoWidth() + "x" + metadata.getVideoHeight()); } Assert.assertTrue(metadata.getVideoDecoder().toLowerCase().contains(videoDecoder)); } else if (hasAudio && checkAudio) { Assert.assertTrue(metadata.hasAudio()); Assert.assertFalse(metadata.hasVideo()); Assert.assertTrue(metadata.getAudioDecoder().toLowerCase().contains(audioDecoder)); } else { Assert.fail("Cannot check a file witho no audio and no video"); } // Check duration with 1 decimal precision DecimalFormat df = new DecimalFormat("#0.0"); df.setRoundingMode(RoundingMode.UP); log.info("Duration of {} according to ffmpeg: {} s", file.getName(), metadata.getDuration()); log.info("Duration of {} according to 'duration' property: {} s", file.getName(), duration); log.info("Difference in s duration: {}", Math.abs(metadata.getDuration() - duration)); final double difference = 10; Assert.assertTrue("Difference between recording entity duration (" + duration + ") and real video duration (" + metadata.getDuration() + ") is greater than " + difference + " in file " + file.getName(), Math.abs((metadata.getDuration() - duration)) < difference); }