Skip to content

Commit

Permalink
more integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anhefti committed Jul 6, 2022
1 parent 43c7cd8 commit a773d6d
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 2 deletions.
2 changes: 1 addition & 1 deletion codecov.yml
@@ -1,7 +1,7 @@
coverage:
precision: 2
round: down
range: "40..80"
range: "30..70"
status:
project:
default:
Expand Down
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2022 ETH Zürich, Educational Development and Technology (LET)
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package ch.ethz.seb.sebserver.gui.service.remote.webservice.api.batch;

import org.springframework.context.annotation.Lazy;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;

import com.fasterxml.jackson.core.type.TypeReference;

import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.api.EntityType;
import ch.ethz.seb.sebserver.gbl.model.BatchAction;
import ch.ethz.seb.sebserver.gbl.model.Page;
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;

@Lazy
@Component
@GuiProfile
public class GetBatchActionPage extends RestCall<Page<BatchAction>> {

public GetBatchActionPage() {
super(new TypeKey<>(
CallType.GET_PAGE,
EntityType.BATCH_ACTION,
new TypeReference<Page<BatchAction>>() {
}),
HttpMethod.GET,
MediaType.APPLICATION_FORM_URLENCODED,
API.BATCH_ACTION_ENDPOINT);
}

}
Expand Up @@ -48,12 +48,15 @@

import ch.ethz.seb.sebserver.gbl.Constants;
import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.api.API.BatchActionType;
import ch.ethz.seb.sebserver.gbl.api.API.BulkActionType;
import ch.ethz.seb.sebserver.gbl.api.APIMessage;
import ch.ethz.seb.sebserver.gbl.api.EntityType;
import ch.ethz.seb.sebserver.gbl.api.JSONMapper;
import ch.ethz.seb.sebserver.gbl.client.ClientCredentials;
import ch.ethz.seb.sebserver.gbl.model.BatchAction;
import ch.ethz.seb.sebserver.gbl.model.Domain;
import ch.ethz.seb.sebserver.gbl.model.Domain.BATCH_ACTION;
import ch.ethz.seb.sebserver.gbl.model.Domain.SEB_CLIENT_CONFIGURATION;
import ch.ethz.seb.sebserver.gbl.model.EntityDependency;
import ch.ethz.seb.sebserver.gbl.model.EntityKey;
Expand Down Expand Up @@ -119,6 +122,9 @@
import ch.ethz.seb.sebserver.gui.service.examconfig.impl.ExamConfigurationServiceImpl;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCallError;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestServiceImpl;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.batch.DoBatchAction;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.batch.GetBatchAction;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.batch.GetBatchActionPage;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.ActivateSEBRestriction;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.CheckExamConsistency;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.CheckExamImported;
Expand Down Expand Up @@ -264,7 +270,7 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest {
@Before
@Sql(scripts = { "classpath:schema-test.sql", "classpath:data-test.sql" })
public void init() {
System.out.println("*** init");
// Nothing
}

@After
Expand Down Expand Up @@ -3878,4 +3884,65 @@ public void testUsecase28_TestExamProctoring() throws IOException {
}
}

@Test
@Order(29)
// *************************************
// Use Case 29: Login as admin and create some batch actions
// - Get Exam (running)
// - start some SEB clients connecting to running exam
// - Check collecting rooms created
public void testUsecase29_TestBatchAction() throws IOException, InterruptedException {
final RestServiceImpl restService = createRestServiceForUser(
"admin",
"admin",
new DoBatchAction(),
new GetBatchAction(),
new GetBatchActionPage(),
new GetExamConfigNodePage());

final ConfigurationNode config = restService
.getBuilder(GetExamConfigNodePage.class)
.call()
.getOrThrow().content
.get(0);
assertNotNull(config);
assertEquals("READY_TO_USE", config.status.toString());

// apply batch action
final Result<BatchAction> doBatchAction = restService
.getBuilder(DoBatchAction.class)
.withFormParam(Domain.BATCH_ACTION.ATTR_ACTION_TYPE, BatchActionType.EXAM_CONFIG_STATE_CHANGE.name())
.withFormParam(BATCH_ACTION.ATTR_SOURCE_IDS, config.getModelId())
.withFormParam(BatchAction.ACTION_ATTRIBUT_TARGET_STATE, ConfigurationStatus.CONSTRUCTION.name())
.call();

assertNotNull(doBatchAction);
assertFalse(doBatchAction.hasError());
final BatchAction batchAction = doBatchAction.get();
assertNotNull(batchAction);
assertNotNull(batchAction.ownerId);
assertFalse(batchAction.isFinished());
assertEquals("EXAM_CONFIG_STATE_CHANGE", batchAction.actionType.name());

Thread.sleep(1000);

final BatchAction savedBatchAction = restService
.getBuilder(GetBatchAction.class)
.withURIVariable(API.PARAM_MODEL_ID, batchAction.getModelId())
.call().get();

assertNotNull(savedBatchAction);
assertNotNull(savedBatchAction.ownerId);
assertTrue(savedBatchAction.isFinished());
assertEquals("EXAM_CONFIG_STATE_CHANGE", savedBatchAction.actionType.name());
assertNotNull(savedBatchAction.processorId);

final Page<BatchAction> page = restService
.getBuilder(GetBatchActionPage.class)
.call().get();

assertNotNull(page);
assertFalse(page.content.isEmpty());
}

}

0 comments on commit a773d6d

Please sign in to comment.