Package org.springframework.data.gemfire.repository.sample

Examples of org.springframework.data.gemfire.repository.sample.Animal


      }
    };
  }

  protected Animal createAnimal(final Long id, final String name) {
    Animal animal = new Animal();
    animal.setId(id);
    animal.setName(name);
    return animal;
  }
View Full Code Here


    }
    return animalMap;
  }

  protected Animal createAnimal(final String name) {
    Animal animal = new Animal();
    animal.setName(name);
    return animal;
  }
View Full Code Here

    animal.setName(name);
    return animal;
  }

  protected Animal createAnimal(final Long id, final String name) {
    Animal animal = createAnimal(name);
    animal.setId(id);
    return animal;
  }
View Full Code Here

    EntityInformation<Animal, Long> mockEntityInformation = mock(EntityInformation.class);

    doAnswer(new Answer<Long>() {
      private final AtomicLong idSequence = new AtomicLong(0l);
      @Override public Long answer(final InvocationOnMock invocation) throws Throwable {
        Animal argument = Animal.class.cast(invocation.getArguments()[0]);
        Long id = argument.getId();
        id = (id != null ? id : idSequence.incrementAndGet());
        argument.setId(id);
        return id;

      }
    }).when(mockEntityInformation).getId(any(Animal.class));
View Full Code Here

    Region<Long, Animal> mockRegion = mock(Region.class, "testSave");

    SimpleGemfireRepository<Animal, Long> repository = new SimpleGemfireRepository<Animal, Long>(
      createGemfireTemplate(mockRegion), mockEntityInformation());

    Animal dog = repository.save(createAnimal("dog"));

    assertNotNull(dog);
    assertEquals(1l, dog.getId().longValue());
    assertEquals("dog", dog.getName());

    verify(mockRegion, times(1)).put(eq(1l), eq(dog));
  }
View Full Code Here

    verify(mockRegion, times(1)).putAll(eq(asMap(savedAnimals)));
  }

  @Test
  public void testSaveWrapper() {
    Animal dog = createAnimal(1l, "dog");

    Wrapper dogWrapper = new Wrapper(dog, dog.getId());

    Region<Long, Animal> mockRegion = mock(Region.class, "testSaveWrapper");

    SimpleGemfireRepository<Animal, Long> repository = new SimpleGemfireRepository<Animal, Long>(
      createGemfireTemplate(mockRegion), mockEntityInformation());

    repository.save(dogWrapper);

    verify(mockRegion, times(1)).put(eq(dog.getId()), eq(dog));
  }
View Full Code Here

    verify(mockRegion, times(1)).put(eq(dog.getId()), eq(dog));
  }

  @Test
  public void testExists() {
    final Animal dog = createAnimal(1l, "dog");

    Region<Long, Animal> mockRegion = mock(Region.class, "testFindOne");

    when(mockRegion.get(any(Long.class))).then(new Answer<Animal>() {
      @Override public Animal answer(final InvocationOnMock invocation) throws Throwable {
        return (dog.getId().equals(invocation.getArguments()[0]) ? dog : null);
      }
    });

    SimpleGemfireRepository<Animal, Long> repository = new SimpleGemfireRepository<Animal, Long>(
      createGemfireTemplate(mockRegion), mockEntityInformation());
View Full Code Here

    assertFalse(repository.exists(10l));
  }

  @Test
  public void testFindOne() {
    final Animal dog = createAnimal(1l, "dog");

    Region<Long, Animal> mockRegion = mock(Region.class, "testFindOne");

    when(mockRegion.get(any(Long.class))).then(new Answer<Animal>() {
      @Override public Animal answer(final InvocationOnMock invocation) throws Throwable {
        return (dog.getId().equals(invocation.getArguments()[0]) ? dog : null);
      }
    });

    SimpleGemfireRepository<Animal, Long> repository = new SimpleGemfireRepository<Animal, Long>(
      createGemfireTemplate(mockRegion), mockEntityInformation());
View Full Code Here

TOP

Related Classes of org.springframework.data.gemfire.repository.sample.Animal

Copyright © 2018 www.massapicom. 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.