Skip to content

Instantly share code, notes, and snippets.

View remeniuk's full-sized avatar

Vasil Remeniuk remeniuk

View GitHub Profile
<?xml version="1.0" encoding="UTF-8"?>
<beans>
<bean id="testAssembly" class="de.o2.bic.nbaa.postpaid.
compositemodel.assembly.TestAssembly">
<constructor-arg ref="testAssemblyFlow"/>
<constructor-arg>
<bean id="testComponentAServices" class="java.util.
ArrayList">
<constructor-arg>
<list>
<?xml version="1.0" encoding='utf-8'?>
<service xmlns="http://www.w3.org/2007/app"
xmlns:atom="http://www.w3.org/2005/Atom">
<workspace>
<atom:title>My Pictures</atom:title>
<collection
href="http://example.org/pic" >
<atom:title>Pictures</atom:title>
<accept>image/png</accept>
<accept>image/jpeg</accept>
<?xml version=”1.0″ encoding=”UTF-8″ ?>
<record>
<name>Vasil</name>
<lastname>Remeniuk</lastname>
<email>[email protected]</email>
<address>Minsk, Belarus</address>
</record>
<mapper namespace="com.vasilrem.ideabox.model.TopicMapper">
<resultMap id="topicResult" type="com.vasilrem.ideabox.model.Topic">
<constructor>
<idArg column="id" javaType="String"/>
<arg column="name" javaType="String"/>
</constructor>
</resultMap>
<select id="getTopic" parameterType="String" resultMap="topicResult">
SELECT ID, NAME FROM IDEA_TOPIC WHERE ID = #{value}
</select>
<configuration>
<properties resource="properties/SqlMapConfig.properties" />
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="${driver}"/>
<property name="url" value="${url}"/>
<property name="username" value="${username}"/>
<property name="password" value="${password}"/>
class IdeaBoxComponentSpecTest extends JUnit4(IdeaBoxAssemblySpec)
object IdeaBoxComponentSpecRunner extends ConsoleRunner(IdeaBoxAssemblySpec)
object IdeaBoxAssemblySpec extends Specification{
"Search for a topic by a valid ID" should{
"return topic instance" in {
IdeaBoxAssembly.getTopicById("1") must notBeNull
}
}
}
trait IdeaBoxService{
val ideaBoxDao:IdeaBoxDao
def getTopicById(id: String): Topic = {
ideaBoxDao.getTopicById(id)
}
}
object IdeaBoxAssembly extends IdeaBoxService{
trait IdeaBoxDao {
def getTopicById(id:String):Topic
}
class IdeaBoxDaoImpl extends IdeaBoxDao{
val sqlMap = new SqlSessionFactoryBuilder().build(
Resources.getResourceAsReader("ibatis/SqlMapConfig.xml"))
def getTopicById(id:String):Topic = {
val session = sqlMap.openSession()
try{
trait DomainClass{
def isNotEmptyString(str: String) = str != null && str.length > 0
}
case class Topic(id: String, name: String) extends DomainClass{
assume(isNotEmptyString(id))
assume(isNotEmptyString(name))
}
val ideaJSON = """{"author":{"id":"1","name":"John Smith"},"body":"Dummy idea body","date":"1267605359042","id":"Dummy Idea ID","subject":"Dummy Idea","topic":{"id":"1","name":"General"}}"""
"New idea, submitted via REST-service (PUT idea to resource location) " should{
"appear in the list of ideas (GET ideas from resource location)" in{
ideaResource.addIdeaToTopic(null, ideaJSON.getBytes)
ideasResource.getIdeas("1") must eventually(include(""""id":"Dummy Idea ID","subject":"Dummy Idea","topic":{"id":"1","name":"General"}}"""))
}
}