Skip to content

Commit

Permalink
Merge branch 'developer'
Browse files Browse the repository at this point in the history
  • Loading branch information
abainczyk committed Jun 14, 2018
2 parents 3782b37 + 1ada515 commit 38aadc9
Show file tree
Hide file tree
Showing 23 changed files with 127 additions and 32 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# ALEX 1.5.1

This release only contains some bug fixes.


# ALEX 1.5.0

## Breaking Changes
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Make sure you have Java 8 installed on your system.
We advise to use a modern web browser like Google Chrome, Mozilla Firefox or Microsoft Edge with JavaScript enabled.

1. [Download](https://github.com/LearnLib/alex/releases/latest) the latest version.
2. Open a terminal and start ALEX via `java -jar alex-1.5.0.war [--alex.port=XXXX]`.
2. Open a terminal and start ALEX via `java -jar alex-1.5.1.war [--alex.port=XXXX]`.
3. Wait until the command line prints something like `de.learnlib.alex.App - Started App in XX.XXX seconds`.
3. Open *http://localhost:8000* in a web browser.

Expand Down Expand Up @@ -48,7 +48,7 @@ cd alex
mvn install package [-DskipTests]
```

The bundle can then be found at `build/target/alex-build-1.5.0.war`.
The bundle can then be found at `build/target/alex-build-1.5.1.war`.

## Further reading

Expand Down
2 changes: 1 addition & 1 deletion backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>de.learnlib.alex</groupId>
<artifactId>alex-parent</artifactId>
<version>1.5.0</version>
<version>1.5.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import de.learnlib.alex.learning.entities.LearnerResult;
import de.learnlib.alex.learning.repositories.LearnerResultRepository;
import de.learnlib.alex.testing.entities.TestSuite;
import de.learnlib.alex.testing.repositories.TestReportRepository;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
Expand Down Expand Up @@ -68,6 +69,9 @@ public class ProjectDAOImpl implements ProjectDAO {
/** The repository for learner results. */
private LearnerResultRepository learnerResultRepository;

/** The repository for test reports. */
private TestReportRepository testReportRepository;

/** The FileDAO to use. Will be injected. */
private FileDAO fileDAO;

Expand All @@ -85,14 +89,17 @@ public class ProjectDAOImpl implements ProjectDAO {
* The FileDAO to use.
* @param projectUrlDAO
* The ProjectUrlDAO to use.
* @param testReportRepository
* The repository for test reports.
*/
@Inject
public ProjectDAOImpl(ProjectRepository projectRepository, LearnerResultRepository learnerResultRepository,
@Lazy FileDAO fileDAO, @Lazy ProjectUrlDAO projectUrlDAO) {
TestReportRepository testReportRepository, @Lazy FileDAO fileDAO, @Lazy ProjectUrlDAO projectUrlDAO) {
this.projectRepository = projectRepository;
this.learnerResultRepository = learnerResultRepository;
this.fileDAO = fileDAO;
this.projectUrlDAO = projectUrlDAO;
this.testReportRepository = testReportRepository;
}

@Override
Expand All @@ -111,6 +118,10 @@ public Project create(final Project project) throws ValidationException {
testSuite.setProject(project);
project.getTests().add(testSuite);

if (project.getUrls().isEmpty()) {
throw new ValidationException("The project has to have at least one URL.");
}

project.getUrls().forEach(url -> {
url.setId(null);
url.setProject(project);
Expand Down Expand Up @@ -164,6 +175,10 @@ public Project update(User user, Project project) throws NotFoundException, Vali
.collect(Collectors.toList());
projectUrlDAO.checkAccess(user, project, urls);

if (project.getUrls().isEmpty()) {
throw new ValidationException("The project has to have at least one URL.");
}

try {
project.setUser(user);
project.setGroups(projectInDb.getGroups());
Expand Down Expand Up @@ -204,6 +219,8 @@ public void delete(User user, Long projectId) throws NotFoundException {
final Project project = projectRepository.findOne(projectId);
checkAccess(user, project);

testReportRepository.deleteAllByProject_Id(projectId);
learnerResultRepository.deleteAllByProject_Id(projectId);
projectRepository.delete(project);

// delete the project directory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,15 @@ public interface LearnerResultRepository extends JpaRepository<LearnerResult, UU
@SuppressWarnings("checkstyle:methodname")
Long deleteByProject_IdAndTestNoIn(Long projectId, Long... testNos);

/**
* Delete all learner results in a project.
*
* @param projectId
* The ID of the project.
* @return The amount of deleted LearnResults.
*/
@Transactional
@SuppressWarnings("checkstyle:methodname")
Long deleteAllByProject_Id(Long projectId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public Response resume(@PathParam("project_id") long projectId,
* This will always return OK, even if there is nothing to stop.
* To see if there is currently a learning process, the status like '/active' will be returned.
*
* @param projectId The project to stop.
* @param projectId The project to stop.
* @return The status of the current learn process.
* @successResponse 200 OK
* @responseType de.learnlib.alex.learning.entities.LearnerStatus
Expand All @@ -281,8 +281,14 @@ public Response stop(@PathParam("project_id") long projectId) {
User user = ((UserPrincipal) securityContext.getUserPrincipal()).getUser();
LOGGER.traceEntry("stop() for user {}.", user);

try {
projectDAO.getByID(user.getId(), projectId);
} catch (NotFoundException e) {
return ResourceErrorHandler.createRESTErrorMessage("LearnerResource.stop", Status.NOT_FOUND, e);
}

if (learner.isActive(projectId)) {
learner.stop(user); // Hammer Time
learner.stop(projectId); // Hammer Time
} else {
LOGGER.info(RESOURCE_MARKER, "tried to stop the learning again.");
}
Expand All @@ -297,17 +303,16 @@ public Response stop(@PathParam("project_id") long projectId) {
*
* @param projectId The project to get the Status of.
* @return The information of the learning
* @throws NotFoundException If the previous learn job or the related Project could not be found.
* @successResponse 200 OK
* @responseType de.learnlib.alex.learning.entities.LearnerResult
* @errorResponse 404 not found `de.learnlib.alex.common.utils.ResourceErrorHandler.RESTError
*/
@GET
@Path("/{project_id}/status")
@Produces(MediaType.APPLICATION_JSON)
public Response getResult(@PathParam("project_id") long projectId) throws NotFoundException {
public Response getStatus(@PathParam("project_id") long projectId) {
User user = ((UserPrincipal) securityContext.getUserPrincipal()).getUser();
LOGGER.traceEntry("getResult() for user {}.", user);
LOGGER.traceEntry("getStatus() for user {}.", user);

LearnerStatus status = learner.getStatus(projectId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,11 @@ private void validateCounterexample(User user, LearnerResumeConfiguration config
/**
* Ends the learning process after the current step.
*
* @param user The user that wants to stop his active thread.
* @param projectId The id of the project that is learned.
*/
public void stop(User user) {
final AbstractLearnerThread learnerThread = userThreads.get(user);
public void stop(Long projectId) {
final AbstractLearnerThread learnerThread = userThreads.get(projectId);

if (learnerThread != null) {
learnerThread.stopLearning();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,15 @@ public interface TestReportRepository extends JpaRepository<TestReport, Long> {
@Transactional(readOnly = true)
@SuppressWarnings("checkstyle:methodname")
List<TestReport> findAllByProject_Id(Long projectId);

/**
* Delete all test reports by project id.
*
* @param projectId
* The id of the project.
* @return The number of deleted test reports.
*/
@Transactional
@SuppressWarnings("checkstyle:methodname")
Long deleteAllByProject_Id(Long projectId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import de.learnlib.alex.data.entities.SymbolGroup;
import de.learnlib.alex.data.repositories.ProjectRepository;
import de.learnlib.alex.learning.repositories.LearnerResultRepository;
import de.learnlib.alex.testing.repositories.TestReportRepository;
import org.hamcrest.MatcherAssert;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -35,6 +36,7 @@
import javax.persistence.RollbackException;
import javax.validation.ConstraintViolationException;
import javax.validation.ValidationException;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
Expand Down Expand Up @@ -65,11 +67,15 @@ public class ProjectDAOImplTest {
@Mock
private ProjectUrlDAO projectUrlDAO;

@Mock
private TestReportRepository testReportRepository;

private ProjectDAO projectDAO;

@Before
public void setUp() {
projectDAO = new ProjectDAOImpl(projectRepository, learnerResultRepository, fileDAO, projectUrlDAO);
projectDAO = new ProjectDAOImpl(projectRepository, learnerResultRepository, testReportRepository, fileDAO,
projectUrlDAO);
}

@Test
Expand All @@ -91,6 +97,30 @@ public void shouldCreateAValidEmptyProject() {
assertThat(p.getId(), is(equalTo(1L)));
}

@Test(expected = ValidationException.class)
public void shouldNotCreateAProjectIfUrlsAreEmpty() throws NotFoundException {
User user = new User(USER_ID);

Project project = new Project();
project.setId(PROJECT_ID);
project.setUser(user);

projectDAO.create(project);
}

@Test(expected = ValidationException.class)
public void shouldNotUpdateAProjectIfUrlsAreEmpty() throws NotFoundException {
User user = new User(USER_ID);

Project project = new Project();
project.setId(PROJECT_ID);
project.setUser(user);

given(projectRepository.findOne(PROJECT_ID)).willReturn(project);

projectDAO.update(user, project);
}

@Test
public void shouldCreateAValidPreFilledProject() {
SymbolGroup testGroup = new SymbolGroup();
Expand All @@ -111,6 +141,7 @@ public void shouldCreateAValidPreFilledProject() {
@Test(expected = ValidationException.class)
public void shouldHandleConstraintViolationExceptionOnProjectCreationGracefully() {
Project project = new Project();
project.setUrls(Collections.singletonList(new ProjectUrl()));
//
given(projectRepository.save(project)).willThrow(ConstraintViolationException.class);

Expand All @@ -120,6 +151,7 @@ public void shouldHandleConstraintViolationExceptionOnProjectCreationGracefully(
@Test(expected = ValidationException.class)
public void shouldHandleDataIntegrityViolationExceptionOnProjectCreationGracefully() {
Project project = new Project();
project.setUrls(Collections.singletonList(new ProjectUrl()));
//
given(projectRepository.save(project)).willThrow(DataIntegrityViolationException.class);

Expand All @@ -129,6 +161,7 @@ public void shouldHandleDataIntegrityViolationExceptionOnProjectCreationGraceful
@Test(expected = ValidationException.class)
public void shouldHandleTransactionSystemExceptionOnProjectCreationGracefully() {
Project project = new Project();
project.setUrls(Collections.singletonList(new ProjectUrl()));
//
ConstraintViolationException constraintViolationException;
constraintViolationException = new ConstraintViolationException("Project is not valid!", new HashSet<>());
Expand Down Expand Up @@ -218,6 +251,7 @@ public void shouldHandleConstraintViolationExceptionOnProjectUpdateGracefully()
user.setId(USER_ID);

Project project = new Project();
project.setUrls(Collections.singletonList(new ProjectUrl()));
project.setUser(user);
project.setId(PROJECT_ID);

Expand All @@ -235,6 +269,7 @@ public void shouldHandleDataIntegrityViolationExceptionOnProjectUpdateGracefully
Project project = new Project();
project.setUser(user);
project.setId(PROJECT_ID);
project.setUrls(Collections.singletonList(new ProjectUrl()));

given(projectRepository.save(project)).willThrow(DataIntegrityViolationException.class);
given(projectRepository.findOne(PROJECT_ID)).willReturn(project);
Expand All @@ -248,6 +283,7 @@ public void shouldHandleTransactionSystemExceptionOnProjectUpdateGracefully() th
user.setId(USER_ID);

Project project = new Project();
project.setUrls(Collections.singletonList(new ProjectUrl()));
project.setUser(user);
project.setId(PROJECT_ID);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public void shouldStopIfTheLearningIsActive() {
Response response = target("/learner/" + PROJECT_TEST_ID + "/stop").request().header("Authorization", adminToken).get();

assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
verify(learner).stop(admin);
verify(learner).stop(PROJECT_TEST_ID);
}

@Test
Expand All @@ -312,7 +312,7 @@ public void shouldNotStopIfTheLearningIsNotActive() {
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
String expectedJSON = "{\"active\":false}";
assertEquals(expectedJSON, response.readEntity(String.class));
verify(learner, never()).stop(admin);
verify(learner, never()).stop(PROJECT_TEST_ID);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void shouldResumeAThread() throws NotFoundException {

@Test
public void shouldStopAThread() throws NotFoundException {
learner.stop(user);
learner.stop(-1L);
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<artifactId>alex-parent</artifactId>
<groupId>de.learnlib.alex</groupId>
<version>1.5.0</version>
<version>1.5.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion frontend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<artifactId>alex-parent</artifactId>
<groupId>de.learnlib.alex</groupId>
<version>1.5.0</version>
<version>1.5.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
3 changes: 1 addition & 2 deletions frontend/src/main/javascript/environments.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* The version of ALEX.
* @type {string}
*/
export const version = '1.5.0';
export const version = '1.5.1';

/**
* API URL
Expand All @@ -30,4 +30,3 @@ export const version = '1.5.0';
*/
export const apiUrl = '/rest';
// export const apiUrl = 'http://localhost:8000/rest';
//
2 changes: 1 addition & 1 deletion frontend/src/main/javascript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/src/main/javascript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ALEX",
"version": "1.5.0",
"version": "1.5.1",
"description": "A web application for interring Mealy machines of web applications and RESTful web services via active automata learning.",
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ <h3 class="modal-title">Edit project <strong ng-bind="::vm.project.name"></stron
<form name="vm.form" ng-submit="vm.updateProject()">

<div class="modal-body">
<div class="alert alert-danger" ng-if="vm.errorMessage != null">
{{vm.errorMessage}}
</div>

<project-form-groups project="vm.project" form="vm.form"></project-form-groups>

<hr>
Expand Down
Loading

0 comments on commit 38aadc9

Please sign in to comment.