| 37181 |
amit |
1 |
package com.spice.profitmandi.service;
|
|
|
2 |
|
|
|
3 |
import com.spice.profitmandi.dao.entity.user.AgendaInstance;
|
|
|
4 |
import com.spice.profitmandi.dao.enumuration.dtr.AgendaSource;
|
|
|
5 |
import com.spice.profitmandi.dao.enumuration.dtr.AgendaType;
|
|
|
6 |
import org.junit.Test;
|
|
|
7 |
|
|
|
8 |
import java.util.ArrayList;
|
|
|
9 |
import java.util.List;
|
|
|
10 |
import java.util.stream.Collectors;
|
|
|
11 |
|
|
|
12 |
import static org.junit.Assert.assertEquals;
|
|
|
13 |
|
|
|
14 |
public class AgendaVisibilityFilterTest {
|
|
|
15 |
|
|
|
16 |
private static AgendaInstance inst(AgendaType type, AgendaSource source) {
|
|
|
17 |
AgendaInstance ai = new AgendaInstance();
|
|
|
18 |
ai.setAgendaType(type.name());
|
|
|
19 |
ai.setSource(source.name());
|
|
|
20 |
ai.setStatus("OPEN");
|
|
|
21 |
return ai;
|
|
|
22 |
}
|
|
|
23 |
|
|
|
24 |
private static List<String> types(List<AgendaInstance> list) {
|
|
|
25 |
return list.stream().map(AgendaInstance::getAgendaType).collect(Collectors.toList());
|
|
|
26 |
}
|
|
|
27 |
|
|
|
28 |
@Test
|
|
|
29 |
public void revivalHidesDataDrivenAgendasExceptCreditDues() {
|
|
|
30 |
List<AgendaInstance> open = new ArrayList<>();
|
|
|
31 |
open.add(inst(AgendaType.REVIVAL, AgendaSource.AUTO));
|
|
|
32 |
open.add(inst(AgendaType.LOW_SALES, AgendaSource.AUTO));
|
|
|
33 |
open.add(inst(AgendaType.LOW_PURCHASE, AgendaSource.AUTO));
|
|
|
34 |
open.add(inst(AgendaType.LOW_INVESTMENT, AgendaSource.AUTO));
|
|
|
35 |
open.add(inst(AgendaType.CREDIT_DUES, AgendaSource.AUTO));
|
|
|
36 |
open.add(inst(AgendaType.BRAND_ADDITION, AgendaSource.MANUAL));
|
|
|
37 |
|
|
|
38 |
List<AgendaInstance> visible = AgendaInstanceServiceImpl.filterVisibleForVisitStatic(open);
|
|
|
39 |
List<String> t = types(visible);
|
|
|
40 |
assertEquals(3, visible.size());
|
|
|
41 |
assertEquals(true, t.contains(AgendaType.REVIVAL.name()));
|
|
|
42 |
assertEquals(true, t.contains(AgendaType.CREDIT_DUES.name()));
|
|
|
43 |
assertEquals(true, t.contains(AgendaType.BRAND_ADDITION.name())); // MANUAL always shows
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
@Test
|
|
|
47 |
public void noRevivalShowsEverything() {
|
|
|
48 |
List<AgendaInstance> open = new ArrayList<>();
|
|
|
49 |
open.add(inst(AgendaType.LOW_SALES, AgendaSource.AUTO));
|
|
|
50 |
open.add(inst(AgendaType.LOW_INVESTMENT, AgendaSource.AUTO));
|
|
|
51 |
assertEquals(2, AgendaInstanceServiceImpl.filterVisibleForVisitStatic(open).size());
|
|
|
52 |
}
|
|
|
53 |
}
|