Examples of MongoOperations


Examples of org.springframework.data.mongodb.core.MongoOperations

    }


    @Test
    public void getTemplate(){
        MongoOperations temp1;

        temp1 = repo.getTemplate();
        assertThat(temp1, is(sameInstance(template)));
    }
View Full Code Here

Examples of org.springframework.data.mongodb.core.MongoOperations

        assertThat(temp1, is(sameInstance(template)));
    }

    @Test
    public void setTemplate(){
        MongoOperations temp1 = createNiceMock(MongoOperations.class);

        repo.setTemplate(temp1);
        assertThat(repo.getTemplate(), is(sameInstance(temp1)));

    }
View Full Code Here

Examples of org.springframework.data.mongodb.core.MongoOperations

public class MongoApp2 {
  private static final Log log = LogFactory.getLog(MongoApp.class);

  public static void main(String[] args) throws Exception {
    MongoOperations mongoOps = new MongoTemplate(new SimpleMongoDbFactory(
        new Mongo(), "database"));
    Person p = new Person("Joe", 34);
    // Insert is used to initially store the object into the database.
    mongoOps.insert(p);
    log.info("Insert: " + p); // Find
    p = mongoOps.findById(p.getId(), Person.class);
    log.info("Found: " + p); // Update
    mongoOps.updateFirst(query(where("name").is("Joe")), update("age", 35),
        Person.class);
    p = mongoOps.findOne(query(where("name").is("Joe")), Person.class);
    log.info("Updated: " + p); // Delete mongoOps.remove(p);
    // Check that deletion worked
    List<Person> people = mongoOps.findAll(Person.class);
    log.info("Number of people = : " + people.size());
//    mongoOps.dropCollection(Person.class);
  }
View Full Code Here

Examples of org.springframework.data.mongodb.core.MongoOperations

public class MongoApp {
  private static final Log log = LogFactory.getLog(MongoApp.class);

  public static void main(String[] args) throws Exception {
    MongoOperations mongoOps = new MongoTemplate(new Mongo(), "database");
    mongoOps.insert(new Person("Joe", 34));
    log.info(mongoOps.findOne(new Query(where("name").is("Joe")),
        Person.class));
//    mongoOps.dropCollection("person");
  }
View Full Code Here

Examples of org.springframework.data.mongodb.core.MongoOperations

    }


    @Test
    public void getTemplate(){
        MongoOperations temp1;

        temp1 = repo.getTemplate();
        assertThat(temp1, is(sameInstance(template)));
    }
View Full Code Here

Examples of org.springframework.data.mongodb.core.MongoOperations

        assertThat(temp1, is(sameInstance(template)));
    }

    @Test
    public void setTemplate(){
        MongoOperations temp1 = createNiceMock(MongoOperations.class);

        repo.setTemplate(temp1);
        assertThat(repo.getTemplate(), is(sameInstance(temp1)));

    }
View Full Code Here

Examples of org.springframework.data.mongodb.core.MongoOperations

    @SuppressWarnings("unchecked")
    final MongoItemWriter<String>[] writers = new MongoItemWriter[limit];
    final String[] results = new String[limit];
    for(int i = 0; i< limit; i++) {
      final int index = i;
      MongoOperations mongoOperations = mock(MongoOperations.class);
     
      doAnswer(new Answer<Void>() {
        @Override
        public Void answer(InvocationOnMock invocation)
            throws Throwable {
View Full Code Here

Examples of org.springframework.data.mongodb.core.MongoOperations

   * @see org.springframework.data.repository.cdi.CdiRepositoryBean#create(javax.enterprise.context.spi.CreationalContext, java.lang.Class)
   */
  @Override
  protected T create(CreationalContext<T> creationalContext, Class<T> repositoryType, Object customImplementation) {

    MongoOperations mongoOperations = getDependencyInstance(operations, MongoOperations.class);
    MongoRepositoryFactory factory = new MongoRepositoryFactory(mongoOperations);

    return factory.getRepository(repositoryType, customImplementation);
  }
View Full Code Here

Examples of org.springframework.data.mongodb.core.MongoOperations

   */
  @Test
  public void testMongoTemplateFactory() {

    assertTrue(ctx.containsBean("mongoTemplate"));
    MongoOperations operations = (MongoOperations) ctx.getBean("mongoTemplate");

    MongoDbFactory dbf = (MongoDbFactory) getField(operations, "mongoDbFactory");
    assertEquals("database", getField(dbf, "databaseName"));

    MongoConverter converter = (MongoConverter) getField(operations, "mongoConverter");
View Full Code Here

Examples of org.springframework.data.mongodb.core.MongoOperations

   */
  @Test
  public void testSecondMongoTemplateFactory() {

    assertTrue(ctx.containsBean("anotherMongoTemplate"));
    MongoOperations operations = (MongoOperations) ctx.getBean("anotherMongoTemplate");

    MongoDbFactory dbf = (MongoDbFactory) getField(operations, "mongoDbFactory");
    assertEquals("database", getField(dbf, "databaseName"));

    WriteConcern writeConcern = (WriteConcern) getField(operations, "writeConcern");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.