#509: Checkstyle Fixes

This commit is contained in:
nikhilbarar 2018-06-11 01:56:32 +05:30
parent 971a74e13a
commit c48a1e9193
28 changed files with 953 additions and 304 deletions

View File

@ -1,4 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
@ -30,6 +54,16 @@
<version>1.4.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>

View File

@ -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);
}
}

View File

@ -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.
#

View File

@ -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 = {};

View File

@ -1,3 +1,27 @@
<!--
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.
-->
<!DOCTYPE html>
<html>
<head>

View File

@ -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';

View File

@ -1,3 +1,27 @@
<!--
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.
-->
<!DOCTYPE html>
<html>
<head>

View File

@ -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 {

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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 }) => {

View File

@ -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 }) => (

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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':

View File

@ -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';

View File

@ -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':

View File

@ -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':

View File

@ -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 {

View File

@ -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;
}
}

View File

@ -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<WebElement> findElementsWithText(String text) {
return driver.findElements(getConditionForText(text));
}
private List<WebElement> 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));
}
}

View File

@ -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);
}
}

View File

@ -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));
}
}