(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
#!/usr/bin/perl | |
# | |
# Pre-commit hook for running checkstyle on changed Java sources | |
# | |
# To use this you need: | |
# 1. checkstyle's jar file somewhere | |
# 2. a checkstyle XML check file somewhere | |
# 3. To configure git: | |
# * git config --add checkstyle.jar <location of jar> | |
# * git config --add checkstyle.checkfile <location of checkfile> |
package object mail { | |
implicit def stringToSeq(single: String): Seq[String] = Seq(single) | |
implicit def liftToOption[T](t: T): Option[T] = Some(t) | |
sealed abstract class MailType | |
case object Plain extends MailType | |
case object Rich extends MailType | |
case object MultiPart extends MailType |
#!/usr/bin/perl | |
# | |
# Pre-commit hook for running checkstyle on changed Java sources | |
# | |
# To use this you need: | |
# 1. checkstyle's jar file somewhere | |
# 2. a checkstyle XML check file somewhere | |
# 3. To configure git: | |
# * git config --add checkstyle.jar <location of jar> | |
# * git config --add checkstyle.checkfile <location of checkfile> |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
import lombok.AllArgsConstructor; | |
import lombok.Data; | |
@Data | |
@AllArgsConstructor | |
public class LazyDeveloper { | |
private String firstName; | |
private String lastName; |
public class ComparingUtils { | |
public static <T extends Comparable<T>> ComparisonBuilder<T> is(T comparable) { | |
return new ComparisonBuilder<>(comparable); | |
} | |
public static class ComparisonBuilder<T> { | |
private Comparable<T> subject; |
/** | |
* | |
* ----------------------------------------------------------------------------------- | |
* From : org.junit.rules.DisableOnDebug#isDebugging(java.util.List<java.lang.String>) | |
* ----------------------------------------------------------------------------------- | |
* | |
* Parses arguments passed to the runtime environment for debug flags | |
* <p> | |
* Options specified in: | |
* <ul> |
/* | |
* | |
* Methods manipulate milliseconds field (fastTime) in java.util.Date object. | |
* | |
* UTC : 12/10/2017 11:15:00 | |
* Local date time : 12/10/2017 14:15:00 +03:00 | |
* | |
* @return new java.util.Date | |
* UTC : 12/10/2017 14:15:00 | |
* Local date time : 12/10/2017 17:15:00 +03:00 |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.mockito.Mockito; | |
import org.powermock.api.mockito.PowerMockito; | |
import org.powermock.core.classloader.annotations.PrepareForTest; | |
import org.powermock.modules.junit4.PowerMockRunner; | |
@RunWith(PowerMockRunner.class) | |
@PrepareForTest(MyFinalClass.class) | |
public class MyFinalClassTest { |
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private NestedObject nestedObject;
example usage in a test method:
when(nestedObject.getStatusInfo().getValue().getStatus()).thenReturn(1);