From c48a1e9193c054c920e23f4d5229ebfdeccf3a2f Mon Sep 17 00:00:00 2001 From: nikhilbarar Date: Mon, 11 Jun 2018 01:56:32 +0530 Subject: [PATCH] #509: Checkstyle Fixes --- component-object/pom.xml | 34 ++ .../com/iluwatar/component/app/TodoApp.java | 43 +- .../src/main/resources/application.properties | 23 + .../src/main/resources/static/dist/bundle.js | 22 + .../src/main/resources/static/index.html | 24 + component-object/src/main/ui/devServer.js | 22 + component-object/src/main/ui/index.html | 24 + .../src/main/ui/src/actions/index.js | 22 + .../main/ui/src/components/AddGroceryItem.js | 22 + .../src/main/ui/src/components/AddTodo.js | 22 + .../src/main/ui/src/components/App.js | 22 + .../src/main/ui/src/components/FilterLink.js | 22 + .../src/main/ui/src/components/Footer.js | 22 + .../src/main/ui/src/components/Link.js | 22 + .../src/main/ui/src/components/Todo.js | 22 + .../src/main/ui/src/components/TodoList.js | 22 + .../ui/src/components/VisibleGroceryList.js | 22 + .../main/ui/src/components/VisibleTodoList.js | 22 + component-object/src/main/ui/src/index.js | 22 + .../src/main/ui/src/reducers/groceryList.js | 22 + .../src/main/ui/src/reducers/index.js | 22 + .../src/main/ui/src/reducers/todos.js | 22 + .../main/ui/src/reducers/visibilityFilter.js | 22 + .../src/main/ui/webpack.config.babel.js | 22 + .../iluwatar/component/AddItemComponent.java | 48 +- .../component/ItemsListComponent.java | 99 +++-- .../com/iluwatar/component/TodoAppTest.java | 413 ++++++++++-------- .../iluwatar/component/TodoPageObject.java | 131 +++--- 28 files changed, 953 insertions(+), 304 deletions(-) diff --git a/component-object/pom.xml b/component-object/pom.xml index bb00d89b4..3c8d267be 100644 --- a/component-object/pom.xml +++ b/component-object/pom.xml @@ -1,4 +1,28 @@ + 4.0.0 @@ -30,6 +54,16 @@ 1.4.6 test + + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter-engine + test + diff --git a/component-object/src/main/java/com/iluwatar/component/app/TodoApp.java b/component-object/src/main/java/com/iluwatar/component/app/TodoApp.java index 943fdcbcf..2f6194671 100644 --- a/component-object/src/main/java/com/iluwatar/component/app/TodoApp.java +++ b/component-object/src/main/java/com/iluwatar/component/app/TodoApp.java @@ -1,12 +1,49 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.component.app; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +/** + * Web development is shifting more and more towards reusable components. + * Frameworks like React, Polymer, Angular, Ember and others provide various + * component friendly abstractions to make front-end code-bases more maintainable. + * So our web applications are now full of “widgets” that have same behavior. + * We can use component various times on single web page or re-use it on various web pages. + * Component Object pattern provides an abstraction which covers functionality of + * single component and reuse it across end-to-end tests. When we have various same + * components on single web page, we are going to use various Component Objects of + * same type per Page Object. + * + */ @SpringBootApplication public class TodoApp { - public static void main(String[] args) { - SpringApplication.run(TodoApp.class, args); - } + /** + * Program entry point + */ + public static void main(String[] args) { + SpringApplication.run(TodoApp.class, args); + } } diff --git a/component-object/src/main/resources/application.properties b/component-object/src/main/resources/application.properties index e69de29bb..50e26d574 100644 --- a/component-object/src/main/resources/application.properties +++ b/component-object/src/main/resources/application.properties @@ -0,0 +1,23 @@ +# +# The MIT License +# Copyright (c) 2014 Ilkka Seppälä +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# + diff --git a/component-object/src/main/resources/static/dist/bundle.js b/component-object/src/main/resources/static/dist/bundle.js index 9469a9dcf..b2cae112e 100644 --- a/component-object/src/main/resources/static/dist/bundle.js +++ b/component-object/src/main/resources/static/dist/bundle.js @@ -1,3 +1,25 @@ +/* + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; diff --git a/component-object/src/main/resources/static/index.html b/component-object/src/main/resources/static/index.html index 33bee3407..f0db241f6 100644 --- a/component-object/src/main/resources/static/index.html +++ b/component-object/src/main/resources/static/index.html @@ -1,3 +1,27 @@ + diff --git a/component-object/src/main/ui/devServer.js b/component-object/src/main/ui/devServer.js index 242952529..511a84e79 100644 --- a/component-object/src/main/ui/devServer.js +++ b/component-object/src/main/ui/devServer.js @@ -1,3 +1,25 @@ +/* + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ import path from 'path'; import webpack from 'webpack'; import webpackDevMiddleware from 'webpack-dev-middleware'; diff --git a/component-object/src/main/ui/index.html b/component-object/src/main/ui/index.html index 527ff97df..d58721ef2 100644 --- a/component-object/src/main/ui/index.html +++ b/component-object/src/main/ui/index.html @@ -1,3 +1,27 @@ + diff --git a/component-object/src/main/ui/src/actions/index.js b/component-object/src/main/ui/src/actions/index.js index 81616d533..11a0206d1 100644 --- a/component-object/src/main/ui/src/actions/index.js +++ b/component-object/src/main/ui/src/actions/index.js @@ -1,3 +1,25 @@ +/* + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ let nextTodoId = 0; export const addTodo = (text) => { return { diff --git a/component-object/src/main/ui/src/components/AddGroceryItem.js b/component-object/src/main/ui/src/components/AddGroceryItem.js index 9de9cbd08..3a2571f04 100644 --- a/component-object/src/main/ui/src/components/AddGroceryItem.js +++ b/component-object/src/main/ui/src/components/AddGroceryItem.js @@ -1,3 +1,25 @@ +/* + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ import React, { PropTypes } from 'react'; import { connect } from 'react-redux'; import { addGroceryItem } from '../actions'; diff --git a/component-object/src/main/ui/src/components/AddTodo.js b/component-object/src/main/ui/src/components/AddTodo.js index 48e959825..973f3ff0a 100644 --- a/component-object/src/main/ui/src/components/AddTodo.js +++ b/component-object/src/main/ui/src/components/AddTodo.js @@ -1,3 +1,25 @@ +/* + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ import React, { PropTypes } from 'react'; import { connect } from 'react-redux'; import { addTodo } from '../actions'; diff --git a/component-object/src/main/ui/src/components/App.js b/component-object/src/main/ui/src/components/App.js index 853ee9f2e..e3fc95c61 100644 --- a/component-object/src/main/ui/src/components/App.js +++ b/component-object/src/main/ui/src/components/App.js @@ -1,3 +1,25 @@ +/* + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ import React from 'react'; import Footer from './Footer'; import AddTodo from './AddTodo'; diff --git a/component-object/src/main/ui/src/components/FilterLink.js b/component-object/src/main/ui/src/components/FilterLink.js index 65beb8224..575a42acf 100644 --- a/component-object/src/main/ui/src/components/FilterLink.js +++ b/component-object/src/main/ui/src/components/FilterLink.js @@ -1,3 +1,25 @@ +/* + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ import { connect } from 'react-redux'; import { setVisibilityFilter } from '../actions'; import Link from './Link'; diff --git a/component-object/src/main/ui/src/components/Footer.js b/component-object/src/main/ui/src/components/Footer.js index 7a57d424c..d4456cfca 100644 --- a/component-object/src/main/ui/src/components/Footer.js +++ b/component-object/src/main/ui/src/components/Footer.js @@ -1,3 +1,25 @@ +/* + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ import React from 'react'; import FilterLink from './FilterLink'; diff --git a/component-object/src/main/ui/src/components/Link.js b/component-object/src/main/ui/src/components/Link.js index a0b925adb..de18ea9e8 100644 --- a/component-object/src/main/ui/src/components/Link.js +++ b/component-object/src/main/ui/src/components/Link.js @@ -1,3 +1,25 @@ +/* + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ import React, { PropTypes } from 'react'; const Link = ({ active, children, onClick }) => { diff --git a/component-object/src/main/ui/src/components/Todo.js b/component-object/src/main/ui/src/components/Todo.js index 3a6067187..6ae5d6eba 100644 --- a/component-object/src/main/ui/src/components/Todo.js +++ b/component-object/src/main/ui/src/components/Todo.js @@ -1,3 +1,25 @@ +/* + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ import React, { PropTypes } from 'react'; const Todo = ({ onClick, completed, text }) => ( diff --git a/component-object/src/main/ui/src/components/TodoList.js b/component-object/src/main/ui/src/components/TodoList.js index acd0705e1..1373baf75 100644 --- a/component-object/src/main/ui/src/components/TodoList.js +++ b/component-object/src/main/ui/src/components/TodoList.js @@ -1,3 +1,25 @@ +/* + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ import React, { PropTypes } from 'react'; import Todo from './Todo'; diff --git a/component-object/src/main/ui/src/components/VisibleGroceryList.js b/component-object/src/main/ui/src/components/VisibleGroceryList.js index 235fc4ebe..9bac09aa0 100644 --- a/component-object/src/main/ui/src/components/VisibleGroceryList.js +++ b/component-object/src/main/ui/src/components/VisibleGroceryList.js @@ -1,3 +1,25 @@ +/* + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ import { connect } from 'react-redux'; import { toggleGroceryItem } from '../actions'; import TodoList from './TodoList'; diff --git a/component-object/src/main/ui/src/components/VisibleTodoList.js b/component-object/src/main/ui/src/components/VisibleTodoList.js index 1147dda00..42a44a2c1 100644 --- a/component-object/src/main/ui/src/components/VisibleTodoList.js +++ b/component-object/src/main/ui/src/components/VisibleTodoList.js @@ -1,3 +1,25 @@ +/* + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ import { connect } from 'react-redux'; import { toggleTodo } from '../actions'; import TodoList from './TodoList'; diff --git a/component-object/src/main/ui/src/index.js b/component-object/src/main/ui/src/index.js index 00cc1c8fa..375c2f731 100644 --- a/component-object/src/main/ui/src/index.js +++ b/component-object/src/main/ui/src/index.js @@ -1,3 +1,25 @@ +/* + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ import 'babel-polyfill'; import React from 'react'; import { render } from 'react-dom'; diff --git a/component-object/src/main/ui/src/reducers/groceryList.js b/component-object/src/main/ui/src/reducers/groceryList.js index 20d7f663f..f0150fe4b 100644 --- a/component-object/src/main/ui/src/reducers/groceryList.js +++ b/component-object/src/main/ui/src/reducers/groceryList.js @@ -1,3 +1,25 @@ +/* + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ const groceryItem = (state, action) => { switch (action.type) { case 'ADD_GROCERY_ITEM': diff --git a/component-object/src/main/ui/src/reducers/index.js b/component-object/src/main/ui/src/reducers/index.js index 81ebc32c4..eae959366 100644 --- a/component-object/src/main/ui/src/reducers/index.js +++ b/component-object/src/main/ui/src/reducers/index.js @@ -1,3 +1,25 @@ +/* + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ import { combineReducers } from 'redux'; import todos from './todos'; import groceryList from './groceryList'; diff --git a/component-object/src/main/ui/src/reducers/todos.js b/component-object/src/main/ui/src/reducers/todos.js index d3484d1fd..cc5434f83 100644 --- a/component-object/src/main/ui/src/reducers/todos.js +++ b/component-object/src/main/ui/src/reducers/todos.js @@ -1,3 +1,25 @@ +/* + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ const todo = (state, action) => { switch (action.type) { case 'ADD_TODO': diff --git a/component-object/src/main/ui/src/reducers/visibilityFilter.js b/component-object/src/main/ui/src/reducers/visibilityFilter.js index f0801e036..354cf730c 100644 --- a/component-object/src/main/ui/src/reducers/visibilityFilter.js +++ b/component-object/src/main/ui/src/reducers/visibilityFilter.js @@ -1,3 +1,25 @@ +/* + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ const visibilityFilter = (state = 'SHOW_ALL', action) => { switch (action.type) { case 'SET_VISIBILITY_FILTER': diff --git a/component-object/src/main/ui/webpack.config.babel.js b/component-object/src/main/ui/webpack.config.babel.js index a1389cad8..5f846ef91 100644 --- a/component-object/src/main/ui/webpack.config.babel.js +++ b/component-object/src/main/ui/webpack.config.babel.js @@ -1,3 +1,25 @@ +/* + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ import path from 'path'; export default { diff --git a/component-object/src/test/java/com/iluwatar/component/AddItemComponent.java b/component-object/src/test/java/com/iluwatar/component/AddItemComponent.java index 42df7427d..5494a95c1 100644 --- a/component-object/src/test/java/com/iluwatar/component/AddItemComponent.java +++ b/component-object/src/test/java/com/iluwatar/component/AddItemComponent.java @@ -1,3 +1,25 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.component; import org.openqa.selenium.By; @@ -5,19 +27,19 @@ import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; class AddItemComponent { - private WebDriver driver; - private String containerCssSelector; + private WebDriver driver; + private String containerCssSelector; - AddItemComponent(WebDriver driver, String containerCssSelector) { - this.driver = driver; - this.containerCssSelector = containerCssSelector; - } + AddItemComponent(WebDriver driver, String containerCssSelector) { + this.driver = driver; + this.containerCssSelector = containerCssSelector; + } - AddItemComponent addItem(String todo) { - WebElement input = driver.findElement(By.cssSelector(containerCssSelector + " input")); - input.sendKeys(todo); - WebElement button = driver.findElement(By.cssSelector(containerCssSelector + " button")); - button.click(); - return this; - } + AddItemComponent addItem(String todo) { + WebElement input = driver.findElement(By.cssSelector(containerCssSelector + " input")); + input.sendKeys(todo); + WebElement button = driver.findElement(By.cssSelector(containerCssSelector + " button")); + button.click(); + return this; + } } diff --git a/component-object/src/test/java/com/iluwatar/component/ItemsListComponent.java b/component-object/src/test/java/com/iluwatar/component/ItemsListComponent.java index 4a970ff3f..c188c6639 100644 --- a/component-object/src/test/java/com/iluwatar/component/ItemsListComponent.java +++ b/component-object/src/test/java/com/iluwatar/component/ItemsListComponent.java @@ -1,54 +1,77 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.component; -import org.apache.commons.lang3.StringUtils; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; - -import java.util.List; - import static java.lang.String.format; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import java.util.List; + +import org.apache.commons.lang3.StringUtils; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + class ItemsListComponent { - private final WebDriver driver; - private final String containerCssSelector; + private final WebDriver driver; + private final String containerCssSelector; - ItemsListComponent(WebDriver driver, String containerCssSelector) { - this.driver = driver; - this.containerCssSelector = containerCssSelector; - } + ItemsListComponent(WebDriver driver, String containerCssSelector) { + this.driver = driver; + this.containerCssSelector = containerCssSelector; + } - ItemsListComponent clickOnItem(String todoItem) { - findElementWithText(todoItem).click(); - return this; - } + ItemsListComponent clickOnItem(String todoItem) { + findElementWithText(todoItem).click(); + return this; + } - ItemsListComponent verifyItemShown(String todoItem, boolean expectedStrikethrough) { - WebElement todoElement = findElementWithText(todoItem); - assertNotNull(todoElement); - boolean actualStrikethrough = todoElement.getAttribute("style").contains("text-decoration: line-through;"); - assertEquals(expectedStrikethrough, actualStrikethrough); - return this; - } + ItemsListComponent verifyItemShown(String todoItem, boolean expectedStrikethrough) { + WebElement todoElement = findElementWithText(todoItem); + assertNotNull(todoElement); + boolean actualStrikethrough = todoElement.getAttribute("style") + .contains("text-decoration: line-through;"); + assertEquals(expectedStrikethrough, actualStrikethrough); + return this; + } - ItemsListComponent verifyItemNotShown(String todoItem) { - assertTrue(findElementsWithText(todoItem).isEmpty()); - return this; - } + ItemsListComponent verifyItemNotShown(String todoItem) { + assertTrue(findElementsWithText(todoItem).isEmpty()); + return this; + } - private WebElement findElementWithText(String text) { - return driver.findElement(getConditionForText(text)); - } + private WebElement findElementWithText(String text) { + return driver.findElement(getConditionForText(text)); + } - private List findElementsWithText(String text) { - return driver.findElements(getConditionForText(text)); - } + private List findElementsWithText(String text) { + return driver.findElements(getConditionForText(text)); + } - private By getConditionForText(String text) { - String containerClassName = StringUtils.substring(containerCssSelector, 1); - return By.xpath(format("//*[@class='" + containerClassName + "']//*[text()='%s']", text)); - } + private By getConditionForText(String text) { + String containerClassName = StringUtils.substring(containerCssSelector, 1); + return By.xpath(format("//*[@class='" + containerClassName + "']//*[text()='%s']", text)); + } } diff --git a/component-object/src/test/java/com/iluwatar/component/TodoAppTest.java b/component-object/src/test/java/com/iluwatar/component/TodoAppTest.java index 8c1d5fd89..929684b8d 100644 --- a/component-object/src/test/java/com/iluwatar/component/TodoAppTest.java +++ b/component-object/src/test/java/com/iluwatar/component/TodoAppTest.java @@ -1,5 +1,29 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.component; +import com.iluwatar.component.app.TodoApp; + import io.github.bonigarcia.wdm.ChromeDriverManager; import org.junit.AfterClass; @@ -12,243 +36,244 @@ import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.boot.test.WebIntegrationTest; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import com.iluwatar.component.app.TodoApp; - +/** + * Tests various components. + */ @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = TodoApp.class) @WebIntegrationTest public class TodoAppTest { - private static WebDriver driver; + private static WebDriver driver; - @BeforeClass - public static void setUp() { - ChromeDriverManager.getInstance().setup(); - driver = new ChromeDriver(); - } + @BeforeClass + public static void setUp() { + ChromeDriverManager.getInstance().setup(); + driver = new ChromeDriver(); + } - @AfterClass - public static void tearDown() { - driver.quit(); - } + @AfterClass + public static void tearDown() { + driver.quit(); + } - @Test - public void testCreateTodos() { - // GIVEN - new TodoPageObject(driver).get() + @Test + public void testCreateTodos() { + // GIVEN + new TodoPageObject(driver).get() - // WHEN - .addTodo("Buy groceries") - .addTodo("Tidy up") + // WHEN + .addTodo("Buy groceries") + .addTodo("Tidy up") - // THEN - .getTodoList() - .verifyItemShown("Buy groceries", false) - .verifyItemShown("Tidy up", false); - } + // THEN + .getTodoList() + .verifyItemShown("Buy groceries", false) + .verifyItemShown("Tidy up", false); + } - @Test - public void testCompleteTodo() { - // GIVEN - new TodoPageObject(driver).get() - .addTodo("Buy groceries") - .addTodo("Tidy up") - .getTodoList() + @Test + public void testCompleteTodo() { + // GIVEN + new TodoPageObject(driver).get() + .addTodo("Buy groceries") + .addTodo("Tidy up") + .getTodoList() - // WHEN - .clickOnItem("Buy groceries") + // WHEN + .clickOnItem("Buy groceries") - // THEN - .verifyItemShown("Buy groceries", true) - .verifyItemShown("Tidy up", false); - } + // THEN + .verifyItemShown("Buy groceries", true) + .verifyItemShown("Tidy up", false); + } - @Test - public void testSelectTodosActive() { - // GIVEN - TodoPageObject todoPage = new TodoPageObject(driver).get(); + @Test + public void testSelectTodosActive() { + // GIVEN + TodoPageObject todoPage = new TodoPageObject(driver).get(); - todoPage - .addTodo("Buy groceries") - .addTodo("Tidy up") - .getTodoList() - .clickOnItem("Buy groceries"); + todoPage + .addTodo("Buy groceries") + .addTodo("Tidy up") + .getTodoList() + .clickOnItem("Buy groceries"); - // WHEN - todoPage - .selectActive() + // WHEN + todoPage + .selectActive() - // THEN - .getTodoList() - .verifyItemNotShown("Buy groceries") - .verifyItemShown("Tidy up", false); - } + // THEN + .getTodoList() + .verifyItemNotShown("Buy groceries") + .verifyItemShown("Tidy up", false); + } - @Test - public void testSelectTodosCompleted() { - // GIVEN - TodoPageObject todoPage = new TodoPageObject(driver).get(); - todoPage - .addTodo("Buy groceries") - .addTodo("Tidy up") - .getTodoList() - .clickOnItem("Buy groceries"); + @Test + public void testSelectTodosCompleted() { + // GIVEN + TodoPageObject todoPage = new TodoPageObject(driver).get(); + todoPage + .addTodo("Buy groceries") + .addTodo("Tidy up") + .getTodoList() + .clickOnItem("Buy groceries"); - // WHEN - todoPage - .selectCompleted() + // WHEN + todoPage + .selectCompleted() - // THEN - .getTodoList() - .verifyItemShown("Buy groceries", true) - .verifyItemNotShown("Tidy up"); - } + // THEN + .getTodoList() + .verifyItemShown("Buy groceries", true) + .verifyItemNotShown("Tidy up"); + } - @Test - public void testSelectTodosAll() { - // GIVEN - TodoPageObject todoPage = new TodoPageObject(driver).get(); - todoPage - .addTodo("Buy groceries") - .addTodo("Tidy up") - .getTodoList() - .clickOnItem("Buy groceries"); - todoPage - .selectCompleted() + @Test + public void testSelectTodosAll() { + // GIVEN + TodoPageObject todoPage = new TodoPageObject(driver).get(); + todoPage + .addTodo("Buy groceries") + .addTodo("Tidy up") + .getTodoList() + .clickOnItem("Buy groceries"); + todoPage + .selectCompleted() - // WHEN - .selectAll() + // WHEN + .selectAll() - // THEN - .getTodoList() - .verifyItemShown("Buy groceries", true) - .verifyItemShown("Tidy up", false); - } + // THEN + .getTodoList() + .verifyItemShown("Buy groceries", true) + .verifyItemShown("Tidy up", false); + } - @Test - public void testCreateGroceryItems() { - // GIVEN - new TodoPageObject(driver).get() + @Test + public void testCreateGroceryItems() { + // GIVEN + new TodoPageObject(driver).get() - // WHEN - .addGroceryItem("avocados") - .addGroceryItem("tomatoes") + // WHEN + .addGroceryItem("avocados") + .addGroceryItem("tomatoes") - // THEN - .getGroceryList() - .verifyItemShown("avocados", false) - .verifyItemShown("tomatoes", false); - } + // THEN + .getGroceryList() + .verifyItemShown("avocados", false) + .verifyItemShown("tomatoes", false); + } - @Test - public void testCompleteGroceryItem() { - // GIVEN - new TodoPageObject(driver).get() - .addGroceryItem("avocados") - .addGroceryItem("tomatoes") - .getGroceryList() + @Test + public void testCompleteGroceryItem() { + // GIVEN + new TodoPageObject(driver).get() + .addGroceryItem("avocados") + .addGroceryItem("tomatoes") + .getGroceryList() - // WHEN - .clickOnItem("avocados") + // WHEN + .clickOnItem("avocados") - // THEN - .verifyItemShown("avocados", true) - .verifyItemShown("tomatoes", false); - } + // THEN + .verifyItemShown("avocados", true) + .verifyItemShown("tomatoes", false); + } - @Test - public void testSelectGroceryItemsActive() { - // GIVEN - TodoPageObject todoPage = new TodoPageObject(driver).get(); + @Test + public void testSelectGroceryItemsActive() { + // GIVEN + TodoPageObject todoPage = new TodoPageObject(driver).get(); - todoPage - .addGroceryItem("avocados") - .addGroceryItem("tomatoes") - .getGroceryList() - .clickOnItem("avocados"); + todoPage + .addGroceryItem("avocados") + .addGroceryItem("tomatoes") + .getGroceryList() + .clickOnItem("avocados"); - // WHEN - todoPage - .selectActive() + // WHEN + todoPage + .selectActive() - // THEN - .getGroceryList() - .verifyItemNotShown("avocados") - .verifyItemShown("tomatoes", false); - } + // THEN + .getGroceryList() + .verifyItemNotShown("avocados") + .verifyItemShown("tomatoes", false); + } - @Test - public void testSelectGroceryItemsCompleted() { - // GIVEN - TodoPageObject todoPage = new TodoPageObject(driver).get(); - todoPage - .addGroceryItem("avocados") - .addGroceryItem("tomatoes") - .getGroceryList() - .clickOnItem("avocados"); + @Test + public void testSelectGroceryItemsCompleted() { + // GIVEN + TodoPageObject todoPage = new TodoPageObject(driver).get(); + todoPage + .addGroceryItem("avocados") + .addGroceryItem("tomatoes") + .getGroceryList() + .clickOnItem("avocados"); - // WHEN - todoPage - .selectCompleted() + // WHEN + todoPage + .selectCompleted() - // THEN - .getGroceryList() - .verifyItemShown("avocados", true) - .verifyItemNotShown("tomatoes"); - } + // THEN + .getGroceryList() + .verifyItemShown("avocados", true) + .verifyItemNotShown("tomatoes"); + } - @Test - public void testSelectGroceryItemsAll() { - // GIVEN - TodoPageObject todoPage = new TodoPageObject(driver).get(); - todoPage - .addGroceryItem("avocados") - .addGroceryItem("tomatoes") - .getGroceryList() - .clickOnItem("avocados"); - todoPage - .selectCompleted() + @Test + public void testSelectGroceryItemsAll() { + // GIVEN + TodoPageObject todoPage = new TodoPageObject(driver).get(); + todoPage + .addGroceryItem("avocados") + .addGroceryItem("tomatoes") + .getGroceryList() + .clickOnItem("avocados"); + todoPage + .selectCompleted() - // WHEN - .selectAll() + // WHEN + .selectAll() - // THEN - .getGroceryList() - .verifyItemShown("avocados", true) - .verifyItemShown("tomatoes", false); - } + // THEN + .getGroceryList() + .verifyItemShown("avocados", true) + .verifyItemShown("tomatoes", false); + } - @Test - public void testSelectCombinedItemsActive() { - // GIVEN - TodoPageObject todoPage = new TodoPageObject(driver).get(); + @Test + public void testSelectCombinedItemsActive() { + // GIVEN + TodoPageObject todoPage = new TodoPageObject(driver).get(); - todoPage - .addTodo("Buy groceries") - .addTodo("Tidy up") - .addGroceryItem("avocados") - .addGroceryItem("tomatoes"); + todoPage + .addTodo("Buy groceries") + .addTodo("Tidy up") + .addGroceryItem("avocados") + .addGroceryItem("tomatoes"); - todoPage - .getGroceryList() - .clickOnItem("avocados"); + todoPage + .getGroceryList() + .clickOnItem("avocados"); - todoPage - .getTodoList() - .clickOnItem("Tidy up"); + todoPage + .getTodoList() + .clickOnItem("Tidy up"); - // WHEN - todoPage - .selectActive(); + // WHEN + todoPage + .selectActive(); - // THEN - todoPage - .getTodoList() - .verifyItemShown("Buy groceries", false) - .verifyItemNotShown("Tidy up"); + // THEN + todoPage + .getTodoList() + .verifyItemShown("Buy groceries", false) + .verifyItemNotShown("Tidy up"); - todoPage - .getGroceryList() - .verifyItemNotShown("avocados") - .verifyItemShown("tomatoes", false); - } + todoPage + .getGroceryList() + .verifyItemNotShown("avocados") + .verifyItemShown("tomatoes", false); + } } diff --git a/component-object/src/test/java/com/iluwatar/component/TodoPageObject.java b/component-object/src/test/java/com/iluwatar/component/TodoPageObject.java index 163d58975..1bac5625d 100644 --- a/component-object/src/test/java/com/iluwatar/component/TodoPageObject.java +++ b/component-object/src/test/java/com/iluwatar/component/TodoPageObject.java @@ -1,79 +1,98 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.component; +import static java.lang.String.format; + import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; -import java.util.List; - -import static java.lang.String.format; -import static org.junit.Assert.*; - class TodoPageObject { - private final WebDriver driver; - private final WebDriverWait wait; - private final ItemsListComponent todoItemsList; - private final AddItemComponent addTodoItemComponent; - private final ItemsListComponent groceryItemsList; - private final AddItemComponent addGroceryItemComponent; + private final WebDriver driver; + private final WebDriverWait wait; + private final ItemsListComponent todoItemsList; + private final AddItemComponent addTodoItemComponent; + private final ItemsListComponent groceryItemsList; + private final AddItemComponent addGroceryItemComponent; - TodoPageObject(WebDriver driver) { - this.driver = driver; - this.wait = new WebDriverWait(driver, 10); - todoItemsList = new ItemsListComponent(driver, ".todo-list"); - addTodoItemComponent = new AddItemComponent(driver, ".add-todo"); - groceryItemsList = new ItemsListComponent(driver, ".grocery-list"); - addGroceryItemComponent = new AddItemComponent(driver, ".add-grocery-item"); - } + TodoPageObject(WebDriver driver) { + this.driver = driver; + this.wait = new WebDriverWait(driver, 10); + todoItemsList = new ItemsListComponent(driver, ".todo-list"); + addTodoItemComponent = new AddItemComponent(driver, ".add-todo"); + groceryItemsList = new ItemsListComponent(driver, ".grocery-list"); + addGroceryItemComponent = new AddItemComponent(driver, ".add-grocery-item"); + } - TodoPageObject get() { - driver.get("localhost:8080"); - wait.until(ExpectedConditions.elementToBeClickable(By.tagName("button"))); - return this; - } + TodoPageObject get() { + driver.get("localhost:8080"); + wait.until(ExpectedConditions.elementToBeClickable(By.tagName("button"))); + return this; + } - TodoPageObject selectAll() { - findElementWithText("All").click(); - return this; - } + TodoPageObject selectAll() { + findElementWithText("All").click(); + return this; + } - TodoPageObject selectActive() { - findElementWithText("Active").click(); - return this; - } + TodoPageObject selectActive() { + findElementWithText("Active").click(); + return this; + } - TodoPageObject selectCompleted() { - findElementWithText("Completed").click(); - return this; - } + TodoPageObject selectCompleted() { + findElementWithText("Completed").click(); + return this; + } - TodoPageObject addTodo(String todoName) { - addTodoItemComponent.addItem(todoName); - return this; - } + TodoPageObject addTodo(String todoName) { + addTodoItemComponent.addItem(todoName); + return this; + } - TodoPageObject addGroceryItem(String todoName) { - addGroceryItemComponent.addItem(todoName); - return this; - } + TodoPageObject addGroceryItem(String todoName) { + addGroceryItemComponent.addItem(todoName); + return this; + } - ItemsListComponent getTodoList() { - return todoItemsList; - } + ItemsListComponent getTodoList() { + return todoItemsList; + } - ItemsListComponent getGroceryList() { - return groceryItemsList; - } + ItemsListComponent getGroceryList() { + return groceryItemsList; + } - private WebElement findElementWithText(String text) { - return driver.findElement(getConditionForText(text)); - } + private WebElement findElementWithText(String text) { + return driver.findElement(getConditionForText(text)); + } - private By getConditionForText(String text) { - return By.xpath(format("//*[text()='%s']", text)); - } + private By getConditionForText(String text) { + return By.xpath(format("//*[text()='%s']", text)); + } }