Spy Objects [wp_ad_camp_5] A Mockito spy allows us to create a spy object from a real object with similar behavior where each method can be stubbed out when needed. It is ideal for testing legacy code as you cannot invoke
Execute Tests in Order in JUnit 4
Using @FixMethodOrder [wp_ad_camp_5] To execute tests in a order in JUnit 4, annotate the class with @FixedMethodOrder passing one of enum MethodSorters items as parameter. Either one of the following can be used are parameter to @FixMethodOrder. MethodSorters.NAME_ASCENDING: This sorts
JavaScript Object Creation and Object Methods and Properties
[wp_ad_camp_1] If you’ve read this, it merely declares JavaScript can do OOP. It did not talked about other (more advanced) OOP stuff like access modifiers, encapsulation – behaviors and properties, and inheritance. On this article, we’ll talk more on object
Check if a value is in an Array in JavaScript
Given an array of strings, we want to know if a particular string value is in that array. Here we’ll use the Array object’s .indexOf function.
JavaScript scope in functions vs Java scope in methods
For years, JavaScript to me was a mere validation tool or script for web applications. I hated it. I avoided using it. This time JavaScript gets the same respect from me as Java does. If you plan to “own” (or master if you can) JavaScript and you are coming from blocked-scoped languages like Java, C#, C and C++, this is one of key things you need to keep in mind…
Working with Reference Types in JavaScript
JavaScript has both primitive and reference types. It has three primitive types: string, numeric, and boolean. Internally, these are small and fixed-sized collection of bytes that are easily and predictably manipulated at the low (primitive) levels of the JavaScript interpreter. Example of strings are ‘This is a string’ and “This is another string”. Numeric values – 1, and 3.1416. Boolean values – true or false. On the other hand, reference types are different. They include objects (including JS built-in objects), Arrays, and functions. Essentially, they can have any number of properties or elements with various types (both primitives and references), so they cannot be manipulated as easily as fixed-size primitive v
JavaScript Arrays with Elements of Different Data Types
Array with different types of data? Weird stuff! Generally, an array is collection of similar items. In Computer Science 101, this means the items are of the same data type. We have an array of integers, boolean values or strings. But in JavaScript, arrays can have elements of different types.
Type Checking in JavaScript
Okay, JavaScript is a loosely-typed language, which means you do not declare the data type of a variable explicitly. In a basic variable assignment expression, e.g., var i = 4;, the value that assigns to the variable determines the data type of the variable. As you assign different types of data to the same variable, its data type changes as well. Given the nature of JavaScript, finding out what data type a variable represents before using it is very important.
How to use @ManyToMany in JPA
This article demonstrates how to use @ManyToMany in JPA using Hibernate JPA.
How to create multi-module application in Maven using Eclipse
Background [wp_ad_camp_5] Maven allows you to break down your application into multiple modules. The presentation, service, and integration layers will each be in separate module. This article demonstrates how to create just that. Software Environment Windows 7 Professional SP1 Java