Skip to content

Instantly share code, notes, and snippets.

Lenar Badretdinov LenarBad

Block or report user

Report or block LenarBad

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
LenarBad /
Created Jun 14, 2018
JUnit data providers for Spring
import static java.lang.Character.toUpperCase;
import java.util.ArrayList;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.manipulation.Filter;
import org.junit.runner.manipulation.NoTestsRemainException;
View Jenkins build periodically

Build every hour:
H * * * *

Build every 20 minutes:
H/20 * * * *

Build every 20 minutes 2am to 11pm:
H/20 5-23 * * *

Build every 20 minutes, work time/days (8am-6pm, MON-FRI) only:
H/20 8-18 * * 1-5

Build every hour MON-WED and FRI only:
H * * * 1-3,5

LenarBad /
Last active May 14, 2018
Spring Boot + JUnit minimal required code
package io.lenar.examples.junitspringboot.tests;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
View Selenium WebDriver. Replace
String script = "arguments[0].innerHTML='" + StringEscapeUtils.escapeEcmaScript(innerHtml) + "'";
((JavascriptExecutor) driver).executeScript(script, webElement);
LenarBad / Selenium WebDriver open local
Created Apr 27, 2018
Selenium WebDriver - open a local html file. The file should be placed in the resources folder
View Selenium WebDriver open local
String path = this.getClass().getResource("/my-local-form-page.html").getPath();
driver.get("file://" + path);
LenarBad / Spring Boot + TestNG -
Last active May 7, 2018
BaseIT class for Spring Booot and TestNG tests
View Spring Boot + TestNG -
package io.lenar.examples.spring.start;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest(classes = TestNGWithSpringApplication.class)
public class BaseIT extends AbstractTestNGSpringContextTests {
// Common methods, variables and constants
LenarBad /
Created Mar 5, 2018
How to mount a VirtualBox shared folder
sudo mount -t vboxsf hostfolder guestFolder
LenarBad /
Last active Mar 1, 2018
AspectJ. How to log method invocation and print parameters as name:value map from ProceedingJoinPoint for TestNG tests
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
import org.testng.Reporter;
LenarBad / ServiceClientExampleIT
Last active Mar 2, 2018
Service Client - Usage in Tests
View ServiceClientExampleIT
@SpringBootTest(classes = TestNGWithSpringApplication.class)
public class BookServiceClientExampleIT extends AbstractTestNGSpringContextTests {
BookServiceClient client;
public void createUpdateDeleteScenarioTest() throws IOException {
Book createdBook = client.createBook(new Book("Title", "Author")).dto();
String id = createdBook.getId();
LenarBad /
Last active Feb 27, 2018
Response Classes for service Client
public class Response {
private ResponseStatus status;
public Response(HttpResponse httpResponse) {
this.status = new ResponseStatus(httpResponse);
public ResponseStatus getStatus() {
return status;
You can’t perform that action at this time.