Mockito: List Matchers with generics
Mockito offers: when(mock.process(Matchers.any(List.class))); How to avoid warning if process takes a List<Bar> instead? 4 Answers 4
Mockito offers: when(mock.process(Matchers.any(List.class))); How to avoid warning if process takes a List<Bar> instead? 4 Answers 4
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago. Improve this question I’m at the beginning/middle of a project that we chose to implement using GWT. Has anyone … Read more
I have a problem with the stream of Java 8 foreach attempting to move on next item in loop. I cannot set the command like continue;, only return; works but you will exit from the loop in this case. I need to move on next item in loop. How can I do that? Example(not working): … Read more
I have noticed that in a Maven artifact’s JAR, the project.version attribute is included in two files: META-INF/maven/${groupId}/${artifactId}/pom.properties META-INF/maven/${groupId}/${artifactId}/pom.xml Is there a recommended way to read this version at runtime? 12 Answers 12
I’m using the runtime to run command prompt commands from my Java program. However, I’m not aware of how I can get the output the command returns. Here is my code: Runtime rt = Runtime.getRuntime(); String[] commands = {“system.exe”, “-send” , argument}; Process proc = rt.exec(commands); I tried doing System.out.println(proc); but that did not return … Read more
Is there a way how to test if an element is present? Any findElement method would end in an exception, but that is not what I want, because it can be that an element is not present and that is okay, that is not a fail of the test, so an exception can not be … Read more
I would like to lookup an enum from its string value (or possibly any other value). I’ve tried the following code but it doesn’t allow static in initialisers. Is there a simple way? public enum Verbosity { BRIEF, NORMAL, FULL; private static Map<String, Verbosity> stringMap = new HashMap<String, Verbosity>(); private Verbosity() { stringMap.put(this.toString(), this); } … Read more
Below are the values contain in the HashMap statusName {Active=33, Renewals Completed=3, Application=15} Java code to getting the first Key (i.e Active) Object myKey = statusName.keySet().toArray()[0]; How can we collect the first Key “Value” (i.e 33), I want to store both the “Key” and “Value” in separate variable. 11 Answers 11
I’ve got such a code snippet: @RunWith(PowerMockRunner.class) @PrepareForTest({Thread.class}) public class AllMeasuresDataTest { @Before public void setUp() throws Exception { } @Test public void testGetMeasures() { AllMeasuresData measure = new AllMeasuresData(); assertEquals(measure.getMeasures(), null); HashMap<String, Measure> map = new HashMap<String, Measure>(); measure.setMeasures(map); assertEquals(measure.getMeasures(), map); measure.setMeasures(null); assertEquals(measure.getMeasures(), null); } @Test public void testAllMeasuresData() throws IOException { ClassLoader loader … Read more
I have a maven2 multi-module project and in each of my child modules I have JUnit tests that are named Test.java and Integration.java for unit tests and integration tests respectively. When I execute: mvn test all of the JUnit tests *Test.java within the child modules are executed. When I execute mvn test -Dtest=**/*Integration none of … Read more