@Test public void testCreate() throws TechnicalException { IdentityProvider identityProvider = new IdentityProvider(); identityProvider.setName("testName"); identityProvider.setMappers(Collections.singletonMap("username", "johndoe")); identityProvider.setRoleMapper(Collections.singletonMap("username=johndoe", new String[]{"dev", "admin"})); TestObserver<IdentityProvider> testObserver = identityProviderRepository.create(identityProvider).test(); testObserver.awaitTerminalEvent(); testObserver.assertComplete(); testObserver.assertNoErrors(); testObserver.assertValue(idp -> idp.getName().equals(identityProvider.getName()) && idp.getMappers().containsKey("username") && idp.getRoleMapper().containsKey("username=johndoe")); }
@Override public Single<IdentityProvider> create(IdentityProvider item) { IdentityProviderMongo identityProvider = convert(item); identityProvider.setId(identityProvider.getId() == null ? RandomString.generate() : identityProvider.getId()); return Single.fromPublisher(identitiesCollection.insertOne(identityProvider)).flatMap(success -> findById(identityProvider.getId()).toSingle()); }
MongoIdentityProviderRepository extends AbstractManagementMongoRepository implements IdentityProviderRepository { @Override public Single<IdentityProvider> create(IdentityProvider item) { IdentityProviderMongo identityProvider = convert(item); identityProvider.setId(identityProvider.getId() == null ? RandomString.generate() : identityProvider.getId()); return Single.fromPublisher(identitiesCollection.insertOne(identityProvider)).flatMap(success -> findById(identityProvider.getId()).toSingle()); } }
MongoIdentityProviderRepository extends AbstractManagementMongoRepository implements IdentityProviderRepository { @Override public Single<IdentityProvider> create(IdentityProvider item) { IdentityProviderMongo identityProvider = convert(item); identityProvider.setId(identityProvider.getId() == null ? RandomString.generate() : identityProvider.getId()); return Single.fromPublisher(identitiesCollection.insertOne(identityProvider)).flatMap(success -> findById(identityProvider.getId()).toSingle()); }  }
MongoIdentityProviderRepository extends AbstractManagementMongoRepository implements IdentityProviderRepository { @Override public Single<IdentityProvider> create(IdentityProvider item) { IdentityProviderMongo identityProvider = convert(item); identityProvider.setId(identityProvider.getId() == null ? RandomString.generate() : identityProvider.getId()); return Single.fromPublisher(identitiesCollection.insertOne(identityProvider)).flatMap(success -> findById(identityProvider.getId()).toSingle()); }  @PostConstruct void init(); @Override Single<Set<IdentityProvider>> findAll(ReferenceType referenceType, String referenceId); @Override Single<Set<IdentityProvider>> findAll(); @Override Single<Set<IdentityProvider>> findByDomain(String domain); @Override Maybe<IdentityProvider> findById(String identityProviderId); @Override Maybe<IdentityProvider> findById(ReferenceType referenceType, String referenceId, String identityProviderId); @Override Single<IdentityProvider> create(IdentityProvider item); @Override Single<IdentityProvider> update(IdentityProvider item); @Override Completable delete(String id); }
MongoIdentityProviderRepository extends AbstractManagementMongoRepository implements IdentityProviderRepository { @Override public Single<IdentityProvider> create(IdentityProvider item) { IdentityProviderMongo identityProvider = convert(item); identityProvider.setId(identityProvider.getId() == null ? RandomString.generate() : identityProvider.getId()); return Single.fromPublisher(identitiesCollection.insertOne(identityProvider)).flatMap(success -> findById(identityProvider.getId()).toSingle()); }  @PostConstruct void init(); @Override Single<Set<IdentityProvider>> findAll(ReferenceType referenceType, String referenceId); @Override Single<Set<IdentityProvider>> findAll(); @Override Single<Set<IdentityProvider>> findByDomain(String domain); @Override Maybe<IdentityProvider> findById(String identityProviderId); @Override Maybe<IdentityProvider> findById(ReferenceType referenceType, String referenceId, String identityProviderId); @Override Single<IdentityProvider> create(IdentityProvider item); @Override Single<IdentityProvider> update(IdentityProvider item); @Override Completable delete(String id);  }