FINERACT-776 Fix TopicTest failure

This commit is contained in:
percyashu
2020-01-30 20:24:40 +01:00
committed by Michael Vorburger ⛑️
parent 28db242884
commit 7d99d783d5
@@ -20,6 +20,7 @@ package org.apache.fineract.notification;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.refEq; import static org.mockito.ArgumentMatchers.refEq;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@@ -37,9 +38,11 @@ import org.apache.fineract.useradministration.domain.AppUserRepository;
import org.apache.fineract.useradministration.domain.Role; import org.apache.fineract.useradministration.domain.Role;
import org.apache.fineract.useradministration.domain.RoleRepository; import org.apache.fineract.useradministration.domain.RoleRepository;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
@org.junit.Ignore // see FINERACT-776 @RunWith(MockitoJUnitRunner.class)
public class TopicTest { public class TopicTest {
@Mock @Mock
@@ -64,18 +67,10 @@ public class TopicTest {
public void testTopicStorage() { public void testTopicStorage() {
Office office = officeRepository.getOne(1L); Office office = officeRepository.getOne(1L);
Role role = new Role("New Member_Type", "Testing topic creation"); Role role = new Role("New Member_Type", "Testing topic creation");
Topic topic = topicRepository.getOne(1L);
String title = role.getName() + " of " + office.getName(); lenient().when(this.officeRepository.getOne(1L)).thenReturn(office);
Long entityId = office.getId(); lenient().when(this.topicRepository.getOne(1L)).thenReturn(topic);
String entityType = "";
if (office.getParent() == null) {
entityType = "OFFICE";
} else {
entityType = "BRANCH";
}
Topic topic = new Topic(title, true, entityId, entityType, role.getName().toUpperCase());
when(this.officeRepository.getOne(1L)).thenReturn(office);
when(this.roleRepository.save(role)).thenReturn(role); when(this.roleRepository.save(role)).thenReturn(role);
when(this.topicWritePltfService.create(refEq(topic))).thenReturn(1L); when(this.topicWritePltfService.create(refEq(topic))).thenReturn(1L);
@@ -90,13 +85,13 @@ public class TopicTest {
@Test @Test
public void testTopicSubscriberStorage() { public void testTopicSubscriberStorage() {
AppUser user = appUserRepository.findById(1L).get(); AppUser user = appUserRepository.getOne(1L);
Topic topic = topicRepository.findById(1L).get(); Topic topic = topicRepository.getOne(1L);
TopicSubscriber topicSubscriber = new TopicSubscriber(topic, user, new Date()); TopicSubscriber topicSubscriber = new TopicSubscriber(topic, user, new Date());
when(this.appUserRepository.getOne(1L)).thenReturn(user); lenient().when(this.appUserRepository.getOne(1L)).thenReturn(user);
when(this.topicRepository.getOne(1L)).thenReturn(topic); lenient().when(this.topicRepository.getOne(1L)).thenReturn(topic);
when(this.topicSubscriberWritePltfService.create(refEq(topicSubscriber))).thenReturn(1L); when(this.topicSubscriberWritePltfService.create(refEq(topicSubscriber))).thenReturn(1L);
Long subscriberId = this.topicSubscriberWritePltfService.create(topicSubscriber); Long subscriberId = this.topicSubscriberWritePltfService.create(topicSubscriber);