javax.transaction.Transactional Java Examples
The following examples show how to use
javax.transaction.Transactional.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AccountResourceIntTest.java From expper with GNU General Public License v3.0 | 6 votes |
@Test @Transactional public void testRegisterInvalidLogin() throws Exception { UserDTO u = new UserDTO( "funky-log!n", // login <-- invalid "password", // password "Funky", // firstName "One", // lastName "[email protected]", // e-mail true, // activated "en", // langKey new HashSet<>(Arrays.asList(AuthoritiesConstants.USER)) ); restUserMockMvc.perform( post("/api/register") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(u))) .andExpect(status().isBadRequest()); Optional<User> user = userRepository.findOneByEmail("[email protected]"); assertThat(user.isPresent()).isFalse(); }
Example #2
Source File: UserAccountService.java From web-budget with GNU General Public License v3.0 | 6 votes |
/** * Use this method to change the password of a given {@link User} * * @param passwordChangeDTO the {@link PasswordChangeDTO} with the new values * @param user the {@link User} to be updated */ @Transactional public void changePassword(PasswordChangeDTO passwordChangeDTO, User user) { final boolean actualMatch = this.passwordEncoder.passwordsMatch( passwordChangeDTO.getActualPassword(), user.getPassword()); if (actualMatch) { if (passwordChangeDTO.isNewPassMatching()) { user.setPassword(this.passwordEncoder.encryptPassword(passwordChangeDTO.getNewPassword())); this.userRepository.saveAndFlushAndRefresh(user); return; } throw new BusinessLogicException("error.change-password.new-pass-not-match"); } throw new BusinessLogicException("error.change-password.actual-pass-not-match"); }
Example #3
Source File: AdminService.java From openvsx with Eclipse Public License 2.0 | 6 votes |
@Transactional(rollbackOn = ErrorResultException.class) public ResultJson editNamespaceMember(String namespaceName, String userName, String provider, String role, UserData admin) throws ErrorResultException { var namespace = repositories.findNamespace(namespaceName); if (namespace == null) { throw new ErrorResultException("Namespace not found: " + namespaceName); } if (Strings.isNullOrEmpty(provider)) { provider = "github"; } var user = repositories.findUserByLoginName(provider, userName); if (user == null) { throw new ErrorResultException("User not found: " + provider + "/" + userName); } ResultJson result; if (role.equals("remove")) { result = users.removeNamespaceMember(namespace, user); } else { result = users.addNamespaceMember(namespace, user, role); } logAdminAction(admin, result); return result; }
Example #4
Source File: UserGroupService.java From jweb-cms with GNU Affero General Public License v3.0 | 6 votes |
@Transactional public UserGroup update(String id, UpdateUserGroupRequest request) { UserGroup userGroup = this.get(id); if (!Strings.isNullOrEmpty(request.name)) { userGroup.name = request.name; } if (!Strings.isNullOrEmpty(request.description)) { userGroup.description = request.description; } if (request.roles != null) { userGroup.roles = Joiner.on(",").join(request.roles); } userGroup.updatedTime = now(); userGroup.updatedBy = request.requestBy; repository.update(id, userGroup); return userGroup; }
Example #5
Source File: EventItemWriter.java From pragmatic-microservices-lab with MIT License | 6 votes |
@Override @Transactional public void writeItems(List<Object> items) throws Exception { try (PrintWriter archive = new PrintWriter(new BufferedWriter(new FileWriter( new File(jobContext.getProperties().getProperty(ARCHIVE_DIRECTORY) + "/archive_" + jobContext.getJobName() + "_" + jobContext.getInstanceId() + ".csv"), true)))) { for (Object item : items) { HandlingEventRegistrationAttempt attempt = (HandlingEventRegistrationAttempt) item; applicationEvents.receivedHandlingEventRegistrationAttempt(attempt); archive.println(attempt.getRegistrationTime() + "," + attempt.getCompletionTime() + "," + attempt.getTrackingId() + "," + attempt.getVoyageNumber() + "," + attempt.getUnLocode() + "," + attempt.getType()); } } }
Example #6
Source File: JPARegistryStorage.java From apicurio-registry with Apache License 2.0 | 6 votes |
/** * @see io.apicurio.registry.storage.RegistryStorage#deleteArtifactRule(java.lang.String, io.apicurio.registry.types.RuleType) */ @Override @Transactional public void deleteArtifactRule(String artifactId, RuleType rule) throws ArtifactNotFoundException, RuleNotFoundException, RegistryStorageException { try { requireNonNull(artifactId); requireNonNull(rule); _getArtifact(artifactId, null); int affected = entityManager.createQuery("DELETE FROM Rule r " + "WHERE r.artifactId = :artifact_id AND r.name = :name") .setParameter("artifact_id", artifactId) .setParameter("name", rule) .executeUpdate(); if (affected == 0) { throw new RuleNotFoundException(rule); } } catch (PersistenceException ex) { throw new RegistryStorageException(ex); } }
Example #7
Source File: CiServiceImplTest.java From we-cmdb with Apache License 2.0 | 6 votes |
@Transactional @Test public void executeIntegrateQueryForMultiReferCiThroughReferenceByRSThenReturnResultSucessfully() { IntegrationQueryDto child = new IntegrationQueryDto("invoke_sequence_design"); child.setCiTypeId(6); child.setAttrs(Lists.newArrayList(92)); child.setAttrKeyNames(Lists.newArrayList("invoke_sequence_design.code")); child.setParentRs(new Relationship(96, false)); IntegrationQueryDto parent = new IntegrationQueryDto("invoke_design"); parent.setCiTypeId(5); parent.setAttrs(Lists.newArrayList(76)); parent.setAttrKeyNames(Lists.newArrayList("invoke_design.code")); parent.setChildren(Lists.newArrayList(child)); AdhocIntegrationQueryDto adhocQuery = new AdhocIntegrationQueryDto(); adhocQuery.setCriteria(parent); adhocQuery.setQueryRequest(new QueryRequest()); QueryResponse response = ciService.adhocIntegrateQuery(adhocQuery); assertThat(response.getContents() .size(), equalTo(10)); }
Example #8
Source File: LoginIpServiceImpl.java From MultimediaDesktop with Apache License 2.0 | 6 votes |
@Transactional @Override @HandlerPoint(handlerName = "loginHandler") public void addLoginIp(LoginIpDto loginIpdto) { if (loginIpdto == null || StringUtils.isBlank(loginIpdto.getUserId()) || StringUtils.isBlank(loginIpdto.getIpaddress()) || loginIpdto.getLoginType() == null) { log.error("[登录记录]-[登录记录数据校验失败]-[校验数据为:]" + ToStringBuilder.reflectionToString(loginIpdto)); return; } LoginIp loginIp = new LoginIp(new User(loginIpdto.getUserId()), loginIpdto.getIpaddress(), loginIpdto.getLoginType()); loginIpRepository.save(loginIp); userRepository.updateUserLastLoginDate(loginIpdto.getUserId(), loginIp.getLoginTime()); }
Example #9
Source File: EmitterResource.java From quarkus-quickstarts with Apache License 2.0 | 6 votes |
@Transactional @GET @Path("/prices") @Produces(MediaType.SERVER_SENT_EVENTS) @SseElementType(MediaType.TEXT_PLAIN) public Publisher<Double> prices() { // get the next three prices from the price stream return Multi.createFrom().publisher(prices) .transform().byTakingFirstItems(3) .map(price -> { // store each price before we send them Price priceEntity = new Price(); priceEntity.value = price; // here we are all in the same transaction // thanks to context propagation priceEntity.persist(); return price; // the transaction is committed once the stream completes }); }
Example #10
Source File: TransferenceService.java From web-budget with GNU General Public License v3.0 | 6 votes |
/** * Method to make the {@link WalletBalance} transference * * @param transference the transference */ @Transactional public void transfer(Transference transference) { this.savingBusinessLogics.forEach(logic -> logic.run(transference)); this.transferenceRepository.save(transference); // transfer this.updateWalletBalanceEvent.fire(WalletBalanceBuilder.getInstance() .to(transference.getDestination()) .value(transference.getValue()) .withReason(ReasonType.TRANSFERENCE) .build() ); // adjust the origin balance this.updateWalletBalanceEvent.fire(WalletBalanceBuilder.getInstance() .to(transference.getOrigin()) .value(transference.getValue().negate()) .withReason(ReasonType.TRANSFERENCE) .build() ); }
Example #11
Source File: CiServiceImplLegacyModelTest.java From we-cmdb with Apache License 2.0 | 6 votes |
@Transactional @Test public void addCiDataWithAutoFieldThenThrowException() { Map<String, Object> ciDataMap = MapUtils.putAll(new HashMap(), new Object[] { "name_en", "new Bank system", "description", "duplicated name system", "system_type", 554, "key_name", "system_bank_system" // auto // filled // field }); try { ciService.create(2, ImmutableList.of(ciDataMap)); Assert.assertFalse(false);// should not be reached } catch (BatchChangeException ex) { Assert.assertThat(ex.getExceptionHolders() .size(), greaterThan(0)); Assert.assertThat(ex.getExceptionHolders() .get(0) .getException() .getClass(), equalTo(InvalidArgumentException.class)); Assert.assertThat(((InvalidArgumentException) ex.getExceptionHolders() .get(0) .getException()).getArgumentName(), equalTo("key_name")); } }
Example #12
Source File: ArticlesServiceImpl.java From realworld-api-quarkus with MIT License | 6 votes |
@Override @Transactional public ArticlesData findArticles( int offset, int limit, Long loggedUserId, List<String> tags, List<String> authors, List<String> favorited) { List<Article> articles = articleRepository.findArticles(offset, getLimit(limit), tags, authors, favorited); long articlesCount = articleRepository.count(tags, authors, favorited); return new ArticlesData(toResultList(articles, loggedUserId), articlesCount); }
Example #13
Source File: PeriodMovementService.java From web-budget with GNU General Public License v3.0 | 6 votes |
/** * Update the {@link PeriodMovement} * * @param periodMovement the {@link PeriodMovement} to be updated * @return the updated {@link PeriodMovement} */ @Transactional public PeriodMovement update(PeriodMovement periodMovement) { this.periodMovementUpdatingLogics.forEach(logic -> logic.run(periodMovement)); // delete all removed apportionments periodMovement.getDeletedApportionments() .forEach(apportionment -> this.apportionmentRepository.attachAndRemove(apportionment)); final PeriodMovement saved = this.periodMovementRepository.saveAndFlushAndRefresh(periodMovement); // save all current apportionments periodMovement.getApportionments().forEach(apportionment -> { apportionment.setMovement(saved); this.apportionmentRepository.save(apportionment); }); // fire an event telling about the update this.periodMovementUpdatedEvent.fire(saved); return saved; }
Example #14
Source File: CiServiceImplLegacyModelTest.java From we-cmdb with Apache License 2.0 | 6 votes |
@Transactional @Test public void updateIsNotNullableFieldThenGetException() { Map<String, Object> ciDataMap = MapUtils.putAll(new HashMap(), new Object[] { "guid", "0002_0000000002", "system_type", null }); try { ciService.update(2, ImmutableList.of(ciDataMap)); Assert.assertFalse(true);// should not be reached } catch (BatchChangeException ex) { Assert.assertThat(ex.getExceptionHolders() .size(), greaterThan(0)); Assert.assertThat(ex.getExceptionHolders() .get(0) .getException() .getClass(), equalTo(InvalidArgumentException.class)); Assert.assertThat(((InvalidArgumentException) ex.getExceptionHolders() .get(0) .getException()).getArgumentName(), equalTo("system_type")); } }
Example #15
Source File: AccountResourceIntTest.java From jhipster-ribbon-hystrix with GNU General Public License v3.0 | 6 votes |
@Test @Transactional public void testRegisterAdminIsIgnored() throws Exception { UserDTO u = new UserDTO( "badguy", // login "password", // password "Bad", // firstName "Guy", // lastName "[email protected]", // e-mail true, // activated "en", // langKey new HashSet<>(Arrays.asList(AuthoritiesConstants.ADMIN)) // <-- only admin should be able to do that ); restMvc.perform( post("/api/register") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(u))) .andExpect(status().isCreated()); Optional<User> userDup = userRepository.findOneByLogin("badguy"); assertThat(userDup.isPresent()).isTrue(); assertThat(userDup.get().getAuthorities()).hasSize(1) .containsExactly(authorityRepository.findOne(AuthoritiesConstants.USER)); }
Example #16
Source File: PresentationResource.java From jeeshop with Apache License 2.0 | 6 votes |
@PUT @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Transactional(value = Transactional.TxType.REQUIRES_NEW) @RolesAllowed(ADMIN) public Presentation modifyLocalizedPresentation(Presentation presentation) { checkEntityNotNull(); if (this.presentation == null) { // Item does not exist throw new WebApplicationException(Response.Status.BAD_REQUEST); } entityManager.merge(presentation); return presentation; }
Example #17
Source File: UserService.java From FlyCms with MIT License | 5 votes |
/** * 用户登陆 * * @param username * 用户名 * @param password * 密码 * @param request * @throws Exception */ @CacheEvict(value = "user", allEntries = true) @Transactional public User userLogin(String username, String password,boolean keepLogin,HttpServletRequest request,HttpServletResponse response)throws Exception { User user = null; if(StringHelperUtils.checkPhoneNumber(username)) { user = userDao.findByMobile(username); if(user==null){ user = userDao.findByUsername(username); } }else if(StringHelperUtils.emailFormat(username)){ user = userDao.findByEmail(username); }else{ user = userDao.findByUsername(username); } if (user != null) { User login = new User(); if (BCryptUtils.checkpw(password, user.getPassword())) { login.setUserId(user.getUserId()); login.setAttempts(0); login.setLastLogin(new Date()); login.setLoginIp(IpUtils.getIpAddr(request)); userDao.updateUserLogin(login); //用户信息写入session userSessionUtils.setLoginMember(request,response,keepLogin,user); //登录奖励 scoreRuleService.scoreRuleBonus(user.getUserId(), 1L,user.getUserId()); }else{ login.setUserId(user.getUserId()); login.setAttempts(user.getAttempts()+1); login.setAttemptsTime(new Date()); userDao.updateUserLogin(login); user = null; } } return user; }
Example #18
Source File: TestEndpoint.java From quarkus with Apache License 2.0 | 5 votes |
@GET @Path("8254") @Transactional public String testBug8254() { CatOwner owner = new CatOwner("8254"); owner.persist(); new Cat(owner).persist(); new Cat(owner).persist(); new Cat(owner).persist(); // This used to fail with an invalid query "SELECT COUNT(*) SELECT DISTINCT cat.owner FROM Cat cat WHERE cat.owner = ?1" // Should now result in a valid query "SELECT COUNT(DISTINCT cat.owner) FROM Cat cat WHERE cat.owner = ?1" assertEquals(1L, CatOwner.find("SELECT DISTINCT cat.owner FROM Cat cat WHERE cat.owner = ?1", owner).count()); // This used to fail with an invalid query "SELECT COUNT(*) SELECT cat.owner FROM Cat cat WHERE cat.owner = ?1" // Should now result in a valid query "SELECT COUNT(cat.owner) FROM Cat cat WHERE cat.owner = ?1" assertEquals(3L, CatOwner.find("SELECT cat.owner FROM Cat cat WHERE cat.owner = ?1", owner).count()); // This used to fail with an invalid query "SELECT COUNT(*) SELECT cat FROM Cat cat WHERE cat.owner = ?1" // Should now result in a valid query "SELECT COUNT(cat) FROM Cat cat WHERE cat.owner = ?1" assertEquals(3L, Cat.find("SELECT cat FROM Cat cat WHERE cat.owner = ?1", owner).count()); // This didn't use to fail. Make sure it still doesn't. assertEquals(3L, Cat.find("FROM Cat WHERE owner = ?1", owner).count()); assertEquals(3L, Cat.find("owner", owner).count()); assertEquals(1L, CatOwner.find("name = ?1", "8254").count()); return "OK"; }
Example #19
Source File: CommandEntityRepository.java From txle with Apache License 2.0 | 5 votes |
@Transactional @Modifying(clearAutomatically = true) @Query("UPDATE org.apache.servicecomb.saga.alpha.core.Command c " + "SET c.status = :toStatus " + "WHERE c.globalTxId = :globalTxId " + " AND c.localTxId = :localTxId " + " AND c.status = :fromStatus") void updateStatusByGlobalTxIdAndLocalTxId( @Param("fromStatus") String fromStatus, @Param("toStatus") String toStatus, @Param("globalTxId") String globalTxId, @Param("localTxId") String localTxId);
Example #20
Source File: NoPagingTestEndpoint.java From quarkus with Apache License 2.0 | 5 votes |
@GET @Transactional public String test() { PageItem.findAll().list(); return "OK"; }
Example #21
Source File: ClosingService.java From web-budget with GNU General Public License v3.0 | 5 votes |
/** * Reopen the {@link FinancialPeriod} * * @param financialPeriod to reopened */ @Transactional public void reopen(FinancialPeriod financialPeriod) { this.closingRepository.findLastClosing().ifPresent(closing -> { if (!closing.getFinancialPeriod().getIdentification().equals(financialPeriod.getIdentification())) { throw new BusinessLogicException("error.closing.not-last"); } }); this.reopenPeriodLogics.forEach(logic -> logic.run(financialPeriod)); }
Example #22
Source File: CommandEntityRepository.java From servicecomb-pack with Apache License 2.0 | 5 votes |
@Transactional @Modifying(clearAutomatically = true) @Query("UPDATE org.apache.servicecomb.pack.alpha.core.Command c " + "SET c.status = :toStatus " + "WHERE c.globalTxId = :globalTxId " + " AND c.localTxId = :localTxId " + " AND c.status = :fromStatus") void updateStatusByGlobalTxIdAndLocalTxId( @Param("fromStatus") String fromStatus, @Param("toStatus") String toStatus, @Param("globalTxId") String globalTxId, @Param("localTxId") String localTxId);
Example #23
Source File: AccountResourceIntTest.java From OpenIoE with Apache License 2.0 | 5 votes |
@Test @Transactional public void testRegisterDuplicateEmail() throws Exception { // Good ManagedUserDTO validUser = new ManagedUserDTO( null, // id "john", // login "password", // password "John", // firstName "Doe", // lastName "[email protected]", // e-mail true, // activated "en", // langKey new HashSet<>(Arrays.asList(AuthoritiesConstants.USER)), null, // createdDate null, // lastModifiedBy null // lastModifiedDate ); // Duplicate e-mail, different login ManagedUserDTO duplicatedUser = new ManagedUserDTO(validUser.getId(), "johnjr", validUser.getPassword(), validUser.getLogin(), validUser.getLastName(), validUser.getEmail(), true, validUser.getLangKey(), validUser.getAuthorities(), validUser.getCreatedDate(), validUser.getLastModifiedBy(), validUser.getLastModifiedDate()); // Good user restMvc.perform( post("/api/register") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(validUser))) .andExpect(status().isCreated()); // Duplicate e-mail restMvc.perform( post("/api/register") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(duplicatedUser))) .andExpect(status().is4xxClientError()); Optional<User> userDup = userRepository.findOneByLogin("johnjr"); assertThat(userDup.isPresent()).isFalse(); }
Example #24
Source File: WorkFlowExecutionController.java From flux with Apache License 2.0 | 5 votes |
@Transactional @SelectDataSource(type = DataSourceType.READ_WRITE, storage = Storage.SHARDED) public void updateTaskStatus(String machineId, Long stateId, ExecutionUpdateData executionUpdateData) { com.flipkart.flux.domain.Status updateStatus = null; switch (executionUpdateData.getStatus()) { case initialized: updateStatus = com.flipkart.flux.domain.Status.initialized; break; case running: updateStatus = com.flipkart.flux.domain.Status.running; break; case completed: updateStatus = com.flipkart.flux.domain.Status.completed; break; case cancelled: updateStatus = com.flipkart.flux.domain.Status.cancelled; break; case errored: updateStatus = com.flipkart.flux.domain.Status.errored; break; case sidelined: updateStatus = com.flipkart.flux.domain.Status.sidelined; break; } metricsClient.markMeter(new StringBuilder(). append("stateMachine."). append(executionUpdateData.getStateMachineName()). append(".task."). append(executionUpdateData.getTaskName()). append(".status."). append(updateStatus.name()). toString()); updateExecutionStatus(machineId, stateId, updateStatus, executionUpdateData.getRetrycount(), executionUpdateData.getCurrentRetryCount(), executionUpdateData.getErrorMessage(), executionUpdateData.isDeleteFromRedriver()); }
Example #25
Source File: WorkFlowExecutionController.java From flux with Apache License 2.0 | 5 votes |
@Transactional @SelectDataSource(type = DataSourceType.READ_WRITE, storage = Storage.SHARDED) public void updateEventData(String machineId, EventData eventData) { persistEvent(machineId, eventData); String EventUdpateAudit = "Event data updated for event: " + eventData.getName(); this.auditDAO.create(machineId, new AuditRecord(machineId, Long.valueOf(0), Long.valueOf(0), null, null, EventUdpateAudit)); logger.info("Updated event data persisted for event: {} and stateMachineId: {}", eventData.getName(), machineId); }
Example #26
Source File: CouplingInstanceRepositoryTest.java From ServiceCutter with Apache License 2.0 | 5 votes |
@Test @Transactional public void testDualCouplingPersistence() { CouplingCriterionCharacteristic characteristic = createCharacteristic(); UserSystem userSystem = new UserSystem(); userSystemRepository.save(userSystem); Nanoentity nanoentity1 = createNanoentity(userSystem, "nanoentity1"); Nanoentity nanoentity2 = createNanoentity(userSystem, "nanoentity2"); Nanoentity nanoentity3 = createNanoentity(userSystem, "nanoentity3"); CouplingInstance instance = new CouplingInstance(characteristic, InstanceType.CHARACTERISTIC); userSystem.addCouplingInstance(instance); couplingInstanceRepository.save(instance); instance.addNanoentity(nanoentity1); instance.addNanoentity(nanoentity2); instance.addSecondNanoentity(nanoentity3); userSystem.addCouplingInstance(instance); // em.flush(); em.clear(); Set<CouplingInstance> list = couplingInstanceRepository.findByUserSystem(userSystem); assertThat(list, hasSize(1)); CouplingInstance persistedInstance = list.iterator().next(); assertThat(persistedInstance.getNanoentities(), hasSize(2)); assertThat(persistedInstance.getSecondNanoentities(), hasSize(1)); assertThat(persistedInstance.getSecondNanoentities().get(0).getId(), is(nanoentity3.getId())); }
Example #27
Source File: CiTypeServiceImpl.java From we-cmdb with Apache License 2.0 | 5 votes |
@OperationLogPointcut(operation = Implementation, objectClass = CiTypeDto.class) @Transactional @Override public void applyAllCiType() { QueryRequest request = new QueryRequest(); QueryResponse<AdmCiType> response = staticEntityRepository.query(AdmCiType.class, request); if (response != null) { for (AdmCiType admCiType : response.getContents()) { applyCiTypeWithAttr(admCiType, false); } } }
Example #28
Source File: TestEndpoint.java From quarkus with Apache License 2.0 | 5 votes |
@GET @Path("projection") @Transactional public String testProjection() { Assertions.assertEquals(1, Person.count()); PersonName person = Person.findAll().project(PersonName.class).firstResult(); Assertions.assertEquals("2", person.name); person = Person.find("name", "2").project(PersonName.class).firstResult(); Assertions.assertEquals("2", person.name); person = Person.find("name = ?1", "2").project(PersonName.class).firstResult(); Assertions.assertEquals("2", person.name); person = Person.find("name = :name", Parameters.with("name", "2")).project(PersonName.class).firstResult(); Assertions.assertEquals("2", person.name); PanacheQuery<PersonName> query = Person.findAll().project(PersonName.class).page(0, 2); Assertions.assertEquals(1, query.list().size()); query.nextPage(); Assertions.assertEquals(0, query.list().size()); Assertions.assertEquals(1, Person.findAll().project(PersonName.class).count()); return "OK"; }
Example #29
Source File: UserService.java From openvsx with Eclipse Public License 2.0 | 5 votes |
@Transactional public UserData updateUser(OAuth2User principal) { String url = principal.getAttribute("url"); if (url != null && url.startsWith(GITHUB_API)) { return updateGitHubUser(principal); } throw new IllegalArgumentException("Unsupported principal: " + principal.getName()); }
Example #30
Source File: TestEndpoint.java From quarkus with Apache License 2.0 | 5 votes |
@GET @Path("9036") @Transactional public String testBug9036() { Person.deleteAll(); Person emptyPerson = new Person(); emptyPerson.persist(); Person deadPerson = new Person(); deadPerson.name = "Stef"; deadPerson.status = Status.DECEASED; deadPerson.persist(); Person livePerson = new Person(); livePerson.name = "Stef"; livePerson.status = Status.LIVING; livePerson.persist(); assertEquals(3, Person.count()); assertEquals(3, Person.listAll().size()); // should be filtered PanacheQuery<Person> query = Person.findAll(Sort.by("id")).filter("Person.isAlive").filter("Person.hasName", Parameters.with("name", "Stef")); assertEquals(1, query.count()); assertEquals(1, query.list().size()); assertEquals(livePerson, query.list().get(0)); assertEquals(1, query.stream().count()); assertEquals(livePerson, query.firstResult()); assertEquals(livePerson, query.singleResult()); // these should be unaffected assertEquals(3, Person.count()); assertEquals(3, Person.listAll().size()); Person.deleteAll(); return "OK"; }