List of usage examples for java.time LocalDateTime now
public static LocalDateTime now()
From source file:com.ccserver.digital.service.LOSService.java
private CustomerInfoType getCustomerInfoType(CreditCardApplicationDTO dto) { CustomerInfoType customerInfo = new CustomerInfoType(); customerInfo.setFirstName(dto.getFirstName()); customerInfo.setLastName(dto.getLastName()); customerInfo.setMidName(dto.getMiddleName()); customerInfo.setFullName(getFullName(dto)); customerInfo.setCustomerType(getConfiguration("LOS_PCARD", "NORMAL")); IDInfoType idInfo = new IDInfoType(); switch (dto.getTypeOfID()) { case Passport: idInfo.setIDType(getConfiguration("LOS_PV", "PV")); break;//from w w w . j a va2 s . c o m case NationalID: idInfo.setIDType(getConfiguration("LOS_IDTYPE_IC", "IC")); break; } idInfo.setIDNo(dto.getPassportNumber()); idInfo.setIDIssueDate(dateToXMLGregorianCalendar(dto.getDateOfIssue())); if (dto.getPlaceOfIssue() != null) { idInfo.setIDIssueBy(dto.getPlaceOfIssue().getCode()); } CountryDTO citizenship = dto.getCitizenship(); if (citizenship != null) { customerInfo.setNationality(citizenship.getIsoCode()); idInfo.setCountry(citizenship.getCode()); if (!"+84".equalsIgnoreCase(citizenship.getCode())) { idInfo.setIDIssueBy(getConfiguration("LOS_ID_ISSUE_BY_FOREIGNER", "Cuc quan ly xuat nhap canh")); } } customerInfo.getIDInfo().add(idInfo); if (!StringUtils.isEmpty(dto.getLicenseNumber())) { IDInfoType licenseNumberInfo = new IDInfoType(); licenseNumberInfo.setIDType(getConfiguration("LOS_IDTYPE_BSL", "BSL")); licenseNumberInfo.setIDNo(dto.getLicenseNumber()); customerInfo.getIDInfo().add(licenseNumberInfo); } ContactInfoType contactInfo = new ContactInfoType(); PhoneInfoType phoneInfoMobile = new PhoneInfoType(); phoneInfoMobile.setPhoneNo(getPhoneNumber(dto.getMobile())); phoneInfoMobile.setPhoneType(getConfiguration("LOS_PHONETYPE", "mobiphone")); contactInfo.getPhoneInfo().add(phoneInfoMobile); // TODO check with UI design (aLy) PhoneInfoType workPhone = new PhoneInfoType(); workPhone.setPhoneNo(getPhoneNumber(dto.getMobile())); workPhone.setPhoneType(getConfiguration("LOS_WORKPHONETYPE", "workphone")); contactInfo.getPhoneInfo().add(workPhone); AddressDTO currentAddressDto = dto.getCurrentAddress(); if (dto.isCurrentIsPermanent()) { currentAddressDto = dto.getPermanentAddress(); } String totalMonthsLiving = getDurationFormat(dto.getMonthsOfLiving(), dto.getYearsOfLiving()); LocalDateTime startLivingTime = LocalDateTime.now().minusMonths(Integer.parseInt(totalMonthsLiving)); AddressInfoType currentAddress = getAddressInfoType(currentAddressDto); currentAddress.setStartDate(dateToXMLGregorianCalendar(startLivingTime)); currentAddress.setDuration(totalMonthsLiving); currentAddress.setIsPermanent( dto.isCurrentIsPermanent() ? getConfiguration("LOS_YES", "Y") : getConfiguration("LOS_NO", "N")); contactInfo.setAddressInfo(currentAddress); contactInfo.setMailAddress(dto.getEmail()); AddressInfoType permanentAddress = getAddressInfoType(dto.getPermanentAddress()); permanentAddress.setStartDate(dateToXMLGregorianCalendar(startLivingTime)); permanentAddress.setDuration(totalMonthsLiving); permanentAddress.setIsPermanent(dto.isCurrentIsPermanent() ? "Y" : "N"); contactInfo.setPermanentAddressInfo(permanentAddress); customerInfo.setContactInfo(contactInfo); switch (dto.getGender()) { case Male: customerInfo.setGender(getConfiguration("LOS_MALE", "M")); break; case Female: customerInfo.setGender(getConfiguration("LOS_FEMALE", "F")); break; } customerInfo.setBirthday(dateToXMLGregorianCalendar(dto.getDob())); SelectionListDTO education = dto.getEducation(); if (education != null) { customerInfo.setEducation(education.getCode()); } SelectionListDTO maritalStatus = dto.getMaritalStatus(); if (maritalStatus != null) { customerInfo.setMaritalStatus(maritalStatus.getCode()); } if (dto.getNumberOfChildren() != null) { customerInfo.setNumberOfChildren(dto.getNumberOfChildren().toString()); } customerInfo.setSector(getConfiguration("LOS_SECTOR", "1001")); customerInfo.setSegments(getConfiguration("LOS_KHCN", "SEG1")); // pass FT because risk from los customerInfo.setEmploymentStatus(getConfiguration("LOS_FT", "FT")); // customerInfo.setEmploymentStatus(dto.getTypeOfEmployement().equals(TypeOfEmployement.Business) // ? "BO" : "FT"); FrequencyInfoType incomeFrequency = new FrequencyInfoType(); incomeFrequency.setType(getConfiguration("LOS_IC", "INC2")); incomeFrequency.setFrequency(getConfiguration("LOS_FREQUENCY", "M")); AmountType amountType = new AmountType(); BigDecimal monthlyIncome = dto.getMonthlyIncome(); if (monthlyIncome != null) { amountType.setAmount(monthlyIncome.toString()); } amountType.setCurrency(getConfiguration("LOS_VND", "VND")); incomeFrequency.setAmount(amountType); incomeFrequency.setMonthlyAmount(amountType); incomeFrequency.setTotalMonthlyAmount(amountType); customerInfo.setIncomeFrequency(incomeFrequency); FrequencyInfoType expenseFrequency = new FrequencyInfoType(); expenseFrequency.setType(getConfiguration("LOS_FREQUENCY_TYPE", "EXP1")); expenseFrequency.setFrequency(getConfiguration("LOS_FREQUENCY", "M")); AmountType exAmountType = new AmountType(); exAmountType.setAmount(dto.getMonthlyExpenses() + ""); exAmountType.setCurrency(getConfiguration("LOS_VND", "VND")); expenseFrequency.setAmount(exAmountType); expenseFrequency.setMonthlyAmount(exAmountType); expenseFrequency.setTotalMonthlyAmount(exAmountType); customerInfo.setExpenseFrequency(expenseFrequency); FrequencyInfoType netFrequency = new FrequencyInfoType(); AmountType netAmountType = new AmountType(); if (monthlyIncome != null) { netAmountType.setAmount(monthlyIncome.subtract( dto.getMonthlyExpenses() != null ? dto.getMonthlyExpenses() : BigDecimal.valueOf(0L)) + ""); } netFrequency.setAmount(netAmountType); netFrequency.setMonthlyAmount(netAmountType); netFrequency.setTotalMonthlyAmount(netAmountType); customerInfo.setNetFrequency(netFrequency); customerInfo.setGreenCard(String.valueOf(convertBooleanToString(dto.isHaveGreenCard()))); customerInfo.setTinNumber(StringUtils.isEmpty(dto.getTinNumber()) ? "0" : dto.getTinNumber()); customerInfo.setGLPNumber(dto.getGlpNumber()); return customerInfo; }
From source file:org.apache.sysml.validation.ValidateLicAndNotice.java
/** * This will return if NOTICE file is valid or not. * * @param noticeFile is the noticew file to be verified. * @return Returns if NOTICE file validatation successful or failure. *//*from w w w . j a v a 2 s .c om*/ public static boolean validateNotice(String noticeFile) throws Exception { boolean bValidNotice = Constants.bSUCCESS; LocalDateTime currentTime = LocalDateTime.now(); String noticeLines[] = new String[4]; boolean noticeLineIn[] = new boolean[4]; noticeLines[0] = "Apache SystemML"; noticeLines[1] = "Copyright [2015-" + currentTime.getYear() + "] The Apache Software Foundation"; noticeLines[2] = "This product includes software developed at"; noticeLines[3] = "The Apache Software Foundation (http://www.apache.org/)"; BufferedReader reader = new BufferedReader(new FileReader(noticeFile)); String line = null; while ((line = reader.readLine()) != null) { line = line.trim(); for (int i = 0; i < noticeLines.length; i++) { if (line.contains(noticeLines[i])) { noticeLineIn[i] = true; } } } for (int i = 0; i < noticeLines.length; i++) { if (!noticeLineIn[i]) { bValidNotice = Constants.bFAILURE; } } if (bValidNotice == Constants.bSUCCESS) Utility.debugPrint(Constants.DEBUG_INFO2, "Notice validation successful."); return bValidNotice; }
From source file:kitt.site.controller.mobile.UserController.java
/**************************************************** ??? start *********************************************/ //??,??MultipartFile??,??? @LoginRequired//from w w w. j ava 2 s . c o m @ResponseBody @RequestMapping(value = "/account/saveCompanyInfo", method = RequestMethod.POST) public Object saveCompanyInfo(Company company, @RequestParam("license") MultipartFile license, @RequestParam("tax") MultipartFile tax, @RequestParam("organization") MultipartFile organization, @RequestParam("openAccount") MultipartFile openAccount, @RequestParam("bill") MultipartFile bill, @RequestParam("operate") MultipartFile operate, String isdeleteBill, String isdeleteOperate, @CurrentUser User user) throws Exception { user = userMapper.getUserById(user.getId()); Map<String, Object> map = new HashMap<String, Object>(); boolean success = true; String errorMsg = null; int compnayCount = companyMapper.countCompanyIsExist(company.getName().trim(), user.getId()); if (compnayCount != 0) { success = false; errorMsg = "???"; } else { if (!(checkPictureInfo.doCheckPictureTypeIncludeNullFile(license) && checkPictureInfo.doCheckPictureTypeIncludeNullFile(tax) && checkPictureInfo.doCheckPictureTypeIncludeNullFile(organization) && checkPictureInfo.doCheckPictureTypeIncludeNullFile(openAccount) && checkPictureInfo.doCheckPictureTypeIncludeNullFile(bill) && checkPictureInfo.doCheckPictureTypeIncludeNullFile(operate))) { success = false; errorMsg = "? .jpg, .bmp, .png, .jpeg ?"; } else if (!(checkPictureInfo.doCheckPictureSize(license) && checkPictureInfo.doCheckPictureSize(tax) && checkPictureInfo.doCheckPictureSize(organization) && checkPictureInfo.doCheckPictureSize(openAccount) && checkPictureInfo.doCheckPictureSize(bill) && checkPictureInfo.doCheckPictureSize(operate))) { success = false; errorMsg = "??10M"; } else if (!"".equals(user.getVerifystatus())) { company.setUserid(user.getId()); if (company.getId() == 0) { String licensePath = fileService.uploadPictureToUploadDir(license); String taxPath = fileService.uploadPictureToUploadDir(tax); String organizationPath = fileService.uploadPictureToUploadDir(organization); String openAccountPath = fileService.uploadPictureToUploadDir(openAccount); String billPath = null; String operatePath = null; company.setBusinesslicense(licensePath); company.setIdentificationnumber(taxPath); company.setOrganizationcode(organizationPath); company.setOpeninglicense(openAccountPath); if (bill != null && bill.getSize() > 0) { billPath = fileService.uploadPictureToUploadDir(bill); company.setInvoicinginformation(billPath); } if (operate != null && operate.getSize() > 0) { operatePath = fileService.uploadPictureToUploadDir(operate); company.setOperatinglicense(operatePath); } companyMapper.addCompany(company); } else { Company com = companyMapper.getCompanyById(company.getId()); String licensePath = null; String taxPath = null; String organizationPath = null; String openAccountPath = null; String billPath = null; String operatePath = null; if (license != null && license.getSize() > 0) { licensePath = fileService.uploadPictureToUploadDir(license); } else { licensePath = com.getBusinesslicense(); } if (tax != null && tax.getSize() > 0) { taxPath = fileService.uploadPictureToUploadDir(tax); } else { taxPath = com.getIdentificationnumber(); } if (organization != null && organization.getSize() > 0) { organizationPath = fileService.uploadPictureToUploadDir(organization); } else { organizationPath = com.getOrganizationcode(); } if (openAccount != null && openAccount.getSize() > 0) { openAccountPath = fileService.uploadPictureToUploadDir(openAccount); } else { openAccountPath = com.getOpeninglicense(); } if (bill != null && bill.getSize() > 0) { billPath = fileService.uploadPictureToUploadDir(bill); } else { if (StringUtils.isBlank(isdeleteBill)) { billPath = com.getInvoicinginformation(); } else { billPath = null; } } if (operate != null && operate.getSize() > 0) { operatePath = fileService.uploadPictureToUploadDir(operate); } else { if (StringUtils.isBlank(isdeleteOperate)) { operatePath = com.getOperatinglicense(); } else { operatePath = null; } } company.setBusinesslicense(licensePath); company.setIdentificationnumber(taxPath); company.setOrganizationcode(organizationPath); company.setOpeninglicense(openAccountPath); company.setInvoicinginformation(billPath); company.setOperatinglicense(operatePath); companyMapper.modifyCompany(company); } companyMapper.addCompVerify(new CompanyVerify("", LocalDateTime.now(), companyMapper.getIdByUserid(user.getId()), user.getId())); companyMapper.setCompanyStatus("", null, companyMapper.getIdByUserid(user.getId())); userMapper.setUserVerifyStatus("", null, user.getId()); MessageNotice.SubmitCompany.noticeUser(user.getSecurephone()); } } map.put("success", success); map.put("errorMsg", errorMsg); return map; }
From source file:com.gnadenheimer.mg.frames.admin.FrameConfigAdmin.java
private void cmdFacturaPrintTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdFacturaPrintTestActionPerformed try {/*from ww w . j a v a 2 s .c o m*/ TblFacturas testF = new TblFacturas(); testF.setNro(1234567); testF.setFechahora(LocalDateTime.now()); testF.setRazonSocial("Empresa SA"); testF.setRuc("8888888-9"); testF.setDomicilio("Loma Plata"); testF.setCasillaDeCorreo(1158); testF.setIdUser(CurrentUser.getInstance().getUser()); testF.setImporteAporte(10775520); testF.setImporteDonacion(25700000); Utils.getInstance().printFactura(testF); } catch (Exception ex) { JOptionPane.showMessageDialog(null, Thread.currentThread().getStackTrace()[1].getMethodName() + " - " + ex.getMessage()); LOGGER.error(Thread.currentThread().getStackTrace()[1].getMethodName(), ex); } }
From source file:jgnash.report.pdf.Report.java
public void addFooter() throws IOException { final String timeStamp = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT) .format(LocalDateTime.now()); final int pageCount = pdfDocument.getNumberOfPages(); float yStart = getBottomMargin() * 2 / 3; for (int i = 0; i < pageCount; i++) { final PDPage page = pdfDocument.getPage(i); final String pageText = MessageFormat.format(rb.getString("Pattern.Pages"), i + 1, pageCount); final float width = getStringWidth(pageText, getFooterFont(), getFooterFontSize()); try (final PDPageContentStream contentStream = new PDPageContentStream(pdfDocument, page, PDPageContentStream.AppendMode.APPEND, true)) { contentStream.setFont(getFooterFont(), getFooterFontSize()); drawText(contentStream, getLeftMargin(), yStart, timeStamp); drawText(contentStream, (float) getPageFormat().getWidth() - getRightMargin() - width, yStart, pageText);/* www. j ava2 s .c om*/ } catch (final IOException e) { logSevere(Report.class, e); } } }
From source file:org.wso2.carbon.apimgt.core.dao.impl.ApiDAOImpl.java
/** * Method for adding API related information * * @param connection DB Connection// w ww . jav a 2s . co m * @param statement PreparedStatement * @param api API object * @throws SQLException if error occurs while accessing data layer */ private void addAPIRelatedInformation(Connection connection, PreparedStatement statement, final API api) throws SQLException { String apiPrimaryKey = api.getId(); statement.setString(1, api.getProvider()); statement.setString(2, api.getName()); statement.setString(3, api.getContext()); statement.setString(4, api.getVersion()); statement.setBoolean(5, api.isDefaultVersion()); statement.setString(6, api.getDescription()); statement.setString(7, api.getVisibility().toString()); statement.setBoolean(8, api.isResponseCachingEnabled()); statement.setInt(9, api.getCacheTimeout()); statement.setString(10, apiPrimaryKey); BusinessInformation businessInformation = api.getBusinessInformation(); statement.setString(11, businessInformation.getTechnicalOwner()); statement.setString(12, businessInformation.getTechnicalOwnerEmail()); statement.setString(13, businessInformation.getBusinessOwner()); statement.setString(14, businessInformation.getBusinessOwnerEmail()); statement.setString(15, api.getLifecycleInstanceId()); statement.setString(16, api.getLifeCycleStatus()); CorsConfiguration corsConfiguration = api.getCorsConfiguration(); statement.setBoolean(17, corsConfiguration.isEnabled()); statement.setString(18, String.join(",", corsConfiguration.getAllowOrigins())); statement.setBoolean(19, corsConfiguration.isAllowCredentials()); statement.setString(20, String.join(",", corsConfiguration.getAllowHeaders())); statement.setString(21, String.join(",", corsConfiguration.getAllowMethods())); statement.setInt(22, getApiTypeId(connection, ApiType.STANDARD)); statement.setString(23, api.getCreatedBy()); statement.setTimestamp(24, Timestamp.valueOf(LocalDateTime.now())); statement.setTimestamp(25, Timestamp.valueOf(LocalDateTime.now())); statement.setString(26, api.getCopiedFromApiId()); statement.setString(27, api.getUpdatedBy()); statement.setString(28, APILCWorkflowStatus.APPROVED.toString()); statement.execute(); if (API.Visibility.RESTRICTED == api.getVisibility()) { addVisibleRole(connection, apiPrimaryKey, api.getVisibleRoles()); } addTagsMapping(connection, apiPrimaryKey, api.getTags()); addLabelMapping(connection, apiPrimaryKey, api.getLabels()); addGatewayConfig(connection, apiPrimaryKey, api.getGatewayConfig(), api.getCreatedBy()); addTransports(connection, apiPrimaryKey, api.getTransport()); addUrlMappings(connection, api.getUriTemplates().values(), apiPrimaryKey); addSubscriptionPolicies(connection, api.getPolicies(), apiPrimaryKey); addEndPointsForApi(connection, apiPrimaryKey, api.getEndpoint()); addAPIDefinition(connection, apiPrimaryKey, api.getApiDefinition(), api.getCreatedBy()); addAPIPermission(connection, api.getPermissionMap(), apiPrimaryKey); if (api.getApiPolicy() != null) { addApiPolicy(connection, api.getApiPolicy().getUuid(), apiPrimaryKey); } }
From source file:net.di2e.ecdr.describe.generator.DescribeGeneratorImpl.java
protected void setRecordRate(MetricsType metrics, Map<String, TemporalCoverageHolder> timeMap) { TemporalCoverageHolder tc = timeMap.containsKey("modified") ? (TemporalCoverageHolder) timeMap.get("modified") : (timeMap.containsKey("effective") ? (TemporalCoverageHolder) timeMap.get("effective") : (TemporalCoverageHolder) timeMap.get("created")); try {/*from w w w. j av a 2 s. c o m*/ if (tc != null) { Date startDate = tc.getStartDate(); if (startDate != null) { long totalHits = metrics.getCount(); LocalDateTime start = LocalDateTime.ofInstant(startDate.toInstant(), ZoneId.systemDefault()); Duration duration = Duration.between(start, LocalDateTime.now()); RecordRateType rate = new RecordRateType(); metrics.setRecordRate(rate); long dur = totalHits / duration.toHours(); if (dur < 15L) { dur = totalHits / duration.toDays(); if (dur < 4L) { dur = totalHits * 30L / duration.toDays(); if (dur < 10L) { dur = totalHits * 365L / duration.toDays(); rate.setFrequency("Yearly"); } else { rate.setFrequency("Monthly"); } } else { rate.setFrequency("Daily"); } } else if (totalHits > 1000L) { dur = duration.toMinutes(); if (totalHits > 1000L) { dur = duration.toMillis() / 1000L; rate.setFrequency("Second"); } else { rate.setFrequency("Minute"); } } else { rate.setFrequency("Hourly"); } rate.setValue((int) dur); } } } catch (Exception e) { LOGGER.warn("Could not set record rate: {}", e.getMessage(), e); } }
From source file:com.ccserver.digital.service.LOSService.java
private String getDurationFormat(LocalDateTime localDateTime) { if (localDateTime == null) { return StringUtils.EMPTY; }//from w w w . java2 s . co m return String.valueOf(ChronoUnit.MONTHS.between(localDateTime, LocalDateTime.now())); }
From source file:fr.landel.utils.assertor.OperatorTest.java
/** * Test method for {@link Operator#nor()}. *//*from w w w . j av a 2s . co m*/ @Test public void testNor() { final String text = "text"; assertTrue(Assertor.that(text).isEmpty().nor().isNotBlank().isOK()); assertTrue(Assertor.that(text).isNotEmpty().nor().isBlank().isOK()); assertTrue(Assertor.that(text).isEmpty().nor().isBlank().isOK()); assertTrue(Assertor.that(text).isEmpty().nor(true).isTrue().isOK()); assertTrue(Assertor.that(text).isEmpty().nor(true).isFalse().isOK()); assertTrue(Assertor.that(text).isEmpty().nor(text.getClass()).isAssignableFrom(CharSequence.class).isOK()); assertTrue(Assertor.that(text).isEmpty().nor(text.getClass()).isAssignableFrom(StringBuilder.class).isOK()); assertTrue(Assertor.that(text).isEmpty().nor(Calendar.getInstance()) .isAfter(DateUtils.getCalendar(new Date(0))).isOK()); assertTrue(Assertor.that(text).isEmpty().nor(Calendar.getInstance()) .isBefore(DateUtils.getCalendar(new Date(0))).isOK()); assertTrue(Assertor.that(text).isEmpty().nor(new Date()).isAfter(new Date(0)).isOK()); assertTrue(Assertor.that(text).isEmpty().nor(new Date()).isBefore(new Date(0)).isOK()); assertTrue(Assertor.that(text).isNotEmpty().nor(LocalDateTime.now()).isAfter(LocalDateTime.MAX).isOK()); assertFalse(Assertor.that(text).isNotEmpty().nor(LocalDateTime.now()).isAfter(LocalDateTime.MIN).isOK()); assertTrue(Assertor.that(text).isEmpty().nor(2).isGT(1).isOK()); assertTrue(Assertor.that(text).isEmpty().nor(2).isLT(1).isOK()); assertTrue(Assertor.that(text).isEmpty().nor("tt").isNotEmpty().isOK()); assertTrue(Assertor.that(text).isEmpty().nor("tt").isEmpty().isOK()); assertTrue(Assertor.that(text).isEmpty().nor(new String[] {}).isEmpty().isOK()); assertTrue(Assertor.that(text).isEmpty().nor(new String[] {}).isNotEmpty().isOK()); assertTrue(Assertor.that(text).isEmpty().nor(new String[] {}, EnumAnalysisMode.STREAM).isEmpty().isOK()); assertTrue(Assertor.that(text).isEmpty().nor(new String[] {}, EnumAnalysisMode.STREAM).isNotEmpty().isOK()); assertTrue(Assertor.that(text).isEmpty().nor(new String[] {}, EnumAnalysisMode.PARALLEL).isEmpty().isOK()); assertTrue( Assertor.that(text).isEmpty().nor(new String[] {}, EnumAnalysisMode.PARALLEL).isNotEmpty().isOK()); assertTrue(Assertor.that(text).isEmpty().nor(Collections.emptyList()).isEmpty().isOK()); assertTrue(Assertor.that(text).isEmpty().nor(Collections.emptyList()).isNotEmpty().isOK()); assertTrue(Assertor.that(text).isEmpty().nor(Collections.emptyList(), EnumAnalysisMode.STREAM).isEmpty() .isOK()); assertTrue(Assertor.that(text).isEmpty().nor(Collections.emptyList(), EnumAnalysisMode.STREAM).isNotEmpty() .isOK()); assertTrue(Assertor.that(text).isEmpty().nor(Collections.emptyList(), EnumAnalysisMode.PARALLEL).isEmpty() .isOK()); assertTrue(Assertor.that(text).isEmpty().nor(Collections.emptyList(), EnumAnalysisMode.PARALLEL) .isNotEmpty().isOK()); assertTrue(Assertor.that(text).isEmpty().nor(Collections.emptyMap()).isEmpty().isOK()); assertTrue(Assertor.that(text).isEmpty().nor(Collections.emptyMap()).isNotEmpty().isOK()); assertTrue(Assertor.that(text).isEmpty().nor(Collections.emptyMap(), EnumAnalysisMode.STREAM).isEmpty() .isOK()); assertTrue(Assertor.that(text).isEmpty().nor(Collections.emptyMap(), EnumAnalysisMode.STREAM).isNotEmpty() .isOK()); assertTrue(Assertor.that(text).isEmpty().nor(Collections.emptyMap(), EnumAnalysisMode.PARALLEL).isEmpty() .isOK()); assertTrue(Assertor.that(text).isEmpty().nor(Collections.emptyMap(), EnumAnalysisMode.PARALLEL).isNotEmpty() .isOK()); assertTrue(Assertor.that(text).isEmpty().nor((Object) 0).isNotNull().isOK()); assertTrue(Assertor.that(text).isEmpty().nor((Object) 0).isNull().isOK()); assertTrue(Assertor.that(text).isEmpty().nor(new Exception()).isNotNull().isOK()); assertTrue(Assertor.that(text).isEmpty().nor(new Exception()).isNull().isOK()); assertTrue(Assertor.that(Color.BLACK).isNull().nor().isEqual(Color.black).isOK()); assertTrue(Assertor.that(Color.BLACK).isNull().nor((Object) 0).isNotNull().isOK()); assertTrue(Assertor.that(Color.BLACK).isNotNull().nor(Assertor.that(text).isEmpty()).isOK()); // SUB ASSERTOR assertTrue(Assertor.that(text).isNotEmpty().norAssertor(t -> Assertor.that(t.length()).isGT(4)).isOK()); assertEquals("the char sequence 'text' should be null or empty", Assertor.that(text).isEmpty() .norAssertor(t -> Assertor.that(t.length()).isGT(4)).getErrors().get()); assertException( () -> Assertor.that(text).isNotEmpty() .norAssertor((Function<String, StepCharSequence<String>>) null).isOK(), IllegalStateException.class, "sub assertor cannot be null"); // MAPPER assertTrue(Assertor.that(false).isTrue().norObject(b -> b.toString()).hasHashCode(Objects.hashCode("true")) .isOK()); assertTrue(Assertor.that(false).isTrue().norCharSequence(b -> b.toString()).contains("ue").isOK()); assertTrue(Assertor.that("test").isNotEmpty() .norArray(s -> ArrayUtils.toObject(s.getBytes(StandardCharsets.UTF_8))).contains((byte) 'x') .isOK()); assertTrue(Assertor.that(false).isTrue().norBoolean(b -> !b).isFalse().isOK()); assertTrue(Assertor.that(false).isTrue().norClass(b -> b.getClass()).hasSimpleName("Boolean").isOK()); assertTrue(Assertor.that(false).isTrue().norDate(b -> new Date(1464475553641L)) .isAfter(new Date(1464475553640L)).isOK()); assertTrue(Assertor.that(false).isTrue().norCalendar(b -> DateUtils.getCalendar(new Date(1464475553641L))) .isBefore(Calendar.getInstance()).isOK()); assertTrue( Assertor.that(false).isTrue().norTemporal(b -> DateUtils.getLocalDateTime(new Date(1464475553641L))) .isBefore(LocalDateTime.now()).isOK()); assertTrue(Assertor.that(false).isTrue().norEnum(b -> EnumOperator.AND).hasName("AND").isOK()); assertTrue(Assertor.that(false).isTrue().norIterable(b -> Arrays.asList('t', 'r')).contains('t').isOK()); assertTrue(Assertor.that(false).isTrue().norMap(b -> MapUtils2.newHashMap("key", b)).contains("key", true) .isOK()); assertTrue(Assertor.that(false).isTrue().norNumber(b -> b.hashCode()).isGT(0).isOK()); // 1231 assertTrue(Assertor.that(false).isTrue().norThrowable(b -> new IOException(b.toString())) .validates(e -> e.getMessage().contains("true")).isOK()); }
From source file:com.saax.gestorweb.TarefaTest.java
/** * Cadastra uma tarefa simples e adiciona um histrico *///from ww w .j a v a 2 s .c om @Test public void tarefaComHistorico() { System.out.println("Testando cadastro simples de tarefa"); Usuario loggedUser = (Usuario) GestorSession.getAttribute(SessionAttributesEnum.USUARIO_LOGADO); HierarquiaProjetoDetalhe categoriaDefaultMeta = model.getCategoriaDefaultTarefa(); presenter.createTask(categoriaDefaultMeta, loggedUser.getEmpresas().get(0).getEmpresa()); String nome = "Teste Cadastro Tarefa Com Historico"; view.getNomeTarefaTextField().setValue(nome); //view.getTipoRecorrenciaCombo().select(TipoTarefa.RECORRENTE); view.getControleRecorrenciaButton().getCaption().equals("RECORRENTE"); view.getPrioridadeCombo().setValue(PrioridadeTarefa.ALTA); view.getDataInicioDateField().setValue(new Date()); view.getEmpresaCombo().setValue(loggedUser.getEmpresas().get(0).getEmpresa()); try { view.getTarefaFieldGroup().commit(); } catch (FieldGroup.CommitException ex) { fail(ex.getMessage()); } view.getGravarButton().click(); Tarefa t = (Tarefa) GestorEntityManagerProvider.getEntityManager().createNamedQuery("Tarefa.findByNome") .setParameter("nome", nome).setParameter("empresa", loggedUser.getEmpresas().get(0).getEmpresa()) .getSingleResult(); t.addHistorico(new HistoricoTarefa("teste", "comentario", loggedUser, t, LocalDateTime.now())); GestorEntityManagerProvider.getEntityManager().persist(t); t = (Tarefa) GestorEntityManagerProvider.getEntityManager().createNamedQuery("Tarefa.findByNome") .setParameter("nome", nome).setParameter("empresa", loggedUser.getEmpresas().get(0).getEmpresa()) .getSingleResult(); Assert.assertEquals(1, t.getHistorico().size()); GestorEntityManagerProvider.getEntityManager().remove(t); }