Skip to content

Instantly share code, notes, and snippets.

View delabassee's full-sized avatar
👇
Don't raise your voice. Improve your argument.

David Delabassée delabassee

👇
Don't raise your voice. Improve your argument.
View GitHub Profile
import com.fnproject.fn.testing.*
import org.junit.*
import kotlin.test.assertEquals
class HelloFunctionTest {
@Rule @JvmField
val fn = FnTestingRule.createDefault()
@Test
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.fn</groupId>
<artifactId>hello</artifactId>
<version>1.0.0</version>
<properties>
package com.fn.example
fun hello(input: String) = when {
input.isEmpty() -> ("Hello, world!")
else -> ("Hello, ${input}")
}
package com.fn.example
import com.fnproject.fn.testing.*
import org.junit.*
import kotlin.test.assertEquals
class HelloFunctionTest {
@Rule @JvmField
val fn = FnTestingRule.createDefault()
myfunc/
├── func.yaml
├── pom.xml
└── src
├── main
│ └── kotlin
│ └── HelloFunction.kt
└── test
└── kotlin
└── HelloFunctionTest.kt
@delabassee
delabassee / HelloFunctionTest.kt
Created August 3, 2018 12:08
Default generated Kotlin JUnit rules
import com.fnproject.fn.testing.*
import org.junit.*
import kotlin.test.assertEquals
class HelloFunctionTest {
@Rule @JvmField
val fn = FnTestingRule.createDefault()
@Test

Keybase proof

I hereby claim:

  • I am delabassee on github.
  • I am delabassee (https://keybase.io/delabassee) on keybase.
  • I have a public key ASD_7dggiH5zvn5UOvyo4sz1wrO67x4GqgkDSYYo9861XQo

To claim this, I am signing this object:

import com.delabassee.Country
fun country(input: String): List<Country> = when {
input.isEmpty() -> Country.getAll()
else -> Country.getAll().filteredOrAll {
it.name.contains(input.trim(), true)
}
}
private fun <T> List<T>.filteredOrAll(predicate: (T) -> Boolean): List<T> {
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.delabassee.Country
fun country(input: String): String {
return jacksonObjectMapper().writeValueAsString( listCountries(input) )
}
fun listCountries(input: String): List<Country> = when {
input.isEmpty() -> Country.getAll()
else -> Country.getAll().filteredOrAll {
@delabassee
delabassee / Dockerfile
Created September 5, 2018 12:22
Dockerfile to run the Groovy function
FROM groovy:alpine
WORKDIR /function
COPY src/function.groovy .
CMD ["groovy", "function.groovy"]