TSK-1252: fixed newly introduced code smells

This commit is contained in:
Mustapha Zorgati 2020-05-22 03:48:27 +02:00
parent ab6e5ecc33
commit 7e411d42e1
8 changed files with 28 additions and 32 deletions

View File

@ -313,10 +313,11 @@ class ServiceLevelHandler {
*/ */
private void ensureServiceLevelIsNotViolated( private void ensureServiceLevelIsNotViolated(
TaskImpl task, Duration duration, Instant calcPlanned) throws InvalidArgumentException { TaskImpl task, Duration duration, Instant calcPlanned) throws InvalidArgumentException {
if (task.getPlanned() != null && !task.getPlanned().equals(calcPlanned)) { if (task.getPlanned() != null
&& !task.getPlanned().equals(calcPlanned)
// manual entered planned date is a different working day than computed value // manual entered planned date is a different working day than computed value
if (converter.isWorkingDay(0, task.getPlanned()) && (converter.isWorkingDay(0, task.getPlanned())
|| converter.hasWorkingDaysInBetween(task.getPlanned(), calcPlanned)) { || converter.hasWorkingDaysInBetween(task.getPlanned(), calcPlanned))) {
throw new InvalidArgumentException( throw new InvalidArgumentException(
String.format( String.format(
"Cannot update a task with given planned %s " "Cannot update a task with given planned %s "
@ -324,7 +325,6 @@ class ServiceLevelHandler {
task.getPlanned(), task.getDue(), duration)); task.getPlanned(), task.getDue(), duration));
} }
} }
}
private TaskImpl updatePlannedDueOnCreationOfNewTask( private TaskImpl updatePlannedDueOnCreationOfNewTask(
TaskImpl newTask, DurationPrioHolder durationPrioHolder) throws InvalidArgumentException { TaskImpl newTask, DurationPrioHolder durationPrioHolder) throws InvalidArgumentException {

View File

@ -19,10 +19,10 @@ import pro.taskana.common.internal.TaskanaEngineTestConfiguration;
import pro.taskana.common.internal.configuration.DbSchemaCreator; import pro.taskana.common.internal.configuration.DbSchemaCreator;
import pro.taskana.sampledata.SampleDataGenerator; import pro.taskana.sampledata.SampleDataGenerator;
public class TaskanaSecurityConfigAccTest { class TaskanaSecurityConfigAccTest {
@BeforeEach @BeforeEach
public void cleanDb() throws SQLException { void cleanDb() throws SQLException {
DataSource dataSource = TaskanaEngineTestConfiguration.getDataSource(); DataSource dataSource = TaskanaEngineTestConfiguration.getDataSource();
String schemaName = TaskanaEngineTestConfiguration.getSchemaName(); String schemaName = TaskanaEngineTestConfiguration.getSchemaName();
@ -33,7 +33,7 @@ public class TaskanaSecurityConfigAccTest {
} }
@Test @Test
public void should_ThrowException_When_CreatingUnsecuredEngineCfgWhileSecurityIsEnforced() void should_ThrowException_When_CreatingUnsecuredEngineCfgWhileSecurityIsEnforced()
throws SQLException { throws SQLException {
setSecurityFlag(true); setSecurityFlag(true);
@ -54,7 +54,7 @@ public class TaskanaSecurityConfigAccTest {
} }
@Test @Test
public void should_StartUpNormally_When_CreatingUnsecuredEngineCfgWhileSecurityIsNotEnforced() void should_StartUpNormally_When_CreatingUnsecuredEngineCfgWhileSecurityIsNotEnforced()
throws SQLException { throws SQLException {
setSecurityFlag(false); setSecurityFlag(false);
@ -73,7 +73,7 @@ public class TaskanaSecurityConfigAccTest {
} }
@Test @Test
public void should_SetSecurityFlagToFalse_When_CreatingUnsecureEngineCfgAndSecurityFlagIsNotSet() void should_SetSecurityFlagToFalse_When_CreatingUnsecureEngineCfgAndSecurityFlagIsNotSet()
throws SQLException { throws SQLException {
assertThat(retrieveSecurityFlag()).isNull(); assertThat(retrieveSecurityFlag()).isNull();
@ -94,7 +94,7 @@ public class TaskanaSecurityConfigAccTest {
} }
@Test @Test
public void should_SetSecurityFlagToTrue_When_CreatingSecureEngineCfgAndSecurityFlagIsNotSet() void should_SetSecurityFlagToTrue_When_CreatingSecureEngineCfgAndSecurityFlagIsNotSet()
throws SQLException { throws SQLException {
assertThat(retrieveSecurityFlag()).isNull(); assertThat(retrieveSecurityFlag()).isNull();

View File

@ -15,7 +15,7 @@ import pro.taskana.workbasket.api.models.WorkbasketAccessItem;
/** Acceptance test for all "set workbasket access item" scenarios. */ /** Acceptance test for all "set workbasket access item" scenarios. */
@ExtendWith(JaasExtension.class) @ExtendWith(JaasExtension.class)
public class CreateWorkbasketAuthorizationsAccTest extends AbstractAccTest { class CreateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
@WithAccessId(user = "user_1_1") @WithAccessId(user = "user_1_1")
@WithAccessId(user = "taskadmin") @WithAccessId(user = "taskadmin")

View File

@ -14,12 +14,12 @@ import pro.taskana.workbasket.api.WorkbasketService;
/** Acceptance test for all "delete workbasket authorizations" scenarios. */ /** Acceptance test for all "delete workbasket authorizations" scenarios. */
@ExtendWith(JaasExtension.class) @ExtendWith(JaasExtension.class)
public class DeleteWorkbasketAuthorizationsAccTest extends AbstractAccTest { class DeleteWorkbasketAuthorizationsAccTest extends AbstractAccTest {
@WithAccessId(user = "user_1_1") @WithAccessId(user = "user_1_1")
@WithAccessId(user = "taskadmin") @WithAccessId(user = "taskadmin")
@TestTemplate @TestTemplate
public void should_ThrowException_When_UserRoleIsNotAdminOrBusinessAdmin() { void should_ThrowException_When_UserRoleIsNotAdminOrBusinessAdmin() {
final WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); final WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();

View File

@ -14,12 +14,12 @@ import pro.taskana.workbasket.api.WorkbasketService;
/** Acceptance test for all "get workbasket authorizations" scenarios. */ /** Acceptance test for all "get workbasket authorizations" scenarios. */
@ExtendWith(JaasExtension.class) @ExtendWith(JaasExtension.class)
public class GetWorkbasketAuthorizationsAccTest extends AbstractAccTest { class GetWorkbasketAuthorizationsAccTest extends AbstractAccTest {
@WithAccessId(user = "user_1_1") @WithAccessId(user = "user_1_1")
@WithAccessId(user = "taskadmin") @WithAccessId(user = "taskadmin")
@TestTemplate @TestTemplate
public void should_ThrowException_When_UserRoleIsNotAdminOrBusinessAdmin() { void should_ThrowException_When_UserRoleIsNotAdminOrBusinessAdmin() {
final WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); final WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();

View File

@ -23,17 +23,13 @@ import pro.taskana.workbasket.internal.models.WorkbasketImpl;
/** Acceptance test for all "update workbasket" scenarios. */ /** Acceptance test for all "update workbasket" scenarios. */
@ExtendWith(JaasExtension.class) @ExtendWith(JaasExtension.class)
public class UpdateWorkbasketAccTest extends AbstractAccTest { class UpdateWorkbasketAccTest extends AbstractAccTest {
public UpdateWorkbasketAccTest() {
super();
}
@WithAccessId( @WithAccessId(
user = "teamlead_1", user = "teamlead_1",
groups = {"group_1", "businessadmin"}) groups = {"group_1", "businessadmin"})
@Test @Test
public void testUpdateWorkbasket() void testUpdateWorkbasket()
throws NotAuthorizedException, WorkbasketNotFoundException, ConcurrencyException { throws NotAuthorizedException, WorkbasketNotFoundException, ConcurrencyException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.getWorkbasket("GPK_KSC", "DOMAIN_A"); Workbasket workbasket = workbasketService.getWorkbasket("GPK_KSC", "DOMAIN_A");
@ -67,7 +63,7 @@ public class UpdateWorkbasketAccTest extends AbstractAccTest {
user = "teamlead_1", user = "teamlead_1",
groups = {"group_1", "businessadmin"}) groups = {"group_1", "businessadmin"})
@Test @Test
public void testUpdateWorkbasketWithConcurrentModificationShouldThrowException() void testUpdateWorkbasketWithConcurrentModificationShouldThrowException()
throws NotAuthorizedException, WorkbasketNotFoundException, ConcurrencyException { throws NotAuthorizedException, WorkbasketNotFoundException, ConcurrencyException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
@ -85,7 +81,7 @@ public class UpdateWorkbasketAccTest extends AbstractAccTest {
user = "teamlead_1", user = "teamlead_1",
groups = {"group_1", "businessadmin"}) groups = {"group_1", "businessadmin"})
@Test @Test
public void testUpdateWorkbasketOfNonExistingWorkbasketShouldThrowException() void testUpdateWorkbasketOfNonExistingWorkbasketShouldThrowException()
throws NotAuthorizedException, WorkbasketNotFoundException, ConcurrencyException { throws NotAuthorizedException, WorkbasketNotFoundException, ConcurrencyException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
@ -103,7 +99,7 @@ public class UpdateWorkbasketAccTest extends AbstractAccTest {
@WithAccessId(user = "user_1_1", groups = "group_1") @WithAccessId(user = "user_1_1", groups = "group_1")
@WithAccessId(user = "taskadmin") @WithAccessId(user = "taskadmin")
@TestTemplate @TestTemplate
public void should_ThrowException_When_UserRoleIsNotAdminOrBusinessAdmin() void should_ThrowException_When_UserRoleIsNotAdminOrBusinessAdmin()
throws NotAuthorizedException, WorkbasketNotFoundException { throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.getWorkbasket("USER_1_1", "DOMAIN_A"); Workbasket workbasket = workbasketService.getWorkbasket("USER_1_1", "DOMAIN_A");

View File

@ -40,7 +40,7 @@ class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
@WithAccessId(user = "user_1_1") @WithAccessId(user = "user_1_1")
@WithAccessId(user = "taskadmin") @WithAccessId(user = "taskadmin")
@TestTemplate @TestTemplate
public void should_ThrowException_When_UserIsNotAdminOrBusinessAdmin() { void should_ThrowException_When_UserIsNotAdminOrBusinessAdmin() {
final WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); final WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();

View File

@ -24,7 +24,7 @@ import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
@ExtendWith(JaasExtension.class) @ExtendWith(JaasExtension.class)
public class JaasExtensionTest { class JaasExtensionTest {
private static final String INSIDE_DYNAMIC_TEST_USER = "insidedynamictest"; private static final String INSIDE_DYNAMIC_TEST_USER = "insidedynamictest";
private static final DynamicTest NOT_NULL_DYNAMIC_TEST = private static final DynamicTest NOT_NULL_DYNAMIC_TEST =