use of com.tvd12.calabash.local.test.mappersist.Animal in project calabash by youngmonkeys.
the class LocalMapAnimalPersistExample method test.
@SuppressWarnings("rawtypes")
public void test() throws Exception {
SimpleSettings settings = new SimpleSettings();
SimpleEntityMapPersistSetting mapPersistSetting = new SimpleEntityMapPersistSetting();
mapPersistSetting.setWriteDelay(0);
SimpleEntityMapSetting mapSetting = new SimpleEntityMapSetting();
mapSetting.setMapName(CollectionNames.ANIMAL);
mapSetting.setPersistSetting(mapPersistSetting);
settings.addMapSetting(mapSetting);
EzyBeanContext beanContext = newBeanContext();
SimpleEntityMapPersistFactory.Builder mapPersistFactoryBuilder = SimpleEntityMapPersistFactory.builder();
List mapPersistences = beanContext.getSingletons(MapPersistence.class);
for (Object mapPersist : mapPersistences) {
String mapName = MapPersistenceAnnotations.getMapName(mapPersist);
mapPersistFactoryBuilder.addMapPersist(mapName, (EntityMapPersist) mapPersist);
}
Calabash calabash = new CalabashBuilder().settings(settings).mapPersistFactory(mapPersistFactoryBuilder.build()).build();
Animal animal = new Animal(2, "animal 2", "cat");
EntityMap<Long, Animal> entityMap = calabash.getEntityMap(CollectionNames.ANIMAL);
entityMap.put(animal.getId(), animal);
AnimalByNickQuery query = new AnimalByNickQuery(animal.getNick());
Animal animalByQuery = entityMap.getByQuery(1L, query);
System.out.println("animal by query: " + animalByQuery);
Map<String, Object> statistics = new HashMap<>();
// noinspection InfiniteLoopStatement
while (true) {
// noinspection BusyWait
Thread.sleep(1000);
((StatisticsAware) calabash).addStatistics(statistics);
System.out.println("statistics: " + statistics);
}
}
use of com.tvd12.calabash.local.test.mappersist.Animal in project ezyhttp by youngmonkeys.
the class ResponseEntityTest method createByStatusHeadersAndBody.
@Test
public void createByStatusHeadersAndBody() {
// given
int status = StatusCodes.ACCEPTED;
Map<String, List<String>> headers = new HashMap<>();
headers.put("hello", Arrays.asList("world", "galaxy"));
headers.put("foo", Arrays.asList("bar", "animal"));
Object body = "Hello World";
// when
ResponseEntity sut = new ResponseEntity(status, headers, body);
// then
Asserts.assertEquals(status, sut.getStatus());
Asserts.assertEquals(new MultiValueMap(headers), sut.getHeaders());
Asserts.assertEquals("world", sut.getHeader("hello"));
Asserts.assertEquals(body, sut.getBody());
}
Aggregations