This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import junit.framework.TestCase; | |
| public class CalcTest extends TestCase { | |
| Calc calc; | |
| protected void setUp() throws Exception { | |
| System.out.println("1. Setup"); | |
| calc = new Calc(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Calc { | |
| private int result = 0; | |
| public void add(int a) { | |
| if(a < 0) { | |
| throw new IllegalStateException(); | |
| } | |
| result += a; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @RunWith(SpringJUnit4ClassRunner.class) | |
| @ContextConfiguration( | |
| locations={"classpath:/beans/groovy-context.groovy"}, | |
| loader = GroovyContextLoader.class) | |
| public class GroovyBeanTest { | |
| @Autowired | |
| SmartBean smartBean; | |
| @Test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package beans | |
| import org.springframework.core.io.ClassPathResource | |
| // load configuration from the classpath | |
| def url = new ClassPathResource('beans/simple.config').URL; | |
| def config = new ConfigSlurper().parse(url); | |
| beans { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import static org.junit.Assert.*; | |
| import org.junit.*; | |
| import org.mapstruct.*; | |
| import org.mapstruct.factory.Mappers; | |
| public class CarMappingTest { | |
| @Test | |
| public void mapCarToCarDto() { | |
| CarMapper carMapper = Mappers.getMapper(CarMapper.class); | |
| Car car = new Car(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class PowerMapper { | |
| public Power asPower(PowerDto dto) { | |
| if(dto == null) return null; | |
| Power power = new Power(); | |
| power.value = String.valueOf(dto.value); | |
| return power; | |
| } | |
| public PowerDto asPowerDto(Power power) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.mapstruct.*; | |
| @Mapper(uses = {PowerMapper.class}) | |
| public interface CarMapper { | |
| @Mappings({ | |
| @Mapping(source = "engine", target = "engineDto") | |
| }) | |
| CarDto map(Car car); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def props = [:] | |
| props.helloWorld = ask("Define the hello world message:", "Hello World!") | |
| processTemplates('src/main/groovy/HelloWorld.groovy', props) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var myApp = angular.module('myApp', ['ngResource']) | |
| myApp.factory('usersResource', function($resource){ | |
| return $resource('/users', {}) | |
| }) | |
| myApp.controller('UserCtrl',['$scope', 'usersResource', function($scope, usersResource) { | |
| usersResource.query().$promise.then(function(users) { | |
| console.log('User query was succesful user count: ' + users.length) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Bundle bundle = bundleContext.getBundle(); | |
| BundleWiring bundleWiring = bundle.adapt(BundleWiring.class); | |
| ClassLoader classLoader = bundleWiring.getClassLoader(); |