How to use isCollectionOrMap method of org.jmock.internal.ReturnDefaultValueAction class

Best Jmock-library code snippet using org.jmock.internal.ReturnDefaultValueAction.isCollectionOrMap

Source:ReturnDefaultValueAction.java Github

copy

Full Screen

...66 }67 if (returnType.isArray()) {68 return Array.newInstance(returnType.getComponentType(), 0);69 }70 if (isCollectionOrMap(returnType)) {71 final Object instance = collectionOrMapInstanceFor(returnType);72 if (instance != null) return instance;73 }74 if (imposteriser.canImposterise(returnType) && !invocation.isBuildingExpectation()) {75 return imposteriser.imposterise(this, returnType);76 }77 return null;78 }79 private static Object collectionOrMapInstanceFor(Class<?> returnType) throws Throwable {80 return cannotCreateNewInstance(returnType) ? instanceForCollectionType(returnType) : returnType.newInstance();81 }82 private static Object instanceForCollectionType(Class<?> type) throws Throwable {83 for (Class<?> collectionType : CONCRETE_COLLECTION_TYPES) {84 if (type.isAssignableFrom(collectionType)) {85 return collectionType.newInstance();86 }87 }88 return null;89 }90 private static boolean isCollectionOrMap(Class<?> type) {91 return Collection.class.isAssignableFrom(type)92 || Map.class.isAssignableFrom(type);93 }94 private static boolean cannotCreateNewInstance(Class<?> returnType) {95 return returnType.isInterface() || isAbstract(returnType.getModifiers());96 }97 protected static Map<Class<?>, Object> createDefaultResults() {98 final HashMap<Class<?>, Object> result = new HashMap<Class<?>, Object>();99 result.put(boolean.class, Boolean.FALSE);100 result.put(void.class, null);101 result.put(byte.class, (byte) 0);102 result.put(short.class, (short) 0);103 result.put(int.class, 0);104 result.put(long.class, 0L);...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Jmock-library automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful