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 = '''
FrontlineSMS is a desktop program that allows you to use your modem
to send, receive and manage SMS over a mobile network. We are a
global team of 15 with offices in the US, UK, and Kenya. Our
software is free and open source and used by non-profits and others
worldwide to communicate with people via SMS. We are looking to
expand our developer team for new projects working on mobile
payments, cloud based versions of the software and a variety of
other applications from education to media to open government.
'''
	def methodology = agile * xp * scrum
	def sourceControl = git
	def frameworks = grails, jQuery

	def devTeam = ['Alex', 'Geoffrey', 'Vaneyck', 'Sitati']
	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
}