Skip to content

Instantly share code, notes, and snippets.

@rhamedy
rhamedy / UtilityTest.java
Created September 24, 2020 01:29
Generated unit tests by Diffblue Cover plugin
package com.diffblue.demo;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
public class UtilityTest {
@rhamedy
rhamedy / StudentController.java
Created September 26, 2020 02:17
A sample spring boot controller with a bunch of endpoints
/**
* A Sample Controller that exposes a bunch of endpoints that allow operations
* such as CREATE, READ, DELETE and LIST users.
*
* @author Rafiullah Hamedy
*/
package com.sampleservice.demo.controller;
import java.util.*;
@rhamedy
rhamedy / StudentServiceImpl.java
Created September 26, 2020 02:19
A sample spring boot service layer with a bunch of methods
package com.sampleservice.demo.service;
import com.sampleservice.demo.validator.StudentValidator;
import com.sampleservice.demo.dao.StudentDAO;
import com.sampleservice.demo.model.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Collection;
@rhamedy
rhamedy / StudentControllerTest.java
Created September 26, 2020 02:43
Unit tests generated by AI-powered Diffblue Cover plugin
package com.sampleservice.demo.controller;
import static org.mockito.AdditionalMatchers.or;
import static org.mockito.Mockito.isA;
import static org.mockito.Mockito.isNull;
import static org.mockito.Mockito.when;
import com.sampleservice.demo.dto.inbound.StudentInDTO;
import com.sampleservice.demo.model.Student;
import com.sampleservice.demo.service.StudentServiceImpl;
@rhamedy
rhamedy / StudentValidator.java
Created September 27, 2020 01:58
A Generic validator for getById type of methods from Spring Data
package com.sampleservice.demo.validator;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ResponseStatusException;
import java.util.Optional;
@Component
public class StudentValidator {
@rhamedy
rhamedy / Dockerfile
Created April 18, 2021 21:45
Sample Flask App - Ping Service
FROM python:3.8-slim-buster
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
ENTRYPOINT [ "python" ]
CMD [ "app.py" ]
@rhamedy
rhamedy / Dockerfile
Created April 18, 2021 21:56
Sample Flask App - Ping Service
FROM python:3.8-slim-buster
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
ENTRYPOINT [ "python" ]
CMD [ "app.py" ]