|
| 1 | +package com.redknee.service.event.listener; |
| 2 | + |
| 3 | +import static org.junit.Assert.assertTrue; |
| 4 | + |
| 5 | +import com.redknee.Application; |
| 6 | +import com.redknee.config.ClearCaseVobMapper; |
| 7 | +import com.redknee.rest.dto.EventDto; |
| 8 | +import com.redknee.rest.dto.EventDto.Repository; |
| 9 | +import com.redknee.service.event.ValidationEvent; |
| 10 | +import com.redknee.service.exception.ApiException; |
| 11 | +import java.util.HashMap; |
| 12 | +import java.util.Map; |
| 13 | +import org.junit.Before; |
| 14 | +import org.junit.Test; |
| 15 | +import org.junit.runner.RunWith; |
| 16 | +import org.springframework.boot.test.context.SpringBootTest; |
| 17 | +import org.springframework.test.context.junit4.SpringRunner; |
| 18 | + |
| 19 | +@RunWith(SpringRunner.class) |
| 20 | +@SpringBootTest(classes = Application.class) |
| 21 | +public class ValidationListenerTest { |
| 22 | + |
| 23 | + private ClearCaseVobMapper mapper; |
| 24 | + |
| 25 | + @Before |
| 26 | + public void setUp() throws Exception { |
| 27 | + mapper = new ClearCaseVobMapper(); |
| 28 | + Map<String, String> map = new HashMap<>(); |
| 29 | + map.put("repo_git", "repo_vob"); |
| 30 | + mapper.setPathMapper(map); |
| 31 | + } |
| 32 | + |
| 33 | + @Test |
| 34 | + public void testHandleVobExists() throws Exception { |
| 35 | + EventDto eventDto = new EventDto(); |
| 36 | + Repository repository = new Repository(); |
| 37 | + repository.setFullName("repo_git"); |
| 38 | + eventDto.setRepository(repository); |
| 39 | + ValidationListener listener = new ValidationListener(mapper); |
| 40 | + listener.handle(new ValidationEvent(eventDto)); |
| 41 | + assertTrue(true); |
| 42 | + } |
| 43 | + |
| 44 | + @Test(expected = ApiException.class) |
| 45 | + public void testHandleVobNotExists() throws Exception { |
| 46 | + EventDto eventDto = new EventDto(); |
| 47 | + Repository repository = new Repository(); |
| 48 | + repository.setFullName("repo_git1"); |
| 49 | + eventDto.setRepository(repository); |
| 50 | + ValidationListener listener = new ValidationListener(mapper); |
| 51 | + listener.handle(new ValidationEvent(eventDto)); |
| 52 | + } |
| 53 | +} |
0 commit comments