Skip to content

Commit

Permalink
[testsuite] Added test paths, fixed building blocks
Browse files Browse the repository at this point in the history
Signed-off-by: Alessandro Tundo <alessandrotundo94@gmail.com>
  • Loading branch information
aletundo committed Jul 17, 2018
1 parent 96aeb0f commit ab25a89
Show file tree
Hide file tree
Showing 7 changed files with 535 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
public interface Consumer<T> {
void consume(T t);
CountDownLatch getLatch();
void setLatch(CountDownLatch latch);
List<T> getMessages();
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class NotificationConsumerImpl implements Consumer<NotificationMessage> {
@Autowired
public NotificationConsumerImpl() {
this.messages = new LinkedList<>();
this.latch = new CountDownLatch(1);
this.latch = new CountDownLatch(6);
}

@StreamListener(TestConfigurationStream.NOTIFICATIONS_INPUT)
Expand Down
3 changes: 2 additions & 1 deletion testsuite/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ spring:
kafka:
binder:
brokers: kafka
zkNodes: kafka
# zkNodes: kafka
autoAddPartitions: true
bindings:
analyses-in:
group: testsuiteGroup
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,25 @@ public ResponseEntity<String> createValidConfiguration(String projectId, String
return response;
}

public void createInvalidConfiguration() throws RestClientException, IOException, InterruptedException {
public void attemptToCreateConfigurationWithNullArcanParameters(String projectId, String versionId) throws RestClientException, IOException, InterruptedException {
ObjectNode jsonObject = objectMapper.getNodeFactory().objectNode()
.put("projectId", "")
.put("versionId", "5b25722975a5270001416618");

.put("projectId", projectId)
.put("versionId", versionId);

ResponseEntity<String> response = analysesConfiguratorServiceClient.createConfiguration(jsonObject);

HttpStatus status = response.getStatusCode();
HttpHeaders headers = response.getHeaders();

assertThat(status).isEqualTo(HttpStatus.BAD_REQUEST);
assertThat(headers.getLocation()).isNull();
}

public void attemptToCreateConfigurationWithInvalidProjectIdOrInvalidVersionId(String projectId, String versionId) throws RestClientException, IOException, InterruptedException {
ObjectNode jsonObject = objectMapper.getNodeFactory().objectNode()
.put("projectId", projectId)
.put("versionId", versionId);

ObjectNode parametersNode = objectMapper.getNodeFactory().objectNode().put("inputMode", "jarsFolderMode");

jsonObject.set("arcanParameters", parametersNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public ResponseEntity<String> createStartNowAnalysisWithValidConfig(String confi
return response;
}

public void createStartNowAnalysisWithInvalidConfig() throws JsonProcessingException {
public void attempToCreateStartNowAnalysisWithInvalidConfig() throws JsonProcessingException {

ObjectNode configurationObject = objectMapper.getNodeFactory().objectNode().put("configurationId", "");

Expand Down Expand Up @@ -111,7 +111,7 @@ public ResponseEntity<String> createScheduledAnalysisWithValidConfigAndValidStar
return response;
}

public void createScheduledAnalysisWithInvalidConfigAndValidStartTime() throws JsonProcessingException {
public void attempToCreateScheduledAnalysisWithInvalidConfigAndValidStartTime() throws JsonProcessingException {
ObjectNode configurationObject = objectMapper.getNodeFactory().objectNode().put("configurationId", "");

ObjectNode jsonObject = objectMapper.getNodeFactory().objectNode();
Expand All @@ -127,7 +127,7 @@ public void createScheduledAnalysisWithInvalidConfigAndValidStartTime() throws J
assertThat(status).isEqualTo(HttpStatus.BAD_REQUEST);
}

public void createScheduledAnalysisWithValidConfigAndInvalidStartTime(String configurationId) throws JsonProcessingException {
public void attempToCreateScheduledAnalysisWithValidConfigAndInvalidStartTime(String configurationId) throws JsonProcessingException {

ObjectNode configurationObject = objectMapper.getNodeFactory().objectNode().put("id", configurationId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
Expand Down Expand Up @@ -59,10 +60,10 @@ public void createInvalidProject() throws IOException, InterruptedException {
assertThat(headers.getLocation()).isNull();
}

public ResponseEntity<String> createValidProjectVersion(String projectId) throws IOException {
public ResponseEntity<String> createValidProjectVersion(String projectId, String versionName, String versionDescription) throws IOException {
ObjectNode jsonObject = objectMapper.getNodeFactory().objectNode();

ObjectNode versionObject = objectMapper.getNodeFactory().objectNode().put("name", "TestVersion").put("description", "A beautiful version description");
ObjectNode versionObject = objectMapper.getNodeFactory().objectNode().put("name", versionName).put("description", versionDescription);
ArrayNode versionsArray = objectMapper.getNodeFactory().arrayNode();
versionsArray.add(versionObject);
jsonObject.set("versions", versionsArray);
Expand All @@ -75,16 +76,16 @@ public ResponseEntity<String> createValidProjectVersion(String projectId) throws
assertThat(status).isEqualTo(HttpStatus.OK);
assertThat(body.at("/versions").isArray()).isEqualTo(true);
assertThat(body.at("/versions").size()).isEqualTo(1);
assertThat(body.at("/versions/0/name").asText()).isEqualTo("TestVersion");
assertThat(body.at("/versions/0/description").asText()).isEqualTo("A beautiful version description");
assertThat(body.at("/versions/0/name").asText()).isEqualTo(versionName);
assertThat(body.at("/versions/0/description").asText()).isEqualTo(versionDescription);

return response;
}

public void createInvalidProjectVersion(String projectId) throws IOException {
public void attemptToCreateProjectVersionWithInvalidVersionFields(String projectId, String versionName, String versionDescription) throws IOException {
ObjectNode jsonObject = objectMapper.getNodeFactory().objectNode();

ObjectNode versionObject = objectMapper.getNodeFactory().objectNode().put("name", "TestVersion");
ObjectNode versionObject = objectMapper.getNodeFactory().objectNode().put("name", versionName).put("description", versionDescription);
ArrayNode versionsArray = objectMapper.getNodeFactory().arrayNode();
versionsArray.add(versionObject);
jsonObject.set("versions", versionsArray);
Expand All @@ -96,13 +97,36 @@ public void createInvalidProjectVersion(String projectId) throws IOException {
assertThat(status).isEqualTo(HttpStatus.BAD_REQUEST);
}

public void uploadValidArtefactsZipWithInvalidProjectVersion(String projectId) throws IOException {
public void attempToCreateProjectVersionWithInvalidProjectId(String projectId, String versionName, String versionDescription) throws JsonProcessingException {
ObjectNode jsonObject = objectMapper.getNodeFactory().objectNode();

ObjectNode versionObject = objectMapper.getNodeFactory().objectNode().put("name", versionName).put("description", versionDescription);
ArrayNode versionsArray = objectMapper.getNodeFactory().arrayNode();
versionsArray.add(versionObject);
jsonObject.set("versions", versionsArray);

ResponseEntity<String> response = projectsServiceServiceClient.createVersion(projectId, jsonObject);

HttpStatus status = response.getStatusCode();

assertThat(status).isEqualTo(HttpStatus.NOT_FOUND);

}

public void uploadValidArtefactsZipWithInvalidProjectVersion(String projectId, String versionId) throws IOException {
File file = new ClassPathResource("validZip.zip").getFile();
ResponseEntity<String> response = projectsServiceServiceClient.uploadVersionArtefactsZip(projectId, "invalidProjectVersion", file, false);
ResponseEntity<String> response = projectsServiceServiceClient.uploadVersionArtefactsZip(projectId, versionId, file, false);
HttpStatus status = response.getStatusCode();
assertThat(status).isEqualTo(HttpStatus.BAD_REQUEST);
}

public void uploadValidArtefactsZipWithInvalidProjectId(String projectId, String versionId) throws IOException {
File file = new ClassPathResource("validZip.zip").getFile();
ResponseEntity<String> response = projectsServiceServiceClient.uploadVersionArtefactsZip(projectId, versionId, file, false);
HttpStatus status = response.getStatusCode();
assertThat(status).isEqualTo(HttpStatus.NOT_FOUND);
}

public ResponseEntity<String> uploadValidArtefactsZip(String projectId, String versionId) throws IOException {
File file = new ClassPathResource("validZip.zip").getFile();
ResponseEntity<String> response = projectsServiceServiceClient.uploadVersionArtefactsZip(projectId, versionId, file, false);
Expand Down

0 comments on commit ab25a89

Please sign in to comment.