use of org.talend.dataprep.upgrade.model.UpgradeTask in project data-prep by Talend.
the class UpgradeServiceTest method shouldNotApplyUserTasks.
@Test
public void shouldNotApplyUserTasks() throws Exception {
// given
tasks.add(new MockUpgradeTask("1.3-PE", "first", 1, USER));
tasks.add(new MockUpgradeTask("1.4-EE", "second", 2, USER));
tasks.add(new MockUpgradeTask("2.5-PE", "third", 3, USER));
tasks.add(new MockUpgradeTask("12.3-EE", "fourth", 4, USER));
tasks.add(new MockUpgradeTask("50.4-PE", "fifth", 5, USER));
tasks.add(new MockUpgradeTask("2.12.0-EE", "sixth", 6, USER));
tasks.add(new MockUpgradeTask("10.5.0-EE", "seventh", 7, USER));
// when
when(repository.isAlreadyApplied(anyString(), any())).thenReturn(true);
service.upgradeUser("Mr Anonymous");
// then
for (UpgradeTask task : tasks) {
final MockUpgradeTask mockTask = (MockUpgradeTask) task;
assertFalse(mockTask.applied);
}
}
use of org.talend.dataprep.upgrade.model.UpgradeTask in project data-prep by Talend.
the class UpgradeServiceTest method shouldSortTasks.
@Test
public void shouldSortTasks() throws Exception {
// given
// 4
tasks.add(new MockUpgradeTask("12.3-EE", "fourth", 4, USER));
// 2
tasks.add(new MockUpgradeTask("1.4-EE", "second", 2, USER));
// 6
tasks.add(new MockUpgradeTask("75.12.0-EE", "sixth", 6, USER));
// 7
tasks.add(new MockUpgradeTask("100.5.0-EE", "seventh", 7, USER));
// 3
tasks.add(new MockUpgradeTask("2.5-PE", "third", 3, USER));
// 1
tasks.add(new MockUpgradeTask("1.3-PE", "first", 1, USER));
// 5
tasks.add(new MockUpgradeTask("50.4-PE", "fifth", 5, USER));
// when
service.sortAndCheckTasks();
// then
int i = 1;
for (UpgradeTask task : tasks) {
assertEquals(i, task.getId().getOrder());
i++;
}
}
use of org.talend.dataprep.upgrade.model.UpgradeTask in project data-prep by Talend.
the class UpgradeServiceTest method shouldApplyTasksToUser.
@Test
public void shouldApplyTasksToUser() throws Exception {
// given
List<UpgradeTask> expected = new ArrayList<>();
expected.add(new MockUpgradeTask("1.2.0-PE", "1.2.0-first", 1, USER));
expected.add(new MockUpgradeTask("1.2.0-PE", "1.2.0-second", 2, USER));
expected.add(new MockUpgradeTask("1.2.0-PE", "1.2.0-third", 3, USER));
expected.add(new MockUpgradeTask("1.3.0-PE", "1.3.0-1-fourth", 1, USER));
expected.add(new MockUpgradeTask("1.4.0-PE", "1.4.0-twelfth", 12, USER));
expected.add(new MockUpgradeTask("2.12.0-EE", "2.12.0-fourth", 4, USER));
expected.add(new MockUpgradeTask("10.5.0-EE", "2.12.0-fifth", 5, USER));
List<UpgradeTask> unexpected = new ArrayList<>();
unexpected.add(new MockUpgradeTask("1.2.0-PE", "1.2.0-second", 2, VERSION));
unexpected.add(new MockUpgradeTask("1.3.0-PE", "1.3.0-1-fifth", 5, VERSION));
unexpected.add(new MockUpgradeTask("1.4.0-PE", "1.4.0-eleventh", 11, VERSION));
unexpected.add(new MockUpgradeTask("2.12.0-EE", "2.12.0-third", 3, VERSION));
tasks.addAll(expected);
tasks.addAll(unexpected);
// when
when(repository.isAlreadyApplied(anyString(), any())).thenReturn(false);
service.upgradeUser("Mr Anonymous");
// then
for (UpgradeTask task : expected) {
final MockUpgradeTask mockTask = (MockUpgradeTask) task;
assertTrue(mockTask.applied);
}
for (UpgradeTask task : unexpected) {
final MockUpgradeTask mockTask = (MockUpgradeTask) task;
assertFalse(mockTask.applied);
}
}
use of org.talend.dataprep.upgrade.model.UpgradeTask in project data-prep by Talend.
the class UpgradeServiceTest method shouldAllowUpgrade.
@Test
public void shouldAllowUpgrade() {
// given
when(repository.countUpgradeTask(anyString())).thenReturn(0);
final UpgradeTask upgradeTask = mock(UpgradeTask.class);
when(upgradeTask.getTarget()).thenReturn(VERSION);
service.setTasks(Collections.singletonList(upgradeTask));
// when
assertTrue(service.needUpgrade());
}
Aggregations