@Test public void update() throws TechnicalException { PermissionRequest source = new PermissionRequest().setResourceId("one").setResourceScopes(Arrays.asList("c","d")); PermissionTicket permissionTicket = new PermissionTicket().setPermissionRequest(Arrays.asList(source)); PermissionTicket ptCreated = repository.create(permissionTicket).blockingGet(); PermissionTicket toUpdate = new PermissionTicket().setId(ptCreated.getId()).setPermissionRequest(Arrays.asList(permission)); TestObserver<PermissionTicket> testObserver = repository.update(toUpdate).test(); testObserver.awaitTerminalEvent(); testObserver.assertComplete(); testObserver.assertNoErrors(); testObserver.assertValue(this::isValid); }
@Override public Single<PermissionTicket> update(PermissionTicket ticket) { PermissionTicketMongo permissionTicket = convert(ticket); return Single.fromPublisher(permissionTicketCollection.replaceOne(eq(FIELD_ID, permissionTicket.getId()), permissionTicket)).flatMap(success -> findById(permissionTicket.getId()).toSingle()); }
MongoPermissionTicketRepository extends AbstractManagementMongoRepository implements PermissionTicketRepository { @Override public Single<PermissionTicket> update(PermissionTicket ticket) { PermissionTicketMongo permissionTicket = convert(ticket); return Single.fromPublisher(permissionTicketCollection.replaceOne(eq(FIELD_ID, permissionTicket.getId()), permissionTicket)).flatMap(success -> findById(permissionTicket.getId()).toSingle()); } }
MongoPermissionTicketRepository extends AbstractManagementMongoRepository implements PermissionTicketRepository { @Override public Single<PermissionTicket> update(PermissionTicket ticket) { PermissionTicketMongo permissionTicket = convert(ticket); return Single.fromPublisher(permissionTicketCollection.replaceOne(eq(FIELD_ID, permissionTicket.getId()), permissionTicket)).flatMap(success -> findById(permissionTicket.getId()).toSingle()); }  }
MongoPermissionTicketRepository extends AbstractManagementMongoRepository implements PermissionTicketRepository { @Override public Single<PermissionTicket> update(PermissionTicket ticket) { PermissionTicketMongo permissionTicket = convert(ticket); return Single.fromPublisher(permissionTicketCollection.replaceOne(eq(FIELD_ID, permissionTicket.getId()), permissionTicket)).flatMap(success -> findById(permissionTicket.getId()).toSingle()); }  @PostConstruct void init(); @Override Maybe<PermissionTicket> findById(String id); @Override Single<PermissionTicket> create(PermissionTicket ticket); @Override Single<PermissionTicket> update(PermissionTicket ticket); @Override Completable delete(String id); }
MongoPermissionTicketRepository extends AbstractManagementMongoRepository implements PermissionTicketRepository { @Override public Single<PermissionTicket> update(PermissionTicket ticket) { PermissionTicketMongo permissionTicket = convert(ticket); return Single.fromPublisher(permissionTicketCollection.replaceOne(eq(FIELD_ID, permissionTicket.getId()), permissionTicket)).flatMap(success -> findById(permissionTicket.getId()).toSingle()); }  @PostConstruct void init(); @Override Maybe<PermissionTicket> findById(String id); @Override Single<PermissionTicket> create(PermissionTicket ticket); @Override Single<PermissionTicket> update(PermissionTicket ticket); @Override Completable delete(String id); static final String COLLECTION_NAME; }