Skip to content

Instantly share code, notes, and snippets.

View mockitoguy's full-sized avatar

Szczepan Faber mockitoguy

View GitHub Profile
@mockitoguy
mockitoguy / urls-plugin-6.0.22.ivy
Created February 7, 2017 00:28
Trimmed ivy file
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0" xmlns:e="http://ant.apache.org/ivy/extra">
<info organisation="com.linkedin.play-plugins" module="urls-plugin" revision="6.0.22" status="release" publication="20161006192214">
<description>
urls-plugin
</description>
</info>
<configurations>
<!-- .... -->
<conf name="compile" visibility="public" description=""/>
@mockitoguy
mockitoguy / UnusedStubbingBugTest.java
Created February 3, 2017 13:43
UnusedStubbingBugTest
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
@mockitoguy
mockitoguy / build.gradle
Created January 29, 2017 15:37
Problems bumping version in version file
:bumpVersion
--- Executing: git commit -m Increment version '2.7.0' -> '2.7.1' by Travis CI build 2301 [ci skip] version.properties
# On branch release/2.x
# Your branch is ahead of 'origin/release/2.x' by 1 commit.
# (use "git push" to publish your local commits)
#
nothing to commit, working directory clean
:bumpVersion FAILED
:unbumpVersion SKIPPED
:removeNewTag
@mockitoguy
mockitoguy / sample.java
Created January 24, 2017 06:24
Example of lenient stubbing in Mockito
//given
List mock = mock(List.class);
given(mock.get(3)).willReturn(“ok”);
//expect
mock.get(1) == null // —> get(1) was not stubbed, returning null by default
mock.get(2) == null // —> get(2) was not stubbed, returning null by default
mock.get(3) == “ok” // —> Yay! get(3) was actually stubbed!
@mockitoguy
mockitoguy / gist:ceccb8206008373d16e86d1c1941143f
Created January 19, 2017 16:33
GradeDaemon jstack hanging composite build
2017-01-19 08:32:55
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.40-b25 mixed mode):
"Attach Listener" #73 daemon prio=9 os_prio=31 tid=0x00007fe15befd000 nid=0x6807 waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"Task worker Thread 7" #57 prio=5 os_prio=31 tid=0x00007fe15c96b000 nid=0x7a0f waiting on condition [0x0000700002733000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000007821c1bc8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
@mockitoguy
mockitoguy / gist:e06adb719a6883914d90bbbeeef443c5
Created January 19, 2017 16:28
Composite build hanging
07:05:24.206 [DEBUG] [com.sun.xml.internal.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory] Using optimized Accessor for protected java.lang.String com.linkedin.ivy.dependencies.Exclude.matcher
07:05:24.206 [DEBUG] [com.sun.xml.internal.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory] Using optimized Accessor for protected java.lang.String com.linkedin.ivy.dependencies.Exclude.matcher
07:05:24.207 [DEBUG] [com.sun.xml.internal.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory] Using optimized Accessor for protected java.math.BigDecimal com.linkedin.ivy.IvyModule.version
07:05:24.207 [DEBUG] [com.sun.xml.internal.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory] Using optimized Accessor for protected java.math.BigDecimal com.linkedin.ivy.IvyModule.version
07:05:24.215 [DEBUG] [com.sun.xml.internal.bind.v2.util.XmlFactory] SAXParserFactory instance: com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl@428c7aac
07:05:24.215 [DEBUG] [com.sun.xml.internal.bind.v2.util.XmlFactory] SAXParser
@mockitoguy
mockitoguy / gist:2613e6c5dca705b9a1807fd07ca35226
Created January 16, 2017 15:17
Unable to find a usable idle daemon problem
mint build | [INFO] Running tabby-mctabface 'ligradle -Prelease=true -PallArtifacts build'
[INFO] Executing: -Prelease=true -PallArtifacts build
[INFO] Using versions:
[INFO] Environment: Gradle 2.12, JDK 1.8.0_40
[INFO] Gradle Plugins: gradle-python:1.1.3, ligradle-jvm:2.0.11
FAILURE: Build failed with an exception.
* What went wrong:
Unable to find a usable idle daemon. I have connected to 100 different daemons but I could not use any of them to run build: Build{id=03f3c492-230a-4020-a057-f2f700e44e0b.1, currentDir=/export/home/tester/hudson/data/workspace/MP_TRUNKDEV_MP_DEP/tabby-mctabface_c468178919b2d14cf31b1aa50fe6d9752daeb78a}. BuildActionParameters were DefaultBuildActionParameters{, currentDir=/export/home/tester/hudson/data/workspace/MP_TRUNKDEV_MP_DEP/tabby-mctabface_c468178919b2d14cf31b1aa50fe6d9752daeb78a, systemProperties size=53, envVariables size=116, logLevel=LIFECYCLE, daemonUsage=EXPLICITLY_ENABLED, continuous=false, interactive=false, injectedPluginClasspath=[]}.
Moving big projects forward is challenging (easier to procrastinate stuff!). I really like David Allen’s advice to...
focus on the next physical action
Many times, it is simple to get the big projects moving. Identify the next action, document it on the list or even execute on the spot (2-minute rule - LINK).
Example: Need to take the car for check-up but no motivation? What’s the next action? Call the garage. No number? Next action: find the number, put it on the “calls” list (to call during business hours). Notice that the next action is easy to identify and cheap to implement. It gets project moving, it keeps motivated.
“Next action” mantra is one of the fundamentals of GTD methodology. However, it is a very useful tip on it’s own. If some project is stuck ask the team what is the next action to move it forward. One step at the time, the project will get done.
I'm having problems with composite build, I'm using Gradle 2.14-20160427000021+0000
Problems:
- the dependency project tasks are not triggered when running build
- the dependency report task does not show substituted dependencies (shows jar/module dependencies instead of project dependencies)
Is there anything obvious that I'm doing wrong here?
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
@mockitoguy
mockitoguy / gist:38619fd8766c66c46dff4dc2b6db06ec
Created April 7, 2016 06:20
mockito warnings prototyping
Variants of Mockito debug messages printed to the console when test fails. We should also try to see how it looks like in the exception message.
1.
[Mockito] Potential problems that may contribute to test failure. For more info, see MockitoJUnit class.
[Mockito]
[Mockito] Unused stubbing because of argument mismatch:
[Mockito]
[Mockito] - stubbed with those args here -> at org.mockitousage.junitrunner.ModellingVerboseMockitoTest.shouldLogUnusedStubbingWarningWhenTestFails(ModellingVerboseMockitoTest.java:33)
[Mockito] - BUT called with different args -> at org.mockitousage.junitrunner.ModellingVerboseMockitoTest.shouldLogUnusedStubbingWarningWhenTestFails(ModellingVerboseMockitoTest.java:38)