Skip to content

Instantly share code, notes, and snippets.

View safebear's full-sized avatar

Simon Stratton safebear

View GitHub Profile
@safebear
safebear / cca_maven.txt
Last active June 25, 2018 13:34
CCA Java Course Maven Command
mvn archetype:generate -DgroupId=com.safebear.app -DartifactId=safe-auto -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
@safebear
safebear / TestSuite.java
Created June 25, 2018 13:36
Test Suite class
package com.safebear.app;
@RunWith(Suite.class)
@Suite.SuiteClasses({
Test01_Login.class,
})
public class TestSuite{
}
@safebear
safebear / TestRunner.java
Created June 25, 2018 13:37
Test Runner class
package com.safebear.app;
public class TestRunner{
public static void main(String[] args) {
Result result = JUnitCore.runClasses(TestSuite.class);
for (Failure failure : result.getFailures()){
System.out.println(failure.toString());
}
System.out.println(result.wasSuccessful());
@safebear
safebear / TaskController.java
Created July 8, 2018 21:19
Task Controller - TaskList
package com.safebear.tasklist.controller;
import com.safebear.tasklist.domain.Task;
import com.safebear.tasklist.service.TaskService;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api/tasks")
public class TaskController {
@safebear
safebear / Task.java
Created July 8, 2018 21:23
Task Model File - TaskList
package com.safebear.tasklist.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@safebear
safebear / TaskRepository.java
Created July 8, 2018 21:25
Task Repository Interface - TaskList
package com.safebear.tasklist.repository;
import com.safebear.tasklist.domain.Task;
import org.springframework.data.repository.CrudRepository;
import java.util.List;
public interface TaskRepository extends CrudRepository<Task, Long>{
List<Task> findByName(String name);
@safebear
safebear / TaskService.java
Created July 8, 2018 21:27
Task Service - TaskList
package com.safebear.tasklist.service;
import com.safebear.tasklist.domain.Task;
public interface TaskService {
Iterable<Task> list();
Task save(Task task);
@safebear
safebear / TaskServiceImpl.java
Created July 8, 2018 21:30
Task Service Implementation - Java
package com.safebear.tasklist.service;
import com.safebear.tasklist.domain.Task;
import com.safebear.tasklist.repository.TaskRepository;
import org.springframework.stereotype.Service;
@Service
public class TaskServiceImpl implements TaskService {
private TaskRepository taskRepository;
@safebear
safebear / Jenkinsfile
Created July 10, 2018 08:01
sonarqube
steps {
sh 'mvn clean package sonar:sonar -Dsonar.organization=safebear-student-bitbucket -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=f08a36f3598527bf9b20d9b861b57c0aaa5937e3'
}
@safebear
safebear / StepDefs.java
Last active July 10, 2018 08:25
Using a DataTable in Cucumber
@Given("^the following tasks are created:$")
public void the_following_tasks_are_created(DataTable tasks) {
// Here I'm converting the raw data into a list of lists. The inner list contains the data from a row in the table, while the outer list is the list of rows.
List<List<String>> data = tasks.raw();
// Here I'm checking to see if the first task in the first row (x=0,y=0) has already been created in the system. If it has, then I don't create them.
if (!taskListPage.checkForTask(data.get(0).get(0))) {
// Here I'm iterating through the rows in the table and storing each row in a List called 'task' each time.