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
LenarBad / SpringDataProviderRunner.java
Created Jun 14, 2018
JUnit data providers for Spring
View SpringDataProviderRunner.java
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 examples.md

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
LenarBad / JUnitWithSpringBootExampleIT.java
Last active May 14, 2018
Spring Boot + JUnit minimal required code
View JUnitWithSpringBootExampleIT.java
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 innerHtml.java
String script = "arguments[0].innerHTML='" + StringEscapeUtils.escapeEcmaScript(innerHtml) + "'";
((JavascriptExecutor) driver).executeScript(script, webElement);
@LenarBad
LenarBad / Selenium WebDriver open local file.java
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 file.java
String path = this.getClass().getResource("/my-local-form-page.html").getPath();
driver.get("file://" + path);
driver.findElement(By.id("button")).click();
@LenarBad
LenarBad / Spring Boot + TestNG - BaseIT.java
Last active May 7, 2018
BaseIT class for Spring Booot and TestNG tests
View Spring Boot + TestNG - BaseIT.java
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
LenarBad / mount.sh
Created Mar 5, 2018
How to mount a VirtualBox shared folder
View mount.sh
sudo mount -t vboxsf hostfolder guestFolder
@LenarBad
LenarBad / Logger.java
Last active Mar 1, 2018
AspectJ. How to log method invocation and print parameters as name:value map from ProceedingJoinPoint for TestNG tests
View Logger.java
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
LenarBad / ServiceClientExampleIT
Last active Mar 2, 2018
Service Client - Usage in Tests
View ServiceClientExampleIT
@SpringBootTest(classes = TestNGWithSpringApplication.class)
public class BookServiceClientExampleIT extends AbstractTestNGSpringContextTests {
@Autowired
BookServiceClient client;
@Test
public void createUpdateDeleteScenarioTest() throws IOException {
Book createdBook = client.createBook(new Book("Title", "Author")).dto();
String id = createdBook.getId();
@LenarBad
LenarBad / ResponseClassesForServiceClient.java
Last active Feb 27, 2018
Response Classes for service Client
View ResponseClassesForServiceClient.java
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.