{"action":"created","comment":{"url":"https://api.github.com/repos/Stratio/hermes/pulls/comments/90031367","pull_request_review_id":10556953,"id":90031367,"diff_hunk":"@@ -0,0 +1,66 @@\n+/*\n+ * Copyright (C) 2016 Stratio (http://stratio.com)\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *         http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package com.stratio.hermes.kafka\n+\n+import java.util\n+import java.util.Properties\n+import com.typesafe.config.ConfigFactory\n+import org.apache.kafka.clients.consumer.KafkaConsumer\n+import org.junit.runner.RunWith\n+import org.scalatest.junit.JUnitRunner\n+import org.scalatest.{FlatSpec, Matchers}\n+import scala.io.Source\n+import scala.util.Try\n+import scala.collection.JavaConverters._\n+\n+\n+@RunWith(classOf[JUnitRunner])\n+class KafkaProducerTest extends FlatSpec with Matchers {\n+\n+  val PollTime = Integer.parseInt(System.getProperty(\"POLL_TIME\", \"100\"))\n+  val KafkaHost = System.getProperty(\"KAFKA_HOST\", \"localhost\")\n+  val KafkaPort = System.getProperty(\"KAFKA_PORT\", \"9092\")\n+  val TopicName = System.getProperty(\"TOPIC_NAME\", \"test\")\n+  val props = new Properties\n+  props.put(\"key.deserializer\", \"org.apache.kafka.common.serialization.StringDeserializer\")\n+  props.put(\"value.deserializer\", \"org.apache.kafka.common.serialization.StringDeserializer\")\n+  props.put(\"bootstrap.servers\", KafkaHost + \":\" + KafkaPort)\n+  props.put(\"enable.auto.commit\", \"true\")\n+  props.put(\"group.id\", \"0\")\n+  props.put(\"auto.commit.interval.ms\", \"1000\")\n+  props.put(\"session.timeout.ms\", \"30000\")\n+  val ProducerTest = Try(getClass.getResourceAsStream(\"/fixtures/kafka/producer-fixture.json\"))\n+    .getOrElse(throw new IllegalStateException(\"Error loading locale: /fixtures/kafka/producer-fixture.json\"))\n+\n+  \"A KafkaProducer\" should \"Produce a message and be consumed\" in {\n+\n+    val kafkaProducer = KafkaProducer.getInstance(ConfigFactory.parseResources(\"kafka.conf\"))\n+    val consumer = new KafkaConsumer(props)\n+    consumer.subscribe(util.Arrays.asList(TopicName))\n+    val records1 = consumer.poll(PollTime)\n+    records1.count() shouldEqual 0\n+    KafkaProducer.send(kafkaProducer, TopicName, Source.fromInputStream(ProducerTest).mkString)\n+    kafkaProducer.flush()\n+    val records2 = consumer.poll(PollTime)\n+    for (r <- records2.iterator().asScala) {\n+      r.value.toString.shouldEqual(\"{\\\"name\\\":\\\"amparo\\\"}\")\n+    }\n+    records2.count() shouldEqual 1\n+    KafkaProducer.close(kafkaProducer)\n+    consumer.close()\n+  }","path":"src/test/scala/com/stratio/hermes/kafka/KafkaProducerTest.scala","position":67,"original_position":65,"commit_id":"c0e75e8c3b99844412b6590fc17d9c2db1e4d55e","original_commit_id":"a14678058df06a555aaabae152d9c8faad97b009","user":{"login":"albertostratio","id":7139146,"avatar_url":"https://avatars.githubusercontent.com/u/7139146?v=3","gravatar_id":"","url":"https://api.github.com/users/albertostratio","html_url":"https://github.com/albertostratio","followers_url":"https://api.github.com/users/albertostratio/followers","following_url":"https://api.github.com/users/albertostratio/following{/other_user}","gists_url":"https://api.github.com/users/albertostratio/gists{/gist_id}","starred_url":"https://api.github.com/users/albertostratio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/albertostratio/subscriptions","organizations_url":"https://api.github.com/users/albertostratio/orgs","repos_url":"https://api.github.com/users/albertostratio/repos","events_url":"https://api.github.com/users/albertostratio/events{/privacy}","received_events_url":"https://api.github.com/users/albertostratio/received_events","type":"User","site_admin":false},"body":"As per our conversations we've decided not to test anything else as we're just calling the kafka send method of the kafka library and it should be already tested within the library","created_at":"2016-11-29T15:26:40Z","updated_at":"2016-11-29T15:26:40Z","html_url":"https://github.com/Stratio/hermes/pull/6#discussion_r90031367","pull_request_url":"https://api.github.com/repos/Stratio/hermes/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/Stratio/hermes/pulls/comments/90031367"},"html":{"href":"https://github.com/Stratio/hermes/pull/6#discussion_r90031367"},"pull_request":{"href":"https://api.github.com/repos/Stratio/hermes/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/Stratio/hermes/pulls/6","id":95523459,"html_url":"https://github.com/Stratio/hermes/pull/6","diff_url":"https://github.com/Stratio/hermes/pull/6.diff","patch_url":"https://github.com/Stratio/hermes/pull/6.patch","issue_url":"https://api.github.com/repos/Stratio/hermes/issues/6","number":6,"state":"open","locked":false,"title":"[DCS-157] Create kafka producer","user":{"login":"eruizgar","id":12275861,"avatar_url":"https://avatars.githubusercontent.com/u/12275861?v=3","gravatar_id":"","url":"https://api.github.com/users/eruizgar","html_url":"https://github.com/eruizgar","followers_url":"https://api.github.com/users/eruizgar/followers","following_url":"https://api.github.com/users/eruizgar/following{/other_user}","gists_url":"https://api.github.com/users/eruizgar/gists{/gist_id}","starred_url":"https://api.github.com/users/eruizgar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eruizgar/subscriptions","organizations_url":"https://api.github.com/users/eruizgar/orgs","repos_url":"https://api.github.com/users/eruizgar/repos","events_url":"https://api.github.com/users/eruizgar/events{/privacy}","received_events_url":"https://api.github.com/users/eruizgar/received_events","type":"User","site_admin":false},"body":"#### Description\r\n- This feature allow you to produce messages to kafka.\r\n\r\n\r\n#### Testing\r\n- Check that you can produce a simple message {\"name\":\"amparo\"} using kafka producer method and consume it.\r\n\r\n#### Ticket\r\nhttps://stratio.atlassian.net/browse/DCS-157\r\n","created_at":"2016-11-28T15:50:01Z","updated_at":"2016-11-29T15:26:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7be6d2cf9eb88faf2c8c6fd6661560e832baff38","assignee":{"login":"albertostratio","id":7139146,"avatar_url":"https://avatars.githubusercontent.com/u/7139146?v=3","gravatar_id":"","url":"https://api.github.com/users/albertostratio","html_url":"https://github.com/albertostratio","followers_url":"https://api.github.com/users/albertostratio/followers","following_url":"https://api.github.com/users/albertostratio/following{/other_user}","gists_url":"https://api.github.com/users/albertostratio/gists{/gist_id}","starred_url":"https://api.github.com/users/albertostratio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/albertostratio/subscriptions","organizations_url":"https://api.github.com/users/albertostratio/orgs","repos_url":"https://api.github.com/users/albertostratio/repos","events_url":"https://api.github.com/users/albertostratio/events{/privacy}","received_events_url":"https://api.github.com/users/albertostratio/received_events","type":"User","site_admin":false},"assignees":[{"login":"albertostratio","id":7139146,"avatar_url":"https://avatars.githubusercontent.com/u/7139146?v=3","gravatar_id":"","url":"https://api.github.com/users/albertostratio","html_url":"https://github.com/albertostratio","followers_url":"https://api.github.com/users/albertostratio/followers","following_url":"https://api.github.com/users/albertostratio/following{/other_user}","gists_url":"https://api.github.com/users/albertostratio/gists{/gist_id}","starred_url":"https://api.github.com/users/albertostratio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/albertostratio/subscriptions","organizations_url":"https://api.github.com/users/albertostratio/orgs","repos_url":"https://api.github.com/users/albertostratio/repos","events_url":"https://api.github.com/users/albertostratio/events{/privacy}","received_events_url":"https://api.github.com/users/albertostratio/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/Stratio/hermes/pulls/6/commits","review_comments_url":"https://api.github.com/repos/Stratio/hermes/pulls/6/comments","review_comment_url":"https://api.github.com/repos/Stratio/hermes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Stratio/hermes/issues/6/comments","statuses_url":"https://api.github.com/repos/Stratio/hermes/statuses/c0e75e8c3b99844412b6590fc17d9c2db1e4d55e","head":{"label":"eruizgar:create-kafka-producer","ref":"create-kafka-producer","sha":"c0e75e8c3b99844412b6590fc17d9c2db1e4d55e","user":{"login":"eruizgar","id":12275861,"avatar_url":"https://avatars.githubusercontent.com/u/12275861?v=3","gravatar_id":"","url":"https://api.github.com/users/eruizgar","html_url":"https://github.com/eruizgar","followers_url":"https://api.github.com/users/eruizgar/followers","following_url":"https://api.github.com/users/eruizgar/following{/other_user}","gists_url":"https://api.github.com/users/eruizgar/gists{/gist_id}","starred_url":"https://api.github.com/users/eruizgar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eruizgar/subscriptions","organizations_url":"https://api.github.com/users/eruizgar/orgs","repos_url":"https://api.github.com/users/eruizgar/repos","events_url":"https://api.github.com/users/eruizgar/events{/privacy}","received_events_url":"https://api.github.com/users/eruizgar/received_events","type":"User","site_admin":false},"repo":{"id":74659141,"name":"Hermes","full_name":"eruizgar/Hermes","owner":{"login":"eruizgar","id":12275861,"avatar_url":"https://avatars.githubusercontent.com/u/12275861?v=3","gravatar_id":"","url":"https://api.github.com/users/eruizgar","html_url":"https://github.com/eruizgar","followers_url":"https://api.github.com/users/eruizgar/followers","following_url":"https://api.github.com/users/eruizgar/following{/other_user}","gists_url":"https://api.github.com/users/eruizgar/gists{/gist_id}","starred_url":"https://api.github.com/users/eruizgar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eruizgar/subscriptions","organizations_url":"https://api.github.com/users/eruizgar/orgs","repos_url":"https://api.github.com/users/eruizgar/repos","events_url":"https://api.github.com/users/eruizgar/events{/privacy}","received_events_url":"https://api.github.com/users/eruizgar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/eruizgar/Hermes","description":"A distributed fake data generator based in Akka.","fork":true,"url":"https://api.github.com/repos/eruizgar/Hermes","forks_url":"https://api.github.com/repos/eruizgar/Hermes/forks","keys_url":"https://api.github.com/repos/eruizgar/Hermes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eruizgar/Hermes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eruizgar/Hermes/teams","hooks_url":"https://api.github.com/repos/eruizgar/Hermes/hooks","issue_events_url":"https://api.github.com/repos/eruizgar/Hermes/issues/events{/number}","events_url":"https://api.github.com/repos/eruizgar/Hermes/events","assignees_url":"https://api.github.com/repos/eruizgar/Hermes/assignees{/user}","branches_url":"https://api.github.com/repos/eruizgar/Hermes/branches{/branch}","tags_url":"https://api.github.com/repos/eruizgar/Hermes/tags","blobs_url":"https://api.github.com/repos/eruizgar/Hermes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eruizgar/Hermes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eruizgar/Hermes/git/refs{/sha}","trees_url":"https://api.github.com/repos/eruizgar/Hermes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eruizgar/Hermes/statuses/{sha}","languages_url":"https://api.github.com/repos/eruizgar/Hermes/languages","stargazers_url":"https://api.github.com/repos/eruizgar/Hermes/stargazers","contributors_url":"https://api.github.com/repos/eruizgar/Hermes/contributors","subscribers_url":"https://api.github.com/repos/eruizgar/Hermes/subscribers","subscription_url":"https://api.github.com/repos/eruizgar/Hermes/subscription","commits_url":"https://api.github.com/repos/eruizgar/Hermes/commits{/sha}","git_commits_url":"https://api.github.com/repos/eruizgar/Hermes/git/commits{/sha}","comments_url":"https://api.github.com/repos/eruizgar/Hermes/comments{/number}","issue_comment_url":"https://api.github.com/repos/eruizgar/Hermes/issues/comments{/number}","contents_url":"https://api.github.com/repos/eruizgar/Hermes/contents/{+path}","compare_url":"https://api.github.com/repos/eruizgar/Hermes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eruizgar/Hermes/merges","archive_url":"https://api.github.com/repos/eruizgar/Hermes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eruizgar/Hermes/downloads","issues_url":"https://api.github.com/repos/eruizgar/Hermes/issues{/number}","pulls_url":"https://api.github.com/repos/eruizgar/Hermes/pulls{/number}","milestones_url":"https://api.github.com/repos/eruizgar/Hermes/milestones{/number}","notifications_url":"https://api.github.com/repos/eruizgar/Hermes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eruizgar/Hermes/labels{/name}","releases_url":"https://api.github.com/repos/eruizgar/Hermes/releases{/id}","deployments_url":"https://api.github.com/repos/eruizgar/Hermes/deployments","created_at":"2016-11-24T09:42:18Z","updated_at":"2016-11-24T09:42:20Z","pushed_at":"2016-11-29T15:13:25Z","git_url":"git://github.com/eruizgar/Hermes.git","ssh_url":"git@github.com:eruizgar/Hermes.git","clone_url":"https://github.com/eruizgar/Hermes.git","svn_url":"https://github.com/eruizgar/Hermes","homepage":null,"size":28,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Stratio:master","ref":"master","sha":"d5178baa7b8149f7662c1eff25eb1659e51d8ca6","user":{"login":"Stratio","id":5228027,"avatar_url":"https://avatars.githubusercontent.com/u/5228027?v=3","gravatar_id":"","url":"https://api.github.com/users/Stratio","html_url":"https://github.com/Stratio","followers_url":"https://api.github.com/users/Stratio/followers","following_url":"https://api.github.com/users/Stratio/following{/other_user}","gists_url":"https://api.github.com/users/Stratio/gists{/gist_id}","starred_url":"https://api.github.com/users/Stratio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Stratio/subscriptions","organizations_url":"https://api.github.com/users/Stratio/orgs","repos_url":"https://api.github.com/users/Stratio/repos","events_url":"https://api.github.com/users/Stratio/events{/privacy}","received_events_url":"https://api.github.com/users/Stratio/received_events","type":"Organization","site_admin":false},"repo":{"id":74585688,"name":"hermes","full_name":"Stratio/hermes","owner":{"login":"Stratio","id":5228027,"avatar_url":"https://avatars.githubusercontent.com/u/5228027?v=3","gravatar_id":"","url":"https://api.github.com/users/Stratio","html_url":"https://github.com/Stratio","followers_url":"https://api.github.com/users/Stratio/followers","following_url":"https://api.github.com/users/Stratio/following{/other_user}","gists_url":"https://api.github.com/users/Stratio/gists{/gist_id}","starred_url":"https://api.github.com/users/Stratio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Stratio/subscriptions","organizations_url":"https://api.github.com/users/Stratio/orgs","repos_url":"https://api.github.com/users/Stratio/repos","events_url":"https://api.github.com/users/Stratio/events{/privacy}","received_events_url":"https://api.github.com/users/Stratio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Stratio/hermes","description":"A distributed fake data generator based in Akka.","fork":false,"url":"https://api.github.com/repos/Stratio/hermes","forks_url":"https://api.github.com/repos/Stratio/hermes/forks","keys_url":"https://api.github.com/repos/Stratio/hermes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Stratio/hermes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Stratio/hermes/teams","hooks_url":"https://api.github.com/repos/Stratio/hermes/hooks","issue_events_url":"https://api.github.com/repos/Stratio/hermes/issues/events{/number}","events_url":"https://api.github.com/repos/Stratio/hermes/events","assignees_url":"https://api.github.com/repos/Stratio/hermes/assignees{/user}","branches_url":"https://api.github.com/repos/Stratio/hermes/branches{/branch}","tags_url":"https://api.github.com/repos/Stratio/hermes/tags","blobs_url":"https://api.github.com/repos/Stratio/hermes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Stratio/hermes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Stratio/hermes/git/refs{/sha}","trees_url":"https://api.github.com/repos/Stratio/hermes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Stratio/hermes/statuses/{sha}","languages_url":"https://api.github.com/repos/Stratio/hermes/languages","stargazers_url":"https://api.github.com/repos/Stratio/hermes/stargazers","contributors_url":"https://api.github.com/repos/Stratio/hermes/contributors","subscribers_url":"https://api.github.com/repos/Stratio/hermes/subscribers","subscription_url":"https://api.github.com/repos/Stratio/hermes/subscription","commits_url":"https://api.github.com/repos/Stratio/hermes/commits{/sha}","git_commits_url":"https://api.github.com/repos/Stratio/hermes/git/commits{/sha}","comments_url":"https://api.github.com/repos/Stratio/hermes/comments{/number}","issue_comment_url":"https://api.github.com/repos/Stratio/hermes/issues/comments{/number}","contents_url":"https://api.github.com/repos/Stratio/hermes/contents/{+path}","compare_url":"https://api.github.com/repos/Stratio/hermes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Stratio/hermes/merges","archive_url":"https://api.github.com/repos/Stratio/hermes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Stratio/hermes/downloads","issues_url":"https://api.github.com/repos/Stratio/hermes/issues{/number}","pulls_url":"https://api.github.com/repos/Stratio/hermes/pulls{/number}","milestones_url":"https://api.github.com/repos/Stratio/hermes/milestones{/number}","notifications_url":"https://api.github.com/repos/Stratio/hermes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Stratio/hermes/labels{/name}","releases_url":"https://api.github.com/repos/Stratio/hermes/releases{/id}","deployments_url":"https://api.github.com/repos/Stratio/hermes/deployments","created_at":"2016-11-23T14:45:09Z","updated_at":"2016-11-28T11:49:38Z","pushed_at":"2016-11-29T15:13:25Z","git_url":"git://github.com/Stratio/hermes.git","ssh_url":"git@github.com:Stratio/hermes.git","clone_url":"https://github.com/Stratio/hermes.git","svn_url":"https://github.com/Stratio/hermes","homepage":null,"size":37,"stargazers_count":3,"watchers_count":3,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Stratio/hermes/pulls/6"},"html":{"href":"https://github.com/Stratio/hermes/pull/6"},"issue":{"href":"https://api.github.com/repos/Stratio/hermes/issues/6"},"comments":{"href":"https://api.github.com/repos/Stratio/hermes/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/Stratio/hermes/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/Stratio/hermes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Stratio/hermes/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/Stratio/hermes/statuses/c0e75e8c3b99844412b6590fc17d9c2db1e4d55e"}}}}
{"actor":{"display_login":"albertostratio"}}