This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * To change this license header, choose License Headers in Project Properties. | |
| * To change this template file, choose Tools | Templates | |
| * and open the template in the editor. | |
| */ | |
| package org.me.modelmapper; | |
| import com.fasterxml.jackson.databind.JsonNode; | |
| import com.fasterxml.jackson.databind.ObjectMapper; | |
| import com.google.gson.JsonElement; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ------------------------------------------------------- | |
| T E S T S | |
| ------------------------------------------------------- | |
| Running org.me.modelmapper.JsonModelMapperTest | |
| Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@5704ce99 | |
| Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.921 sec <<< FAILURE! | |
| shouldMapFromJsonNode(org.me.modelmapper.JsonModelMapperTest) Time elapsed: 0.336 sec <<< FAILURE! | |
| org.modelmapper.MappingException: ModelMapper mapping errors: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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>org.me.modelmappertest</groupId> | |
| <artifactId>modelMapperTest</artifactId> | |
| <version>1.0-SNAPSHOT</version> | |
| <packaging>jar</packaging> | |
| <dependencies> | |
| <dependency> | |
| <groupId>org.modelmapper</groupId> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.me.modelmapper; | |
| import com.fasterxml.jackson.databind.JsonNode; | |
| import com.fasterxml.jackson.databind.ObjectMapper; | |
| import java.util.ArrayList; | |
| import org.modelmapper.ModelMapper; | |
| import org.modelmapper.config.Configuration; | |
| import org.modelmapper.jackson.JsonNodeValueReader; | |
| import org.testng.Assert; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1) Error mapping com.google.gson.JsonObject to org.me.modelmappertest.Foo | |
| 1 error | |
| at org.modelmapper.internal.Errors.throwMappingExceptionIfErrorsExist(Errors.java:374) | |
| at org.modelmapper.internal.MappingEngineImpl.map(MappingEngineImpl.java:69) | |
| at org.modelmapper.ModelMapper.mapInternal(ModelMapper.java:497) | |
| at org.modelmapper.ModelMapper.map(ModelMapper.java:340) | |
| at org.me.modelmappertest.TestGsonMapper.main(TestGsonMapper.java:31) | |
| Caused by: java.lang.NullPointerException |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Golf where | |
| import Data.List | |
| import Data.Text (justifyRight, pack, unpack) | |
| import Data.Ord (comparing) | |
| -- ex 1 | |
| skips :: [a] -> [[a]] | |
| skips xs = map (flip every xs) [1..length xs] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| frequencies :: [Integer] -> [(Integer, Int)] | |
| frequencies xs = map (\x -> (head x, length x)) . group . sort $ xs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Golf where | |
| import Data.List | |
| every n xs = case drop (n-1) xs of | |
| (y:ys) -> y:every n ys | |
| [] -> [] | |
| skips :: [a] -> [[a]] | |
| skips xs = map (\n -> every n xs) [1..length xs] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| whatWentWrong :: [LogMessage] -> [String] | |
| whatWentWrong msgs = map (\m -> case m of | |
| (LogMessage _ _ s) -> s | |
| _ -> "") | |
| $ dropWhile (\m -> case m of | |
| (LogMessage (Error severity) _ _) -> severity >= 50 | |
| _ -> False) . | |
| filter (\m -> case m of | |
| (LogMessage (Error _) _ _) -> True | |
| _ -> False) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# OPTIONS_GHC -Wall #-} | |
| module LogAnalysis where | |
| import Log | |
| -- ex 1 | |
| parseMessage :: String -> LogMessage | |
| parseMessage line = | |
| case words line of | |
| ("E":severity:timestamp:content) -> LogMessage (Error $ read severity) (read timestamp) (unwords content) |