Skip to content

Commit

Permalink
[BAEL-19886] - moved related articles to the new core-kotlin-modules/…
Browse files Browse the repository at this point in the history
…core-kotlin module
  • Loading branch information
catalin-burcea committed Jan 22, 2020
1 parent 202c7d6 commit f145e70
Show file tree
Hide file tree
Showing 42 changed files with 106 additions and 76 deletions.
6 changes: 0 additions & 6 deletions core-kotlin-2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,5 @@ This module contains articles about core Kotlin.

### Relevant articles:

- [Kotlin Scope Functions](https://www.baeldung.com/kotlin-scope-functions)
- [Kotlin Annotations](https://www.baeldung.com/kotlin-annotations)
- [Split a List into Parts in Kotlin](https://www.baeldung.com/kotlin-split-list-into-parts)
- [String Comparison in Kotlin](https://www.baeldung.com/kotlin-string-comparison)
- [Guide to JVM Platform Annotations in Kotlin](https://www.baeldung.com/kotlin-jvm-annotations)
- [Finding an Element in a List Using Kotlin](https://www.baeldung.com/kotlin-finding-element-in-list)
- [Kotlin Ternary Conditional Operator](https://www.baeldung.com/kotlin-ternary-conditional-operator)
- More articles: [[<-- prev]](/core-kotlin)
15 changes: 15 additions & 0 deletions core-kotlin-modules/core-kotlin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Core Kotlin

This module contains articles about Kotlin core features.

### Relevant articles:
- [Introduction to the Kotlin Language](https://www.baeldung.com/kotlin)
- [Kotlin Java Interoperability](https://www.baeldung.com/kotlin-java-interoperability)
- [Get a Random Number in Kotlin](https://www.baeldung.com/kotlin-random-number)
- [Create a Java and Kotlin Project with Maven](https://www.baeldung.com/kotlin-maven-java-project)
- [Guide to Sorting in Kotlin](https://www.baeldung.com/kotlin-sort)
- [Creational Design Patterns in Kotlin: Builder](https://www.baeldung.com/kotlin-builder-pattern)
- [Kotlin Scope Functions](https://www.baeldung.com/kotlin-scope-functions)
- [Implementing a Binary Tree in Kotlin](https://www.baeldung.com/kotlin-binary-tree)
- [JUnit 5 for Kotlin Developers](https://www.baeldung.com/junit-5-kotlin)
- [Converting Kotlin Data Class from JSON using GSON](https://www.baeldung.com/kotlin-json-convert-data-class)
29 changes: 29 additions & 0 deletions core-kotlin-modules/core-kotlin/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?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>
<artifactId>core-kotlin</artifactId>
<name>core-kotlin</name>
<packaging>jar</packaging>

<parent>
<groupId>com.baeldung.core-kotlin-modules</groupId>
<artifactId>core-kotlin-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>${junit.platform.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<properties>
<junit.platform.version>1.1.1</junit.platform.version>
</properties>

</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.baeldung.java;
package com.baeldung.interoperability;

import java.io.File;
import java.io.FileReader;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.baeldung.java;
package com.baeldung.interoperability;

public class Customer {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.baeldung.java;
package com.baeldung.introduction;

public class StringUtils {
public static String toUpperCase(String name) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.baeldung.mavenjavakotlin;

import com.baeldung.mavenjavakotlin.services.JavaService;
import com.baeldung.mavenjavakotlin.services.KotlinService;

public class Application {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.baeldung.datastructures
package com.baeldung.binarytree

/**
* Example of how to use the {@link Node} class.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.baeldung.datastructures
package com.baeldung.binarytree

/**
* An ADT for a binary search tree.
* Note that this data type is neither immutable nor thread safe.
*/
class Node(
var key: Int,
var left: Node? = null,
var right: Node? = null) {
var key: Int,
var left: Node? = null,
var right: Node? = null) {

/**
* Return a node with given value. If no such node exists, return null.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.baeldung.kotlin
package com.baeldung.introduction

fun main(args: Array<String>){
println("hello word")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.baeldung.kotlin
package com.baeldung.introduction

open class Item(val id: String, val name: String = "unknown_name") {
open fun getIdOfItem(): String {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.baeldung.kotlin
package com.baeldung.introduction

import java.util.*

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.baeldung.kotlin
package com.baeldung.introduction

import java.util.concurrent.ThreadLocalRandom

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.baeldung.kotlin
package com.baeldung.introduction

class MathematicsOperations {
fun addTwoNumbers(a: Int, b: Int): Int {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.baeldung.mavenjavakotlin.services
package com.baeldung.mavenjavakotlin

class KotlinService {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.baeldung.sorting

import kotlin.comparisons.*

fun sortMethodUsage() {
val sortedValues = mutableListOf(1, 2, 7, 6, 5, 6)
sortedValues.sort()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.baeldung.kotlin;
package com.baeldung.introduction;

import org.junit.Test;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.baeldung.datastructures
package com.baeldung.binarytree

import org.junit.After
import org.junit.Assert.*
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Before
import org.junit.Test

Expand Down Expand Up @@ -69,8 +70,10 @@ class NodeTest {

@Test
fun givenDepthTwo_whenPivotAtDepth2_then_Success() {
val left = Node(1, Node(0), Node(2))
val right = Node(5, Node(4), Node(6))
val left =
Node(1, Node(0), Node(2))
val right =
Node(5, Node(4), Node(6))
val n = Node(3, left, right)
assertEquals(left.left, n.find(0))
}
Expand Down Expand Up @@ -243,7 +246,8 @@ class NodeTest {
*/
@Test
fun givenTreeDepthOne_whenValueAbsent_thenNoChange() {
val n = Node(1, Node(0), Node(2))
val n =
Node(1, Node(0), Node(2))
n.delete(3)
assertEquals(1, n.key)
assertEquals(2, n.right!!.key)
Expand Down Expand Up @@ -281,7 +285,11 @@ class NodeTest {
*/
@Test
fun givenTreeDepthTwo_whenNodeToDeleteHasOneChild_thenChangeTree() {
val n = Node(2, Node(0, null, Node(1)), Node(3))
val n = Node(
2,
Node(0, null, Node(1)),
Node(3)
)
n.delete(0)
assertEquals(2, n.key)
with(n.right!!) {
Expand All @@ -298,8 +306,13 @@ class NodeTest {

@Test
fun givenTreeDepthThree_whenNodeToDeleteHasTwoChildren_thenChangeTree() {
val l = Node(2, Node(1), Node(5, Node(4), Node(6)))
val r = Node(10, Node(9), Node(11))
val l = Node(
2,
Node(1),
Node(5, Node(4), Node(6))
)
val r =
Node(10, Node(9), Node(11))
val n = Node(8, l, r)
n.delete(8)
assertEquals(6, n.key)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.baeldung.kotlin.gson
package com.baeldung.gson

import com.google.gson.Gson

Expand All @@ -11,7 +11,7 @@ class GsonUnitTest {

@Test
fun givenObject_thenGetJSONString() {
var jsonString = gson.toJson(TestModel(1,"Test"))
var jsonString = gson.toJson(TestModel(1, "Test"))
Assert.assertEquals(jsonString, "{\"id\":1,\"description\":\"Test\"}")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
package com.baeldung.kotlin
package com.baeldung.interoperability

import com.baeldung.java.ArrayExample
import com.baeldung.java.Customer
import org.junit.Test
import kotlin.test.assertEquals

class ArrayTest {

@Test
fun givenArray_whenValidateArrayType_thenComplete () {
val ex = ArrayExample()
val ex = com.baeldung.interoperability.ArrayExample()
val numArray = intArrayOf(1, 2, 3)

assertEquals(ex.sumValues(numArray), 6)
}

@Test
fun givenCustomer_whenGetSuperType_thenComplete() {
val instance = Customer::class
val instance = com.baeldung.interoperability.Customer::class
val supertypes = instance.supertypes

assertEquals(supertypes[0].toString(), "kotlin.Any")
}

@Test
fun givenCustomer_whenGetConstructor_thenComplete() {
val instance = Customer::class.java
val instance = com.baeldung.interoperability.Customer::class.java
val constructors = instance.constructors

assertEquals(constructors.size, 1)
assertEquals(constructors[0].name, "com.baeldung.java.Customer")
assertEquals(constructors[0].name, "com.baeldung.interoperability.Customer")
}

fun makeReadFile() {
val ax = ArrayExample()
val ax = com.baeldung.interoperability.ArrayExample()
ax.writeList()
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.baeldung.kotlin
package com.baeldung.interoperability

import com.baeldung.java.Customer
import org.junit.Test
import kotlin.test.assertEquals

class CustomerTest {

@Test
fun givenCustomer_whenNameAndLastNameAreAssigned_thenComplete() {
val customer = Customer()
val customer = com.baeldung.interoperability.Customer()

// Setter method is being called
customer.firstName = "Frodo"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.baeldung.kotlin
package com.baeldung.introduction

import org.junit.Test
import kotlin.test.assertNotNull

class ItemServiceTest {

@Test
fun givenItemId_whenGetForOptionalItem_shouldMakeActionOnNonNullValue() {
//given
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.baeldung.kotlin
package com.baeldung.introduction

import com.baeldung.java.StringUtils
import org.junit.Test
import kotlin.test.assertEquals

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.baeldung.kotlin
package com.baeldung.introduction

import org.junit.Test
import kotlin.test.assertEquals


class LambdaTest {

@Test
fun givenListOfNumber_whenDoingOperationsUsingLambda_shouldReturnProperResult() {
//given
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.baeldung.kotlin
package com.baeldung.introduction

import com.baeldung.kotlin.ListExtension
import org.junit.Test
import kotlin.test.assertTrue

class ListExtensionTest {

@Test
fun givenList_whenExecuteExtensionFunctionOnList_shouldReturnRandomElementOfList(){
fun givenList_whenExecuteExtensionFunctionOnList_shouldReturnRandomElementOfList() {
//given
val elements = listOf("a", "b", "c")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.baeldung.kotlin.junit5
package com.baeldung.junit5

class Calculator {
fun add(a: Int, b: Int) = a + b
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.baeldung.kotlin.junit5
package com.baeldung.junit5

import org.junit.jupiter.api.*
import org.junit.jupiter.api.function.Executable

class CalculatorTest5 {
class CalculatorUnitTest {
private val calculator = Calculator()

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package com.baeldung.kotlin.junit5
package com.baeldung.junit5

class DivideByZeroException(val numerator: Int) : Exception()
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.baeldung.kotlin.junit5
package com.baeldung.junit5

import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test

class SimpleTest5 {
class SimpleUnitTest {

@Test
fun `isEmpty should return true for empty lists`() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.baeldung.sorting

import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test

import org.junit.jupiter.api.Assertions.*

class SortingExampleKtTest {

@Test
Expand Down
Loading

0 comments on commit f145e70

Please sign in to comment.