From 7d99d783d50b8668c7c8b85f0f4d16fe6979df8a Mon Sep 17 00:00:00 2001 From: percyashu Date: Thu, 30 Jan 2020 04:14:07 +0100 Subject: [PATCH] FINERACT-776 Fix TopicTest failure --- .../fineract/notification/TopicTest.java | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/fineract-provider/src/test/java/org/apache/fineract/notification/TopicTest.java b/fineract-provider/src/test/java/org/apache/fineract/notification/TopicTest.java index 09c00969d..10939eb02 100644 --- a/fineract-provider/src/test/java/org/apache/fineract/notification/TopicTest.java +++ b/fineract-provider/src/test/java/org/apache/fineract/notification/TopicTest.java @@ -20,6 +20,7 @@ package org.apache.fineract.notification; import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.refEq; +import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; 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.RoleRepository; import org.junit.Test; +import org.junit.runner.RunWith; import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; -@org.junit.Ignore // see FINERACT-776 +@RunWith(MockitoJUnitRunner.class) public class TopicTest { @Mock @@ -64,18 +67,10 @@ public class TopicTest { public void testTopicStorage() { Office office = officeRepository.getOne(1L); Role role = new Role("New Member_Type", "Testing topic creation"); + Topic topic = topicRepository.getOne(1L); - String title = role.getName() + " of " + office.getName(); - Long entityId = office.getId(); - 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); + lenient().when(this.officeRepository.getOne(1L)).thenReturn(office); + lenient().when(this.topicRepository.getOne(1L)).thenReturn(topic); when(this.roleRepository.save(role)).thenReturn(role); when(this.topicWritePltfService.create(refEq(topic))).thenReturn(1L); @@ -90,13 +85,13 @@ public class TopicTest { @Test public void testTopicSubscriberStorage() { - AppUser user = appUserRepository.findById(1L).get(); - Topic topic = topicRepository.findById(1L).get(); + AppUser user = appUserRepository.getOne(1L); + Topic topic = topicRepository.getOne(1L); TopicSubscriber topicSubscriber = new TopicSubscriber(topic, user, new Date()); - when(this.appUserRepository.getOne(1L)).thenReturn(user); - when(this.topicRepository.getOne(1L)).thenReturn(topic); + lenient().when(this.appUserRepository.getOne(1L)).thenReturn(user); + lenient().when(this.topicRepository.getOne(1L)).thenReturn(topic); when(this.topicSubscriberWritePltfService.create(refEq(topicSubscriber))).thenReturn(1L); Long subscriberId = this.topicSubscriberWritePltfService.create(topicSubscriber);