/** Apply the mapping of a filename or URI */ public String mapURI(String filenameOrURI) { if (mapper == null) return filenameOrURI; String uri = mapper.altMapping(filenameOrURI, null); if (uri == null) { if (StreamManager.logAllLookups && log.isDebugEnabled()) log.debug("Not mapped: " + filenameOrURI); uri = filenameOrURI; } else { if (log.isDebugEnabled()) log.debug("Mapped: " + filenameOrURI + " => " + uri); } return uri; }
@Test public void test() { EventMapper mapper = DBRULE.getSession().getMapper(this.event.getMapper()); assertEquals(0, this.event.getId()); mapper.insert(this.event); Assert.assertThat(0, CoreMatchers.not(CoreMatchers.equalTo(this.event.getId()))); final int eventId = this.event.getId(); LocationMapper locMapper = DBRULE.getSession().getMapper(location.getMapper()); locMapper.insert(location); locMapper.addToEvent(this.event.getId(), location.getId()); Event readEvent = mapper.get(eventId); assertNotNull(readEvent); assertEquals(1, readEvent.getVersion()); assertEquals(LocalDate.of(2015, 12, 6), readEvent.getEndDate()); assertEquals(LocalDate.of(2015, 12, 5), readEvent.getStartDate()); assertNotNull(readEvent.getFees()); assertNotNull(readEvent.getLocalOrganizer()); assertNotNull(readEvent.getLocations()); assertEquals(1, readEvent.getLocations().size()); assertEquals(info, readEvent.getInfo()); assertNotNull(readEvent.getTournamentEdition()); assertTrue(readEvent.getTournamentEdition() instanceof TournamentEdition); int updateCount = mapper.update(this.event); assertEquals(0, updateCount); readEvent.setStartDate(LocalDate.of(2015, 12, 4)); updateCount = mapper.update(readEvent); assertEquals(1, updateCount); readEvent = mapper.get(eventId); assertNotNull(readEvent); assertEquals(2, readEvent.getVersion()); assertEquals(LocalDate.of(2015, 12, 6), readEvent.getEndDate()); assertEquals(LocalDate.of(2015, 12, 4), readEvent.getStartDate()); assertNotNull(readEvent.getFees()); assertNotNull(readEvent.getLocalOrganizer()); assertNotNull(readEvent.getLocations()); assertEquals(info, readEvent.getInfo()); assertEquals(1, readEvent.getLocations().size()); assertNotNull(readEvent.getTournamentEdition()); assertTrue(readEvent.getTournamentEdition() instanceof TournamentEdition); /* * we need a second edition as otherwise we will insert a second event * for a TournamentEditionSingle */ TournamentEdition secondEditino = DBRULE.getSession().getMapper(TournamentEditionMapper.class).get(1); secondEditino.setRegistrationStart(LocalDate.now()); secondEditino.setRegistrationEnd(LocalDate.now()); secondEditino.setSeason(season); secondEditino.setOrganizer(readEvent.getLocalOrganizer()); DBRULE.getSession().getMapper(TournamentEditionMapper.class).insert(secondEditino); this.event.setTournamentEdition(secondEditino); mapper.insert(this.event); List<Event> allEvents = mapper.getAll(); assertNotNull(allEvents); assertEquals(2, allEvents.size()); final int deletedId = this.event.getId(); mapper.delete(this.event); assertNull(mapper.get(deletedId)); allEvents = mapper.getAll(); assertNotNull(allEvents); assertEquals(1, allEvents.size()); }