import java.*
import groovy.*
import css
import javascript.jQuery

if(!candidate.ambitious) throw new InterviewFailedException()

def requirements = new TestRunner(Requirements).run()
if(!requirements.passed) throw new InterviewFailedException()

println "Suitable candidate identified."
println "(Bonus points: ${calculateBonusPoints()})"
println "Please apply for job immediately."

class Requirements {
	@Test
	void "candidate should have programming experience"() {
		assert programming in candidate.experience
	}

	@Test
	void "candidate should like writing good code"() {
		assert [OOP, TDD, "clean code"].every {
			it in candidate.interests
		}
	}
	
	@Test
	void "candidate should be interested in JVM languages"() {
		assert [groovy, scala, jruby].inject(0) { lang, t ->
			t + candidate.interests.lang
		}
	}
}

class FrontlineSMS {
	def about = '''
The Social Impact Lab (SIMLab) lowers the barriers to social change
using mobile technologies. SIMLab''s main product FrontlineSMS is 
free, open-source desktop software that enables users to send, 
receive and manage SMS over a mobile network. FrontlineCloud is 
a cloud-hosted version of FrontlineSMS with extra cloud-based 
features. We are a global team of 15+ with offices in the US and 
Kenya. We are looking to expand our developer team for new projects
working on new functionality, exciting innovative projects and a 
variety of other applications from education to media to open government.

'''
	def methodology = agile * scrum * kanban
	def sourceControl = git
	def frameworks = [grails, jQuery]
	def tools = [AWS, jenkins, camel]

	def devTeam = ['Okal', 'Sitati', 'Vaneyck', 'Fred', 'Pitkin']
	def location = 'Nairobi'

	def contact = [
		email: 'dev-jobs@frontlinesms.com',
		web: 'http://www.frontlinesms.com'
	]
}

def calculateBonusPoints() {
	def bonusPoints

	// front-end experience desirable
	[CSS, javascript, jQuery].each {
		if(candidate.experience.contains(it))
			++bonusPoints
	}

	// interest in ICT4D desirable
	if('ICT4D' in candidate.interests)
		++bonusPoints

	// mobile development experience desirable
	[android, iOS, J2ME].each {
		if(candidate.experience.contains(it))
			++bonusPoints
	}
}