From 9ad123a6558e1ac200c705a2f1f71460270d81a2 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sun, 9 Jul 2017 06:27:31 +0200 Subject: [PATCH 01/89] Versions update (#2234) * Mockito refactor * Httpclient refactor * Refactor json-path * MongoDB Refactor --- javax-servlets/pom.xml | 2 +- .../servlets/FormServletLiveTest.java | 14 ++--- json-path/pom.xml | 2 +- .../OperationIntegrationTest.java | 30 +++++------ .../jsonpath/introduction/ServiceTest.java | 19 ++++--- .../CollaboratorForPartialMocking.java | 8 +-- .../CollaboratorWithFinalMethods.java | 4 +- .../CollaboratorWithStaticMethods.java | 8 +-- .../MockitoAnnotationIntegrationTest.java | 7 +-- .../mockito/MockitoMockIntegrationTest.java | 2 +- .../org/baeldung/mockito/MyDictionary.java | 10 ++-- .../java/org/baeldung/mockito/MyList.java | 2 +- .../org/baeldung/annotation/CascadeSave.java | 1 - .../java/org/baeldung/config/MongoConfig.java | 9 ++-- .../baeldung/config/SimpleMongoConfig.java | 5 +- .../converter/UserWriterConverter.java | 7 ++- .../org/baeldung/event/CascadeCallback.java | 8 +-- .../baeldung/repository/UserRepository.java | 12 ++--- .../aggregation/ZipsAggregationLiveTest.java | 53 ++++++++++--------- .../org/baeldung/gridfs/GridFSLiveTest.java | 32 ++++++----- .../mongotemplate/DocumentQueryLiveTest.java | 12 ++--- .../MongoTemplateProjectionLiveTest.java | 30 +++++------ .../MongoTemplateQueryLiveTest.java | 12 ++--- 23 files changed, 141 insertions(+), 148 deletions(-) diff --git a/javax-servlets/pom.xml b/javax-servlets/pom.xml index 1934102c68..7407666309 100644 --- a/javax-servlets/pom.xml +++ b/javax-servlets/pom.xml @@ -39,7 +39,7 @@ 3.1.0 - 4.5.2 + 4.5.3 \ No newline at end of file diff --git a/javax-servlets/src/test/java/com/baeldung/servlets/FormServletLiveTest.java b/javax-servlets/src/test/java/com/baeldung/servlets/FormServletLiveTest.java index dca725ae32..120a555c5b 100644 --- a/javax-servlets/src/test/java/com/baeldung/servlets/FormServletLiveTest.java +++ b/javax-servlets/src/test/java/com/baeldung/servlets/FormServletLiveTest.java @@ -1,24 +1,24 @@ package com.baeldung.servlets; -import static org.junit.Assert.assertEquals; - -import java.util.ArrayList; -import java.util.List; - import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; -import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.message.BasicNameValuePair; import org.junit.Test; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertEquals; + public class FormServletLiveTest { @Test public void whenPostRequestUsingHttpClient_thenCorrect() throws Exception { - HttpClient client = new DefaultHttpClient(); + HttpClient client = HttpClientBuilder.create().build(); HttpPost method = new HttpPost("http://localhost:8080/calculateServlet"); List nvps = new ArrayList<>(); diff --git a/json-path/pom.xml b/json-path/pom.xml index e81bc1dcf9..8384ba68ed 100644 --- a/json-path/pom.xml +++ b/json-path/pom.xml @@ -23,6 +23,6 @@ - 2.2.0 + 2.4.0 \ No newline at end of file diff --git a/json-path/src/test/java/com/baeldung/jsonpath/introduction/OperationIntegrationTest.java b/json-path/src/test/java/com/baeldung/jsonpath/introduction/OperationIntegrationTest.java index cb5c695cd8..855f524dbe 100644 --- a/json-path/src/test/java/com/baeldung/jsonpath/introduction/OperationIntegrationTest.java +++ b/json-path/src/test/java/com/baeldung/jsonpath/introduction/OperationIntegrationTest.java @@ -1,10 +1,10 @@ package com.baeldung.jsonpath.introduction; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.CoreMatchers.not; - +import com.jayway.jsonpath.Criteria; +import com.jayway.jsonpath.DocumentContext; +import com.jayway.jsonpath.Filter; +import com.jayway.jsonpath.JsonPath; +import com.jayway.jsonpath.Predicate; import org.junit.Test; import java.io.InputStream; @@ -12,15 +12,14 @@ import java.util.List; import java.util.Map; import java.util.Scanner; -import com.jayway.jsonpath.Criteria; -import com.jayway.jsonpath.DocumentContext; -import com.jayway.jsonpath.Filter; -import com.jayway.jsonpath.JsonPath; -import com.jayway.jsonpath.Predicate; +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.not; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; public class OperationIntegrationTest { - InputStream jsonInputStream = this.getClass().getClassLoader().getResourceAsStream("intro_api.json"); - String jsonDataSourceString = new Scanner(jsonInputStream, "UTF-8").useDelimiter("\\Z").next(); + private InputStream jsonInputStream = this.getClass().getClassLoader().getResourceAsStream("intro_api.json"); + private String jsonDataSourceString = new Scanner(jsonInputStream, "UTF-8").useDelimiter("\\Z").next(); @Test public void givenJsonPathWithoutPredicates_whenReading_thenCorrect() { @@ -46,12 +45,7 @@ public class OperationIntegrationTest { @Test public void givenJsonPathWithCustomizedPredicate_whenReading_thenCorrect() { - Predicate expensivePredicate = new Predicate() { - public boolean apply(PredicateContext context) { - String value = context.item(Map.class).get("price").toString(); - return Float.valueOf(value) > 20.00; - } - }; + Predicate expensivePredicate = context -> Float.valueOf(context.item(Map.class).get("price").toString()) > 20.00; List> expensive = JsonPath.parse(jsonDataSourceString).read("$['book'][?]", expensivePredicate); predicateUsageAssertionHelper(expensive); } diff --git a/json-path/src/test/java/com/baeldung/jsonpath/introduction/ServiceTest.java b/json-path/src/test/java/com/baeldung/jsonpath/introduction/ServiceTest.java index 868acac8d0..d5cfa50e80 100644 --- a/json-path/src/test/java/com/baeldung/jsonpath/introduction/ServiceTest.java +++ b/json-path/src/test/java/com/baeldung/jsonpath/introduction/ServiceTest.java @@ -1,9 +1,9 @@ package com.baeldung.jsonpath.introduction; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.hamcrest.CoreMatchers.containsString; - +import com.jayway.jsonpath.Configuration; +import com.jayway.jsonpath.DocumentContext; +import com.jayway.jsonpath.JsonPath; +import com.jayway.jsonpath.Option; import org.junit.Test; import java.io.InputStream; @@ -13,14 +13,13 @@ import java.util.List; import java.util.Map; import java.util.Scanner; -import com.jayway.jsonpath.Configuration; -import com.jayway.jsonpath.DocumentContext; -import com.jayway.jsonpath.JsonPath; -import com.jayway.jsonpath.Option; +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; public class ServiceTest { - InputStream jsonInputStream = this.getClass().getClassLoader().getResourceAsStream("intro_service.json"); - String jsonString = new Scanner(jsonInputStream, "UTF-8").useDelimiter("\\Z").next(); + private InputStream jsonInputStream = this.getClass().getClassLoader().getResourceAsStream("intro_service.json"); + private String jsonString = new Scanner(jsonInputStream, "UTF-8").useDelimiter("\\Z").next(); @Test public void givenId_whenRequestingRecordData_thenSucceed() { diff --git a/mockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorForPartialMocking.java b/mockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorForPartialMocking.java index 771444f13d..9a3bc8875b 100644 --- a/mockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorForPartialMocking.java +++ b/mockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorForPartialMocking.java @@ -1,12 +1,12 @@ package com.baeldung.powermockito.introduction; -public class CollaboratorForPartialMocking { +class CollaboratorForPartialMocking { - public static String staticMethod() { + static String staticMethod() { return "Hello Baeldung!"; } - public final String finalMethod() { + final String finalMethod() { return "Hello Baeldung!"; } @@ -14,7 +14,7 @@ public class CollaboratorForPartialMocking { return "Hello Baeldung!"; } - public String privateMethodCaller() { + String privateMethodCaller() { return privateMethod() + " Welcome to the Java world."; } } \ No newline at end of file diff --git a/mockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithFinalMethods.java b/mockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithFinalMethods.java index 8287454782..f748b6a6fc 100644 --- a/mockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithFinalMethods.java +++ b/mockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithFinalMethods.java @@ -1,8 +1,8 @@ package com.baeldung.powermockito.introduction; -public class CollaboratorWithFinalMethods { +class CollaboratorWithFinalMethods { - public final String helloMethod() { + final String helloMethod() { return "Hello World!"; } diff --git a/mockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithStaticMethods.java b/mockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithStaticMethods.java index 2795ae97f1..1f416aefa7 100644 --- a/mockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithStaticMethods.java +++ b/mockito/src/test/java/com/baeldung/powermockito/introduction/CollaboratorWithStaticMethods.java @@ -1,16 +1,16 @@ package com.baeldung.powermockito.introduction; -public class CollaboratorWithStaticMethods { +class CollaboratorWithStaticMethods { - public static String firstMethod(String name) { + static String firstMethod(String name) { return "Hello " + name + " !"; } - public static String secondMethod() { + static String secondMethod() { return "Hello no one!"; } - public static String thirdMethod() { + static String thirdMethod() { return "Hello no one again!"; } } \ No newline at end of file diff --git a/mockito/src/test/java/org/baeldung/mockito/MockitoAnnotationIntegrationTest.java b/mockito/src/test/java/org/baeldung/mockito/MockitoAnnotationIntegrationTest.java index 4e090e6652..5e083adbf5 100644 --- a/mockito/src/test/java/org/baeldung/mockito/MockitoAnnotationIntegrationTest.java +++ b/mockito/src/test/java/org/baeldung/mockito/MockitoAnnotationIntegrationTest.java @@ -17,7 +17,7 @@ public class MockitoAnnotationIntegrationTest { private List mockedList; @Spy - List spiedList = new ArrayList(); + private List spiedList = new ArrayList<>(); @Before public void init() { @@ -87,6 +87,7 @@ public class MockitoAnnotationIntegrationTest { } @Captor + private ArgumentCaptor argCaptor; @Test @@ -98,10 +99,10 @@ public class MockitoAnnotationIntegrationTest { } @Mock - Map wordMap; + private Map wordMap; @InjectMocks - MyDictionary dic = new MyDictionary(); + private MyDictionary dic = new MyDictionary(); @Test public void whenUseInjectMocksAnnotation_thenCorrect() { diff --git a/mockito/src/test/java/org/baeldung/mockito/MockitoMockIntegrationTest.java b/mockito/src/test/java/org/baeldung/mockito/MockitoMockIntegrationTest.java index 6ec3b34db5..f846907fd7 100644 --- a/mockito/src/test/java/org/baeldung/mockito/MockitoMockIntegrationTest.java +++ b/mockito/src/test/java/org/baeldung/mockito/MockitoMockIntegrationTest.java @@ -24,7 +24,7 @@ public class MockitoMockIntegrationTest { } @Rule - public ExpectedException thrown = ExpectedException.none(); + private ExpectedException thrown = ExpectedException.none(); @Test public void whenUsingSimpleMock_thenCorrect() { diff --git a/mockito/src/test/java/org/baeldung/mockito/MyDictionary.java b/mockito/src/test/java/org/baeldung/mockito/MyDictionary.java index a613b28f59..8a0ea92502 100644 --- a/mockito/src/test/java/org/baeldung/mockito/MyDictionary.java +++ b/mockito/src/test/java/org/baeldung/mockito/MyDictionary.java @@ -3,19 +3,19 @@ package org.baeldung.mockito; import java.util.HashMap; import java.util.Map; -public class MyDictionary { +class MyDictionary { - Map wordMap; + private Map wordMap; - public MyDictionary() { - wordMap = new HashMap(); + MyDictionary() { + wordMap = new HashMap<>(); } public void add(final String word, final String meaning) { wordMap.put(word, meaning); } - public String getMeaning(final String word) { + String getMeaning(final String word) { return wordMap.get(word); } } diff --git a/mockito/src/test/java/org/baeldung/mockito/MyList.java b/mockito/src/test/java/org/baeldung/mockito/MyList.java index 548596e6b6..be69ef8a8a 100644 --- a/mockito/src/test/java/org/baeldung/mockito/MyList.java +++ b/mockito/src/test/java/org/baeldung/mockito/MyList.java @@ -2,7 +2,7 @@ package org.baeldung.mockito; import java.util.AbstractList; -public class MyList extends AbstractList { +class MyList extends AbstractList { @Override public String get(final int index) { diff --git a/spring-data-mongodb/src/main/java/org/baeldung/annotation/CascadeSave.java b/spring-data-mongodb/src/main/java/org/baeldung/annotation/CascadeSave.java index 9fba40245b..aae0214d09 100644 --- a/spring-data-mongodb/src/main/java/org/baeldung/annotation/CascadeSave.java +++ b/spring-data-mongodb/src/main/java/org/baeldung/annotation/CascadeSave.java @@ -8,5 +8,4 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface CascadeSave { - } diff --git a/spring-data-mongodb/src/main/java/org/baeldung/config/MongoConfig.java b/spring-data-mongodb/src/main/java/org/baeldung/config/MongoConfig.java index 6910245b2b..80b177f4c9 100644 --- a/spring-data-mongodb/src/main/java/org/baeldung/config/MongoConfig.java +++ b/spring-data-mongodb/src/main/java/org/baeldung/config/MongoConfig.java @@ -1,8 +1,7 @@ package org.baeldung.config; -import java.util.ArrayList; -import java.util.List; - +import com.mongodb.Mongo; +import com.mongodb.MongoClient; import org.baeldung.converter.UserWriterConverter; import org.baeldung.event.CascadeSaveMongoEventListener; import org.baeldung.event.UserCascadeSaveMongoEventListener; @@ -14,8 +13,8 @@ import org.springframework.data.mongodb.core.convert.CustomConversions; import org.springframework.data.mongodb.gridfs.GridFsTemplate; import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; -import com.mongodb.Mongo; -import com.mongodb.MongoClient; +import java.util.ArrayList; +import java.util.List; @Configuration @EnableMongoRepositories(basePackages = "org.baeldung.repository") diff --git a/spring-data-mongodb/src/main/java/org/baeldung/config/SimpleMongoConfig.java b/spring-data-mongodb/src/main/java/org/baeldung/config/SimpleMongoConfig.java index 6140382f82..9653796d8d 100644 --- a/spring-data-mongodb/src/main/java/org/baeldung/config/SimpleMongoConfig.java +++ b/spring-data-mongodb/src/main/java/org/baeldung/config/SimpleMongoConfig.java @@ -1,13 +1,12 @@ package org.baeldung.config; +import com.mongodb.Mongo; +import com.mongodb.MongoClient; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; -import com.mongodb.Mongo; -import com.mongodb.MongoClient; - @Configuration @EnableMongoRepositories(basePackages = "org.baeldung.repository") public class SimpleMongoConfig { diff --git a/spring-data-mongodb/src/main/java/org/baeldung/converter/UserWriterConverter.java b/spring-data-mongodb/src/main/java/org/baeldung/converter/UserWriterConverter.java index 2dedda46ec..4a6970489e 100644 --- a/spring-data-mongodb/src/main/java/org/baeldung/converter/UserWriterConverter.java +++ b/spring-data-mongodb/src/main/java/org/baeldung/converter/UserWriterConverter.java @@ -1,11 +1,10 @@ package org.baeldung.converter; -import org.baeldung.model.User; -import org.springframework.core.convert.converter.Converter; -import org.springframework.stereotype.Component; - import com.mongodb.BasicDBObject; import com.mongodb.DBObject; +import org.baeldung.model.User; +import org.springframework.core.convert.converter.Converter; +import org.springframework.stereotype.Component; @Component public class UserWriterConverter implements Converter { diff --git a/spring-data-mongodb/src/main/java/org/baeldung/event/CascadeCallback.java b/spring-data-mongodb/src/main/java/org/baeldung/event/CascadeCallback.java index e01a1bc8c0..94cad4566a 100644 --- a/spring-data-mongodb/src/main/java/org/baeldung/event/CascadeCallback.java +++ b/spring-data-mongodb/src/main/java/org/baeldung/event/CascadeCallback.java @@ -12,7 +12,7 @@ public class CascadeCallback implements ReflectionUtils.FieldCallback { private Object source; private MongoOperations mongoOperations; - public CascadeCallback(final Object source, final MongoOperations mongoOperations) { + CascadeCallback(final Object source, final MongoOperations mongoOperations) { this.source = source; this.setMongoOperations(mongoOperations); } @@ -35,7 +35,7 @@ public class CascadeCallback implements ReflectionUtils.FieldCallback { } - public Object getSource() { + private Object getSource() { return source; } @@ -43,11 +43,11 @@ public class CascadeCallback implements ReflectionUtils.FieldCallback { this.source = source; } - public MongoOperations getMongoOperations() { + private MongoOperations getMongoOperations() { return mongoOperations; } - public void setMongoOperations(final MongoOperations mongoOperations) { + private void setMongoOperations(final MongoOperations mongoOperations) { this.mongoOperations = mongoOperations; } } diff --git a/spring-data-mongodb/src/main/java/org/baeldung/repository/UserRepository.java b/spring-data-mongodb/src/main/java/org/baeldung/repository/UserRepository.java index 7d51f7b6cc..8e442e8b7f 100644 --- a/spring-data-mongodb/src/main/java/org/baeldung/repository/UserRepository.java +++ b/spring-data-mongodb/src/main/java/org/baeldung/repository/UserRepository.java @@ -1,12 +1,12 @@ package org.baeldung.repository; -import java.util.List; - import org.baeldung.model.User; import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.mongodb.repository.Query; import org.springframework.data.querydsl.QueryDslPredicateExecutor; +import java.util.List; + public interface UserRepository extends MongoRepository, QueryDslPredicateExecutor { @Query("{ 'name' : ?0 }") List findUsersByName(String name); @@ -26,10 +26,10 @@ public interface UserRepository extends MongoRepository, QueryDslP List findByNameStartingWith(String regexp); List findByNameEndingWith(String regexp); - - @Query(value="{}", fields="{name : 1}") + + @Query(value = "{}", fields = "{name : 1}") List findNameAndId(); - - @Query(value="{}", fields="{_id : 0}") + + @Query(value = "{}", fields = "{_id : 0}") List findNameAndAgeExcludeId(); } diff --git a/spring-data-mongodb/src/test/java/org/baeldung/aggregation/ZipsAggregationLiveTest.java b/spring-data-mongodb/src/test/java/org/baeldung/aggregation/ZipsAggregationLiveTest.java index a25a904758..5686465c19 100644 --- a/spring-data-mongodb/src/test/java/org/baeldung/aggregation/ZipsAggregationLiveTest.java +++ b/spring-data-mongodb/src/test/java/org/baeldung/aggregation/ZipsAggregationLiveTest.java @@ -1,17 +1,10 @@ package org.baeldung.aggregation; -import static org.junit.Assert.*; -import static org.springframework.data.mongodb.core.aggregation.Aggregation.*; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.StreamSupport; - +import com.mongodb.DB; +import com.mongodb.DBCollection; +import com.mongodb.DBObject; +import com.mongodb.MongoClient; +import com.mongodb.util.JSON; import org.baeldung.aggregation.model.StatePopulation; import org.baeldung.config.MongoConfig; import org.junit.AfterClass; @@ -33,18 +26,30 @@ import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import com.mongodb.DB; -import com.mongodb.DBCollection; -import com.mongodb.DBObject; -import com.mongodb.MongoClient; -import com.mongodb.util.JSON; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.StreamSupport; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.springframework.data.mongodb.core.aggregation.Aggregation.group; +import static org.springframework.data.mongodb.core.aggregation.Aggregation.limit; +import static org.springframework.data.mongodb.core.aggregation.Aggregation.match; +import static org.springframework.data.mongodb.core.aggregation.Aggregation.newAggregation; +import static org.springframework.data.mongodb.core.aggregation.Aggregation.project; +import static org.springframework.data.mongodb.core.aggregation.Aggregation.sort; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = MongoConfig.class) public class ZipsAggregationLiveTest { private static MongoClient client; - + @Autowired private MongoTemplate mongoTemplate; @@ -58,7 +63,7 @@ public class ZipsAggregationLiveTest { InputStream zipsJsonStream = ZipsAggregationLiveTest.class.getResourceAsStream("/zips.json"); BufferedReader reader = new BufferedReader(new InputStreamReader(zipsJsonStream)); reader.lines() - .forEach(line -> zipsCollection.insert((DBObject) JSON.parse(line))); + .forEach(line -> zipsCollection.insert((DBObject) JSON.parse(line))); reader.close(); } @@ -95,7 +100,7 @@ public class ZipsAggregationLiveTest { * decreasing population */ List actualList = StreamSupport.stream(result.spliterator(), false) - .collect(Collectors.toList()); + .collect(Collectors.toList()); List expectedList = new ArrayList<>(actualList); Collections.sort(expectedList, (sp1, sp2) -> sp2.getStatePop() - sp1.getStatePop()); @@ -111,7 +116,7 @@ public class ZipsAggregationLiveTest { GroupOperation averageStatePop = group("_id.state").avg("cityPop").as("avgCityPop"); SortOperation sortByAvgPopAsc = sort(new Sort(Direction.ASC, "avgCityPop")); ProjectionOperation projectToMatchModel = project().andExpression("_id").as("state") - .andExpression("avgCityPop").as("statePop"); + .andExpression("avgCityPop").as("statePop"); LimitOperation limitToOnlyFirstDoc = limit(1); Aggregation aggregation = newAggregation(sumTotalCityPop, averageStatePop, sortByAvgPopAsc, limitToOnlyFirstDoc, projectToMatchModel); @@ -121,7 +126,7 @@ public class ZipsAggregationLiveTest { assertEquals("ND", smallestState.getState()); assertTrue(smallestState.getStatePop() - .equals(1645)); + .equals(1645)); } @Test @@ -130,8 +135,8 @@ public class ZipsAggregationLiveTest { GroupOperation sumZips = group("state").count().as("zipCount"); SortOperation sortByCount = sort(Direction.ASC, "zipCount"); GroupOperation groupFirstAndLast = group().first("_id").as("minZipState") - .first("zipCount").as("minZipCount").last("_id").as("maxZipState") - .last("zipCount").as("maxZipCount"); + .first("zipCount").as("minZipCount").last("_id").as("maxZipState") + .last("zipCount").as("maxZipCount"); Aggregation aggregation = newAggregation(sumZips, sortByCount, groupFirstAndLast); diff --git a/spring-data-mongodb/src/test/java/org/baeldung/gridfs/GridFSLiveTest.java b/spring-data-mongodb/src/test/java/org/baeldung/gridfs/GridFSLiveTest.java index 3853a406fb..88205ba7fd 100644 --- a/spring-data-mongodb/src/test/java/org/baeldung/gridfs/GridFSLiveTest.java +++ b/spring-data-mongodb/src/test/java/org/baeldung/gridfs/GridFSLiveTest.java @@ -1,19 +1,8 @@ package org.baeldung.gridfs; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.List; - -import org.baeldung.config.MongoConfig; +import com.mongodb.BasicDBObject; +import com.mongodb.DBObject; +import com.mongodb.gridfs.GridFSDBFile; import org.junit.After; import org.junit.Test; import org.junit.runner.RunWith; @@ -27,9 +16,18 @@ import org.springframework.data.mongodb.gridfs.GridFsTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import com.mongodb.BasicDBObject; -import com.mongodb.DBObject; -import com.mongodb.gridfs.GridFSDBFile; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.nullValue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; @ContextConfiguration("file:src/main/resources/mongoConfig.xml") @RunWith(SpringJUnit4ClassRunner.class) diff --git a/spring-data-mongodb/src/test/java/org/baeldung/mongotemplate/DocumentQueryLiveTest.java b/spring-data-mongodb/src/test/java/org/baeldung/mongotemplate/DocumentQueryLiveTest.java index df3ebcb2d2..729b0f6dfa 100644 --- a/spring-data-mongodb/src/test/java/org/baeldung/mongotemplate/DocumentQueryLiveTest.java +++ b/spring-data-mongodb/src/test/java/org/baeldung/mongotemplate/DocumentQueryLiveTest.java @@ -1,11 +1,5 @@ package org.baeldung.mongotemplate; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -import java.util.Iterator; -import java.util.List; - import org.baeldung.config.MongoConfig; import org.baeldung.model.EmailAddress; import org.baeldung.model.User; @@ -23,6 +17,12 @@ import org.springframework.data.mongodb.core.query.Query; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import java.util.Iterator; +import java.util.List; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = MongoConfig.class) public class DocumentQueryLiveTest { diff --git a/spring-data-mongodb/src/test/java/org/baeldung/mongotemplate/MongoTemplateProjectionLiveTest.java b/spring-data-mongodb/src/test/java/org/baeldung/mongotemplate/MongoTemplateProjectionLiveTest.java index 61115faede..2d2117afbb 100644 --- a/spring-data-mongodb/src/test/java/org/baeldung/mongotemplate/MongoTemplateProjectionLiveTest.java +++ b/spring-data-mongodb/src/test/java/org/baeldung/mongotemplate/MongoTemplateProjectionLiveTest.java @@ -1,9 +1,5 @@ package org.baeldung.mongotemplate; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - import org.baeldung.config.SimpleMongoConfig; import org.baeldung.model.User; import org.junit.After; @@ -16,6 +12,10 @@ import org.springframework.data.mongodb.core.query.Query; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = SimpleMongoConfig.class) public class MongoTemplateProjectionLiveTest { @@ -42,14 +42,14 @@ public class MongoTemplateProjectionLiveTest { final Query query = new Query(); query.fields() - .include("name"); + .include("name"); mongoTemplate.find(query, User.class) - .forEach(user -> { - assertNotNull(user.getName()); - assertTrue(user.getAge() - .equals(0)); - }); + .forEach(user -> { + assertNotNull(user.getName()); + assertTrue(user.getAge() + .equals(0)); + }); } @Test @@ -59,13 +59,13 @@ public class MongoTemplateProjectionLiveTest { final Query query = new Query(); query.fields() - .exclude("_id"); + .exclude("_id"); mongoTemplate.find(query, User.class) - .forEach(user -> { - assertNull(user.getId()); - assertNotNull(user.getAge()); - }); + .forEach(user -> { + assertNull(user.getId()); + assertNotNull(user.getAge()); + }); } diff --git a/spring-data-mongodb/src/test/java/org/baeldung/mongotemplate/MongoTemplateQueryLiveTest.java b/spring-data-mongodb/src/test/java/org/baeldung/mongotemplate/MongoTemplateQueryLiveTest.java index 76162c6096..b7ce0cafae 100644 --- a/spring-data-mongodb/src/test/java/org/baeldung/mongotemplate/MongoTemplateQueryLiveTest.java +++ b/spring-data-mongodb/src/test/java/org/baeldung/mongotemplate/MongoTemplateQueryLiveTest.java @@ -1,11 +1,5 @@ package org.baeldung.mongotemplate; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.hamcrest.Matchers.nullValue; - -import java.util.List; - import org.baeldung.config.MongoConfig; import org.baeldung.model.EmailAddress; import org.baeldung.model.User; @@ -26,6 +20,12 @@ import org.springframework.data.mongodb.core.query.Query; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import java.util.List; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.nullValue; +import static org.junit.Assert.assertThat; + @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = MongoConfig.class) public class MongoTemplateQueryLiveTest { From fe2d2a660455122263e60eadee0882c9c307acf8 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sun, 9 Jul 2017 07:45:22 +0200 Subject: [PATCH 02/89] Dependency clash resolved (#2235) --- guava21/pom.xml | 10 +++-- .../ZipCollectionTest.java | 8 ++-- .../AtomicLongMapIntegrationTest.java | 2 + .../guava/tutorial}/ComparatorsUnitTest.java | 2 + .../guava/tutorial}/GuavaStreamsUnitTest.java | 2 + .../tutorial}/InternBuilderUnitTest.java | 2 + .../guava/tutorial}/MonitorUnitTest.java | 2 + .../tutorial}/MoreCollectorsUnitTest.java | 2 + .../guava/tutorial}/StreamUtility.java | 2 + libraries/pom.xml | 6 --- .../baeldung/zip/ZipCollectionExample.java | 40 ------------------- pom.xml | 1 + 12 files changed, 26 insertions(+), 53 deletions(-) rename {libraries/src/test/java/com/baeldung/zip => guava21/src/test/java/com.baeldung.guava.zip}/ZipCollectionTest.java (94%) rename guava21/src/test/java/{ => com/baeldung/guava/tutorial}/AtomicLongMapIntegrationTest.java (97%) rename guava21/src/test/java/{ => com/baeldung/guava/tutorial}/ComparatorsUnitTest.java (98%) rename guava21/src/test/java/{ => com/baeldung/guava/tutorial}/GuavaStreamsUnitTest.java (99%) rename guava21/src/test/java/{ => com/baeldung/guava/tutorial}/InternBuilderUnitTest.java (91%) rename guava21/src/test/java/{ => com/baeldung/guava/tutorial}/MonitorUnitTest.java (97%) rename guava21/src/test/java/{ => com/baeldung/guava/tutorial}/MoreCollectorsUnitTest.java (95%) rename guava21/src/test/java/{ => com/baeldung/guava/tutorial}/StreamUtility.java (97%) delete mode 100644 libraries/src/main/java/com/baeldung/zip/ZipCollectionExample.java diff --git a/guava21/pom.xml b/guava21/pom.xml index d6e556e4a0..930def2a67 100644 --- a/guava21/pom.xml +++ b/guava21/pom.xml @@ -4,8 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.baeldung.guava - tutorial + guava21 1.0-SNAPSHOT @@ -15,12 +14,17 @@ - com.google.guava guava 21.0 + + + org.jooq + jool + 0.9.12 + diff --git a/libraries/src/test/java/com/baeldung/zip/ZipCollectionTest.java b/guava21/src/test/java/com.baeldung.guava.zip/ZipCollectionTest.java similarity index 94% rename from libraries/src/test/java/com/baeldung/zip/ZipCollectionTest.java rename to guava21/src/test/java/com.baeldung.guava.zip/ZipCollectionTest.java index 6f6a7b765f..866e09c6a0 100644 --- a/libraries/src/test/java/com/baeldung/zip/ZipCollectionTest.java +++ b/guava21/src/test/java/com.baeldung.guava.zip/ZipCollectionTest.java @@ -1,4 +1,4 @@ -package com.baeldung.zip; +package com.baeldung.guava.zip; import com.google.common.collect.Streams; import org.jooq.lambda.Seq; @@ -15,9 +15,9 @@ import static org.junit.Assert.assertEquals; public class ZipCollectionTest { - List names; - List ages; - List expectedOutput; + private List names; + private List ages; + private List expectedOutput; @Before public void setUp() throws Exception { diff --git a/guava21/src/test/java/AtomicLongMapIntegrationTest.java b/guava21/src/test/java/com/baeldung/guava/tutorial/AtomicLongMapIntegrationTest.java similarity index 97% rename from guava21/src/test/java/AtomicLongMapIntegrationTest.java rename to guava21/src/test/java/com/baeldung/guava/tutorial/AtomicLongMapIntegrationTest.java index 9024329a56..273683710c 100644 --- a/guava21/src/test/java/AtomicLongMapIntegrationTest.java +++ b/guava21/src/test/java/com/baeldung/guava/tutorial/AtomicLongMapIntegrationTest.java @@ -1,3 +1,5 @@ +package com.baeldung.guava.tutorial; + import com.google.common.util.concurrent.AtomicLongMap; import org.junit.Test; diff --git a/guava21/src/test/java/ComparatorsUnitTest.java b/guava21/src/test/java/com/baeldung/guava/tutorial/ComparatorsUnitTest.java similarity index 98% rename from guava21/src/test/java/ComparatorsUnitTest.java rename to guava21/src/test/java/com/baeldung/guava/tutorial/ComparatorsUnitTest.java index 3d1f2e9e81..0183e6cf3a 100644 --- a/guava21/src/test/java/ComparatorsUnitTest.java +++ b/guava21/src/test/java/com/baeldung/guava/tutorial/ComparatorsUnitTest.java @@ -1,3 +1,5 @@ +package com.baeldung.guava.tutorial; + import com.google.common.collect.Comparators; import org.junit.Assert; import org.junit.Test; diff --git a/guava21/src/test/java/GuavaStreamsUnitTest.java b/guava21/src/test/java/com/baeldung/guava/tutorial/GuavaStreamsUnitTest.java similarity index 99% rename from guava21/src/test/java/GuavaStreamsUnitTest.java rename to guava21/src/test/java/com/baeldung/guava/tutorial/GuavaStreamsUnitTest.java index 96b4a2ffdb..56c172ca87 100644 --- a/guava21/src/test/java/GuavaStreamsUnitTest.java +++ b/guava21/src/test/java/com/baeldung/guava/tutorial/GuavaStreamsUnitTest.java @@ -1,3 +1,5 @@ +package com.baeldung.guava.tutorial; + import com.google.common.collect.Streams; import org.junit.Assert; import org.junit.Before; diff --git a/guava21/src/test/java/InternBuilderUnitTest.java b/guava21/src/test/java/com/baeldung/guava/tutorial/InternBuilderUnitTest.java similarity index 91% rename from guava21/src/test/java/InternBuilderUnitTest.java rename to guava21/src/test/java/com/baeldung/guava/tutorial/InternBuilderUnitTest.java index 183e3eeb43..13d8f5f3b7 100644 --- a/guava21/src/test/java/InternBuilderUnitTest.java +++ b/guava21/src/test/java/com/baeldung/guava/tutorial/InternBuilderUnitTest.java @@ -1,3 +1,5 @@ +package com.baeldung.guava.tutorial; + import com.google.common.collect.Interner; import com.google.common.collect.Interners; import org.junit.Assert; diff --git a/guava21/src/test/java/MonitorUnitTest.java b/guava21/src/test/java/com/baeldung/guava/tutorial/MonitorUnitTest.java similarity index 97% rename from guava21/src/test/java/MonitorUnitTest.java rename to guava21/src/test/java/com/baeldung/guava/tutorial/MonitorUnitTest.java index e29d4a1eeb..a3a9a4f838 100644 --- a/guava21/src/test/java/MonitorUnitTest.java +++ b/guava21/src/test/java/com/baeldung/guava/tutorial/MonitorUnitTest.java @@ -1,3 +1,5 @@ +package com.baeldung.guava.tutorial; + import com.google.common.util.concurrent.Monitor; import org.junit.Assert; import org.junit.Test; diff --git a/guava21/src/test/java/MoreCollectorsUnitTest.java b/guava21/src/test/java/com/baeldung/guava/tutorial/MoreCollectorsUnitTest.java similarity index 95% rename from guava21/src/test/java/MoreCollectorsUnitTest.java rename to guava21/src/test/java/com/baeldung/guava/tutorial/MoreCollectorsUnitTest.java index 5950997788..acd03022d2 100644 --- a/guava21/src/test/java/MoreCollectorsUnitTest.java +++ b/guava21/src/test/java/com/baeldung/guava/tutorial/MoreCollectorsUnitTest.java @@ -1,3 +1,5 @@ +package com.baeldung.guava.tutorial; + import com.google.common.collect.MoreCollectors; import org.junit.Assert; import org.junit.Test; diff --git a/guava21/src/test/java/StreamUtility.java b/guava21/src/test/java/com/baeldung/guava/tutorial/StreamUtility.java similarity index 97% rename from guava21/src/test/java/StreamUtility.java rename to guava21/src/test/java/com/baeldung/guava/tutorial/StreamUtility.java index 1eb866fb88..b730fbf558 100644 --- a/guava21/src/test/java/StreamUtility.java +++ b/guava21/src/test/java/com/baeldung/guava/tutorial/StreamUtility.java @@ -1,3 +1,5 @@ +package com.baeldung.guava.tutorial; + import org.junit.Assert; import java.util.Iterator; diff --git a/libraries/pom.xml b/libraries/pom.xml index 0373d54429..a3b78f1695 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -349,12 +349,6 @@ java-lsh ${java-lsh.version} - - - com.google.guava - guava - 21.0 - au.com.dius pact-jvm-consumer-junit_2.11 diff --git a/libraries/src/main/java/com/baeldung/zip/ZipCollectionExample.java b/libraries/src/main/java/com/baeldung/zip/ZipCollectionExample.java deleted file mode 100644 index 3df9baad69..0000000000 --- a/libraries/src/main/java/com/baeldung/zip/ZipCollectionExample.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.baeldung.zip; - -import com.google.common.collect.Streams; -import org.jooq.lambda.Seq; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.IntStream; - -public class ZipCollectionExample { - static List names = Arrays.asList("John", "Jane", "Jack", "Dennis"); - - static List ages = Arrays.asList(24, 25, 27); - - public static void main(String[] args) { - // Using Streams API from Guava 21 - Streams - .zip(names.stream(), ages.stream(), (name, age) -> name + ":" + age) - .forEach(System.out::println); - - // Using native Java 8 Int Stream - IntStream - .range(0, Math.min(names.size(), ages.size())) - .mapToObj(i -> names.get(i) + ":" + ages.get(i)) - .forEach(System.out::println); - - // Using jOOL - Seq - .of("John", "Jane", "Dennis") - .zip(Seq.of(24, 25, 27)); - - Seq - .of("John", "Jane", "Dennis") - .zip(Seq.of(24, 25, 27), (x, y) -> x + ":" + y); - - Seq - .of("a", "b", "c") - .zipWithIndex(); - } -} diff --git a/pom.xml b/pom.xml index 818d131359..6c0b0911e0 100644 --- a/pom.xml +++ b/pom.xml @@ -57,6 +57,7 @@ guava guava18 guava19 + guava21 guice disruptor From 62254d9bebead5ecc481653ce20ef560110b085f Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sun, 9 Jul 2017 08:56:51 +0200 Subject: [PATCH 03/89] Serenity build fox (#2236) * Dependency clash resolved * Fix GuavaStreams tests * Fix GuavaStreams tests --- .../guava/tutorial/GuavaStreamsUnitTest.java | 89 ++++++++++--------- 1 file changed, 45 insertions(+), 44 deletions(-) diff --git a/guava21/src/test/java/com/baeldung/guava/tutorial/GuavaStreamsUnitTest.java b/guava21/src/test/java/com/baeldung/guava/tutorial/GuavaStreamsUnitTest.java index 56c172ca87..3d3163cba6 100644 --- a/guava21/src/test/java/com/baeldung/guava/tutorial/GuavaStreamsUnitTest.java +++ b/guava21/src/test/java/com/baeldung/guava/tutorial/GuavaStreamsUnitTest.java @@ -1,23 +1,33 @@ package com.baeldung.guava.tutorial; import com.google.common.collect.Streams; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.util.*; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Optional; +import java.util.OptionalDouble; +import java.util.OptionalInt; +import java.util.OptionalLong; +import java.util.stream.Collectors; import java.util.stream.DoubleStream; import java.util.stream.IntStream; import java.util.stream.LongStream; import java.util.stream.Stream; +import static com.baeldung.guava.tutorial.StreamUtility.assertStreamEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + public class GuavaStreamsUnitTest { - List numbers; + private List numbers; @Before public void setUp() { - numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); + numbers = IntStream.rangeClosed(1, 20).boxed().collect(Collectors.toList()); } @Test @@ -26,17 +36,17 @@ public class GuavaStreamsUnitTest { Stream streamFromCollection = Streams.stream(numbers); //Assert.assertNotNull(streamFromCollection); - StreamUtility.assertStreamEquals(streamFromCollection, numbers.stream()); + assertStreamEquals(streamFromCollection, numbers.stream()); } @Test public void createStreamsWithIterable() { - Iterable numbersIterable = (Iterable) numbers; + Iterable numbersIterable = numbers; Stream streamFromIterable = Streams.stream(numbersIterable); - Assert.assertNotNull(streamFromIterable); - StreamUtility.assertStreamEquals(streamFromIterable, numbers.stream()); + assertNotNull(streamFromIterable); + assertStreamEquals(streamFromIterable, numbers.stream()); } @Test @@ -45,8 +55,8 @@ public class GuavaStreamsUnitTest { Stream streamFromIterator = Streams.stream(numbersIterator); - Assert.assertNotNull(streamFromIterator); - StreamUtility.assertStreamEquals(streamFromIterator, numbers.stream()); + assertNotNull(streamFromIterator); + assertStreamEquals(streamFromIterator, numbers.stream()); } @Test @@ -54,8 +64,8 @@ public class GuavaStreamsUnitTest { Stream streamFromOptional = Streams.stream(Optional.of(1)); - Assert.assertNotNull(streamFromOptional); - Assert.assertEquals(streamFromOptional.count(), 1); + assertNotNull(streamFromOptional); + assertEquals(streamFromOptional.count(), 1); } @Test @@ -63,8 +73,8 @@ public class GuavaStreamsUnitTest { LongStream streamFromOptionalLong = Streams.stream(OptionalLong.of(1)); - Assert.assertNotNull(streamFromOptionalLong); - Assert.assertEquals(streamFromOptionalLong.count(), 1); + assertNotNull(streamFromOptionalLong); + assertEquals(streamFromOptionalLong.count(), 1); } @Test @@ -73,7 +83,7 @@ public class GuavaStreamsUnitTest { IntStream streamFromOptionalInt = Streams.stream(OptionalInt.of(1)); //Assert.assertNotNull(streamFromOptionalInt); - Assert.assertEquals(streamFromOptionalInt.count(), 1); + assertEquals(streamFromOptionalInt.count(), 1); } @Test @@ -82,63 +92,54 @@ public class GuavaStreamsUnitTest { DoubleStream streamFromOptionalDouble = Streams.stream(OptionalDouble.of(1.0)); //Assert.assertNotNull(streamFromOptionalDouble); - Assert.assertEquals(streamFromOptionalDouble.count(), 1); + assertEquals(streamFromOptionalDouble.count(), 1); } @Test public void concatStreamsOfSameType() { - Stream oddNumbers = Arrays - .asList(1, 3, 5, 7, 9, 11, 13, 15, 17, 19) - .stream(); - Stream evenNumbers = Arrays - .asList(2, 4, 6, 8, 10, 12, 14, 16, 18, 20) - .stream(); + List oddNumbers = Arrays + .asList(1, 3, 5, 7, 9, 11, 13, 15, 17, 19); + List evenNumbers = Arrays + .asList(2, 4, 6, 8, 10, 12, 14, 16, 18, 20); - Stream combinedStreams = Streams.concat(oddNumbers, evenNumbers); + Stream combinedStreams = Streams.concat(oddNumbers.stream(), evenNumbers.stream()); //Assert.assertNotNull(combinedStreams); - StreamUtility.assertStreamEquals(combinedStreams, Stream.concat(oddNumbers, evenNumbers)); + assertStreamEquals(combinedStreams, Stream.concat(oddNumbers.stream(), evenNumbers.stream())); } @Test public void concatStreamsOfTypeLongStream() { - LongStream firstTwenty = LongStream.range(1, 20); - LongStream nextTwenty = LongStream.range(21, 40); + LongStream combinedStreams = Streams.concat(LongStream.range(1, 21), LongStream.range(21, 40)); - LongStream combinedStreams = Streams.concat(firstTwenty, nextTwenty); - - Assert.assertNotNull(combinedStreams); - StreamUtility.assertStreamEquals(combinedStreams, LongStream.concat(firstTwenty, nextTwenty)); + assertNotNull(combinedStreams); + assertStreamEquals(combinedStreams, LongStream.range(1, 40)); } @Test public void concatStreamsOfTypeIntStream() { - IntStream firstTwenty = IntStream.range(1, 20); - IntStream nextTwenty = IntStream.range(21, 40); + IntStream combinedStreams = Streams.concat(IntStream.range(1, 20), IntStream.range(21, 40)); - IntStream combinedStreams = Streams.concat(firstTwenty, nextTwenty); - - Assert.assertNotNull(combinedStreams); - StreamUtility.assertStreamEquals(combinedStreams, IntStream.concat(firstTwenty, nextTwenty)); + assertNotNull(combinedStreams); + assertStreamEquals(combinedStreams, IntStream.concat(IntStream.range(1, 20), IntStream.range(21, 40))); } @Test public void findLastOfStream() { Optional lastElement = Streams.findLast(numbers.stream()); - Assert.assertNotNull(lastElement.get()); - Assert.assertEquals(lastElement.get(), numbers.get(20)); + assertEquals(lastElement.get(), numbers.get(19)); } @Test public void mapWithIndexTest() { - Stream stringSream = Stream.of("a", "b", "c"); + Stream stringStream = Stream.of("a", "b", "c"); - Stream mappedStream = Streams.mapWithIndex(stringSream, (str, index) -> str + ":" + index); + Stream mappedStream = Streams.mapWithIndex(stringStream, (str, index) -> str + ":" + index); //Assert.assertNotNull(mappedStream); - Assert.assertEquals(mappedStream + assertEquals(mappedStream .findFirst() .get(), "a:0"); @@ -146,12 +147,12 @@ public class GuavaStreamsUnitTest { @Test public void streamsZipTest() { - Stream stringSream = Stream.of("a", "b", "c"); - Stream intStream = Stream.of(1, 2, 3); + Stream stringSream = Stream.of("a", "b", "c"); + Stream intStream = Stream.of(1, 2, 3); Stream mappedStream = Streams.zip(stringSream, intStream, (str, index) -> str + ":" + index); //Assert.assertNotNull(mappedStream); - Assert.assertEquals(mappedStream + assertEquals(mappedStream .findFirst() .get(), "a:1"); From f876c6d02e58bb275664bc0dc6e5d4240f8b54ee Mon Sep 17 00:00:00 2001 From: Abhinab Kanrar Date: Sun, 9 Jul 2017 12:33:08 +0530 Subject: [PATCH 04/89] vavr's either (#2180) * moving jmh into libraries module * refactoring jmh * Update pom.xml * manual algorightm * with BM result * fix for space issue * Fixed indentation * change as per suggestion * vavr either * adding unit test and othe rutilities --- .../com/baeldung/vavr/either/EitherDemo.java | 90 +++++++++++++++++++ .../baeldung/vavr/either/EitherUnitTest.java | 32 +++++++ 2 files changed, 122 insertions(+) create mode 100644 vavr/src/main/java/com/baeldung/vavr/either/EitherDemo.java create mode 100644 vavr/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java diff --git a/vavr/src/main/java/com/baeldung/vavr/either/EitherDemo.java b/vavr/src/main/java/com/baeldung/vavr/either/EitherDemo.java new file mode 100644 index 0000000000..38df03980f --- /dev/null +++ b/vavr/src/main/java/com/baeldung/vavr/either/EitherDemo.java @@ -0,0 +1,90 @@ +package com.baeldung.vavr.either; + +import java.util.HashMap; +import java.util.Map; + +import io.vavr.control.Either; + +public class EitherDemo { + + public static Object[] computeWithoutEitherUsingArray(int marks) { + Object[] results = new Object[2]; + if (marks < 85) { + results[0] = "Marks not acceptable"; + } else { + results[1] = marks; + } + return results; + } + + public static Map computeWithoutEitherUsingMap(int marks) { + Map results = new HashMap(); + if (marks < 85) { + results.put("FAILURE", "Marks not acceptable"); + } else { + results.put("SUCCESS", marks); + } + return results; + } + + public static Either computeWithEither(int marks) { + if (marks < 85) { + return Either.left("Marks not acceptable"); + } else { + return Either.right(marks); + } + } + + public static String getError(Either result) { + return result.getLeft(); + } + + public static int getMarks(Either result) { + return result.get(); + } + + public static int getModifiedMarks(Either result) { + result = result.right().map(i -> i * 2).toEither(); + return result.get(); + } + + public void utilities() { + + String error; + int marks; + + Either result = computeWithEither(100); + + result.toArray(); + result.toCharSeq(); + result.toLinkedSet(); + result.toList(); + result.toOption(); + result.toPriorityQueue(); + result.iterator(); + result.toVector(); + result.toTree(); + result.toStream(); + + result.toJavaArray(); + result.toJavaList(); + result.toJavaOptional(); + result.toJavaParallelStream(); + result.toJavaSet(); + result.toJavaStream(); + result.toJavaList(); + + Either.RightProjection projection = computeWithEither(9).right(); + + result.contains(800); + result.isLeft(); + result.isRight(); + + if (result.isLeft()) { + error = result.getLeft(); + } else { + marks = result.get(); + } + } + +} diff --git a/vavr/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java b/vavr/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java new file mode 100644 index 0000000000..90cd1ace35 --- /dev/null +++ b/vavr/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java @@ -0,0 +1,32 @@ +package com.baeldung.vavr.either; + +import org.junit.Test; + +import io.vavr.control.Either; + +import static org.junit.Assert.assertEquals; + +public class EitherUnitTest { + + @Test + public void givenMarks_whenPassNumber_thenExpectNumber() { + Either result = EitherDemo.computeWithEither(100); + int marks = EitherDemo.getMarks(result); + assertEquals(100, marks); + } + + @Test + public void givenMarks_whenFailNumber_thenExpectErrorMesssage() { + Either result = EitherDemo.computeWithEither(50); + String error = EitherDemo.getError(result); + assertEquals("Marks not acceptable", error); + } + + @Test + public void givenPassMarks_whenModified_thenExpectNumber() { + Either result = EitherDemo.computeWithEither(90); + int marks = EitherDemo.getModifiedMarks(result); + assertEquals(180, marks); + } + +} From 13eec7e57cdffff721252b01dfc4632276553af4 Mon Sep 17 00:00:00 2001 From: Ahmed Tawila Date: Sun, 9 Jul 2017 10:15:22 +0300 Subject: [PATCH 05/89] BAEL-994 - TemporalAdjuster in Java (#2232) * Evaluation article: Different Types of Bean Injection in Spring * added tests & changed configuration to Java-based config * removed xml config files * rename unit tests * BAEL-972 - Apache Commons Text * remove code from evaluation article * remove code from evaluation article * BAEL-972 - Apache Commons Text - added another example * BAEL-972 - Apache Commons Text - just indentation * BAEL-994 - TemporalAdjuster in Java * BAEL-994 - TemporalAdjuster in Java * BAEL-994 - TemporalAdjuster in Java * BAEL-994 - TemporalAdjuster in Java * BAEL-994 - TemporalAdjuster in Java - fix problems --- .../TemporalAdjusterUtil.java | 31 ------------------- .../CustomTemporalAdjusterTest.java | 31 +++++++------------ .../TemporalAdjustersTest.java | 13 ++------ 3 files changed, 15 insertions(+), 60 deletions(-) delete mode 100644 core-java/src/main/java/com/baeldung/temporaladjuster/TemporalAdjusterUtil.java diff --git a/core-java/src/main/java/com/baeldung/temporaladjuster/TemporalAdjusterUtil.java b/core-java/src/main/java/com/baeldung/temporaladjuster/TemporalAdjusterUtil.java deleted file mode 100644 index 1a1528456e..0000000000 --- a/core-java/src/main/java/com/baeldung/temporaladjuster/TemporalAdjusterUtil.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.baeldung.temporaladjuster; - -import java.text.SimpleDateFormat; -import java.util.Calendar; - -public class TemporalAdjusterUtil { - - public static Calendar nextDayOfWeek(int dayOfWeek) { - Calendar date = Calendar.getInstance(); - int difference = dayOfWeek - date.get(Calendar.DAY_OF_WEEK); - if (!(difference > 0)) { - difference += 7; - } - date.add(Calendar.DAY_OF_MONTH, difference); - return date; - } - - @SuppressWarnings("static-access") - public static String getNextWorkingDay() { - Calendar calendar = Calendar.getInstance(); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - format.setCalendar(calendar); - if (calendar.DAY_OF_WEEK == Calendar.FRIDAY) - calendar.add(Calendar.DATE, 3); - if (calendar.DAY_OF_WEEK == Calendar.SATURDAY) - calendar.add(Calendar.DATE, 2); - else - calendar.add(Calendar.DATE, 1); - return format.format(calendar.getTime()); - } -} diff --git a/core-java/src/test/java/com/baeldung/temporaladjusters/CustomTemporalAdjusterTest.java b/core-java/src/test/java/com/baeldung/temporaladjusters/CustomTemporalAdjusterTest.java index 10dce5c498..a7acc9f743 100644 --- a/core-java/src/test/java/com/baeldung/temporaladjusters/CustomTemporalAdjusterTest.java +++ b/core-java/src/test/java/com/baeldung/temporaladjusters/CustomTemporalAdjusterTest.java @@ -1,56 +1,49 @@ package com.baeldung.temporaladjusters; -import java.text.SimpleDateFormat; import java.time.DayOfWeek; import java.time.LocalDate; import java.time.Period; import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalAdjusters; -import java.util.Calendar; import org.junit.Assert; import org.junit.Test; import com.baeldung.temporaladjuster.CustomTemporalAdjuster; -import com.baeldung.temporaladjuster.TemporalAdjusterUtil; public class CustomTemporalAdjusterTest { @Test public void whenAdjustAndImplementInterface_thenNextWorkingDay() { - LocalDate localDate = LocalDate.now(); + LocalDate localDate = LocalDate.of(2017, 07, 8); CustomTemporalAdjuster temporalAdjuster = new CustomTemporalAdjuster(); LocalDate nextWorkingDay = localDate.with(temporalAdjuster); - Assert.assertEquals(TemporalAdjusterUtil.getNextWorkingDay(), nextWorkingDay.toString()); + Assert.assertEquals("2017-07-10", nextWorkingDay.toString()); } - + @Test public void whenAdjust_thenNextWorkingDay() { - LocalDate localDate = LocalDate.now(); + LocalDate localDate = LocalDate.of(2017, 07, 8); TemporalAdjuster temporalAdjuster = NEXT_WORKING_DAY; LocalDate date = localDate.with(temporalAdjuster); - Assert.assertEquals(TemporalAdjusterUtil.getNextWorkingDay(), date.toString()); + Assert.assertEquals("2017-07-10", date.toString()); } @Test - public void whenAdjust_thenFourteenDaysFromToday() { - LocalDate localDate = LocalDate.now(); + public void whenAdjust_thenFourteenDaysAfterDate() { + LocalDate localDate = LocalDate.of(2017, 07, 8); TemporalAdjuster temporalAdjuster = (t) -> t.plus(Period.ofDays(14)); LocalDate result = localDate.with(temporalAdjuster); - Calendar calendar = Calendar.getInstance(); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - format.setCalendar(calendar); - calendar.add(Calendar.DATE, 14); - String fourteenDaysFromToday = format.format(calendar.getTime()); + String fourteenDaysAfterDate = "2017-07-22"; - Assert.assertEquals(fourteenDaysFromToday, result.toString()); + Assert.assertEquals(fourteenDaysAfterDate, result.toString()); } - static TemporalAdjuster NEXT_WORKING_DAY = TemporalAdjusters.ofDateAdjuster(today -> { - DayOfWeek dayOfWeek = today.getDayOfWeek(); + static TemporalAdjuster NEXT_WORKING_DAY = TemporalAdjusters.ofDateAdjuster(date -> { + DayOfWeek dayOfWeek = date.getDayOfWeek(); int daysToAdd; if (dayOfWeek == DayOfWeek.FRIDAY) daysToAdd = 3; @@ -58,6 +51,6 @@ public class CustomTemporalAdjusterTest { daysToAdd = 2; else daysToAdd = 1; - return today.plusDays(daysToAdd); + return date.plusDays(daysToAdd); }); } diff --git a/core-java/src/test/java/com/baeldung/temporaladjusters/TemporalAdjustersTest.java b/core-java/src/test/java/com/baeldung/temporaladjusters/TemporalAdjustersTest.java index f21da5cf75..d06da5a782 100644 --- a/core-java/src/test/java/com/baeldung/temporaladjusters/TemporalAdjustersTest.java +++ b/core-java/src/test/java/com/baeldung/temporaladjusters/TemporalAdjustersTest.java @@ -1,29 +1,22 @@ package com.baeldung.temporaladjusters; -import java.text.SimpleDateFormat; import java.time.DayOfWeek; import java.time.LocalDate; import java.time.temporal.TemporalAdjusters; -import java.util.Calendar; import org.junit.Assert; import org.junit.Test; -import com.baeldung.temporaladjuster.TemporalAdjusterUtil; - public class TemporalAdjustersTest { @Test public void whenAdjust_thenNextSunday() { - LocalDate localDate = LocalDate.now(); + LocalDate localDate = LocalDate.of(2017, 07, 8); LocalDate nextSunday = localDate.with(TemporalAdjusters.next(DayOfWeek.SUNDAY)); - Calendar calendar = TemporalAdjusterUtil.nextDayOfWeek(Calendar.SUNDAY); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - format.setCalendar(calendar); - String formattedDate = format.format(calendar.getTime()); + String expected = "2017-07-09"; - Assert.assertEquals(formattedDate, nextSunday.toString()); + Assert.assertEquals(expected, nextSunday.toString()); } } From e704d296bfac54dc480b304b5391a740bda92a53 Mon Sep 17 00:00:00 2001 From: Mansi Date: Sun, 9 Jul 2017 14:05:11 +0530 Subject: [PATCH 06/89] BAEL-79 Intro to Activiti with Spring (#2127) * Example Code For Evaluation Article This is an example code for the evaluation article on "Different Types of Bean Injection in Spring" * Added unit tests * Minor changes to application context * Removed code committed for evaluation article * BAEL-944 Demonstrating the problems with new Url pattern matching in Spring 5 * BAEL-944 Demonstrating the problems with new Url pattern matching in Spring 5 * BAEL-944 Exploring the Spring MVC URL Matching Improvements * BAEL-944 Exploring the Spring MVC URL Matching Improvements * BAEL-944 Exploring the Spring MVC URL Matching Improvements * BAEL-944 Code Formatting and solving build issue * BAEL-944 Resolving build issue due to change in Spring version * BAEL-944 Resolving build issue * BAEL-944 Formatting code * BAEL-944 Moving tests to correct package * BAEL-944 Moving tests to correct package * BAEL-944 Replacing @RequestMapping by @GetMapping * BAEL-944 Remove unnecessary attribute name, "value" in annotations * BAEL-79 Intro to Activiti with Spring * BAEL-79 Intro to Activiti with Spring * BAEL-79 Adding activiti module to the parent modules * BAEL-79 Using latest version * BAEL-79 Update Spring boot version that works with Activiti * BAEL-79 Replace RequestMapping with GetMapping * BAEL-79 Use Java 8 Syntax * BAEL-79 Formatting * BAEL-79 changed module name --- pom.xml | 1 + spring-activiti/pom.xml | 60 +++++++++ .../ActivitiController.java | 60 +++++++++ .../ActivitiWithSpringApplication.java | 12 ++ .../TaskRepresentation.java | 43 +++++++ .../resources/processes/my-process.bpmn20.xml | 67 ++++++++++ .../ActivitiControllerTest.java | 120 ++++++++++++++++++ .../ActivitiWithSpringApplicationTests.java | 16 +++ 8 files changed, 379 insertions(+) create mode 100644 spring-activiti/pom.xml create mode 100644 spring-activiti/src/main/java/com/example/activitiwithspring/ActivitiController.java create mode 100644 spring-activiti/src/main/java/com/example/activitiwithspring/ActivitiWithSpringApplication.java create mode 100644 spring-activiti/src/main/java/com/example/activitiwithspring/TaskRepresentation.java create mode 100644 spring-activiti/src/main/resources/processes/my-process.bpmn20.xml create mode 100644 spring-activiti/src/test/java/com/example/activitiwithspring/ActivitiControllerTest.java create mode 100644 spring-activiti/src/test/java/com/example/activitiwithspring/ActivitiWithSpringApplicationTests.java diff --git a/pom.xml b/pom.xml index 6c0b0911e0..d01134fb30 100644 --- a/pom.xml +++ b/pom.xml @@ -25,6 +25,7 @@ + spring-activiti aws akka-streams algorithms diff --git a/spring-activiti/pom.xml b/spring-activiti/pom.xml new file mode 100644 index 0000000000..3d2f1386df --- /dev/null +++ b/spring-activiti/pom.xml @@ -0,0 +1,60 @@ + + + 4.0.0 + + com.example + spring-activiti + 0.0.1-SNAPSHOT + jar + + spring-activiti + Demo project for Spring Boot + + + org.springframework.boot + spring-boot-starter-parent + 1.5.4.RELEASE + + + + + UTF-8 + UTF-8 + 1.8 + + + + + org.activiti + activiti-spring-boot-starter-basic + 6.0.0 + + + org.springframework.boot + spring-boot-starter-web + + + + com.h2database + h2 + runtime + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + diff --git a/spring-activiti/src/main/java/com/example/activitiwithspring/ActivitiController.java b/spring-activiti/src/main/java/com/example/activitiwithspring/ActivitiController.java new file mode 100644 index 0000000000..3924d31f68 --- /dev/null +++ b/spring-activiti/src/main/java/com/example/activitiwithspring/ActivitiController.java @@ -0,0 +1,60 @@ +package com.example.activitiwithspring; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import org.activiti.engine.RuntimeService; +import org.activiti.engine.TaskService; +import org.activiti.engine.task.Task; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class ActivitiController { + private static final Logger logger = LoggerFactory.getLogger(ActivitiController.class); + @Autowired + private RuntimeService runtimeService; + + @Autowired + private TaskService taskService; + + @GetMapping("/start-process") + public String startProcess() { + runtimeService.startProcessInstanceByKey("my-process"); + return "Process started. Number of currently running process instances = " + runtimeService.createProcessInstanceQuery() + .count(); + } + + @GetMapping("/get-tasks/{processInstanceId}") + public List getTasks(@PathVariable String processInstanceId) { + List usertasks = taskService.createTaskQuery() + .processInstanceId(processInstanceId) + .list(); + + List tasks = usertasks.stream().map(task -> { + TaskRepresentation taskRepresentation = new TaskRepresentation(task.getId(), task.getName(), task.getProcessInstanceId()); + return taskRepresentation; + }).collect(Collectors.toList()); + return tasks; + } + + @GetMapping("/complete-task-A/{processInstanceId}") + public TaskRepresentation completeTaskA(@PathVariable String processInstanceId) { + Task task = taskService.createTaskQuery() + .processInstanceId(processInstanceId) + .singleResult(); + taskService.complete(task.getId()); + logger.info("Task completed"); + task = taskService.createTaskQuery() + .processInstanceId(processInstanceId) + .singleResult(); + + return new TaskRepresentation(task.getId(), task.getName(), task.getProcessInstanceId()); + } +} diff --git a/spring-activiti/src/main/java/com/example/activitiwithspring/ActivitiWithSpringApplication.java b/spring-activiti/src/main/java/com/example/activitiwithspring/ActivitiWithSpringApplication.java new file mode 100644 index 0000000000..e98b8ad7ca --- /dev/null +++ b/spring-activiti/src/main/java/com/example/activitiwithspring/ActivitiWithSpringApplication.java @@ -0,0 +1,12 @@ +package com.example.activitiwithspring; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class ActivitiWithSpringApplication { + + public static void main(String[] args) { + SpringApplication.run(ActivitiWithSpringApplication.class, args); + } +} diff --git a/spring-activiti/src/main/java/com/example/activitiwithspring/TaskRepresentation.java b/spring-activiti/src/main/java/com/example/activitiwithspring/TaskRepresentation.java new file mode 100644 index 0000000000..bb1412b057 --- /dev/null +++ b/spring-activiti/src/main/java/com/example/activitiwithspring/TaskRepresentation.java @@ -0,0 +1,43 @@ +package com.example.activitiwithspring; + +class TaskRepresentation { + + private String id; + private String name; + private String processInstanceId; + + public TaskRepresentation() { + super(); + } + + public TaskRepresentation(String id, String name, String processInstanceId) { + this.id = id; + this.name = name; + this.processInstanceId = processInstanceId; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getProcessInstanceId() { + return processInstanceId; + } + + public void setProcessInstanceId(String processInstanceId) { + this.processInstanceId = processInstanceId; + } + +} diff --git a/spring-activiti/src/main/resources/processes/my-process.bpmn20.xml b/spring-activiti/src/main/resources/processes/my-process.bpmn20.xml new file mode 100644 index 0000000000..3ced8d6b7c --- /dev/null +++ b/spring-activiti/src/main/resources/processes/my-process.bpmn20.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-activiti/src/test/java/com/example/activitiwithspring/ActivitiControllerTest.java b/spring-activiti/src/test/java/com/example/activitiwithspring/ActivitiControllerTest.java new file mode 100644 index 0000000000..3176207664 --- /dev/null +++ b/spring-activiti/src/test/java/com/example/activitiwithspring/ActivitiControllerTest.java @@ -0,0 +1,120 @@ +package com.example.activitiwithspring; + +import static org.junit.Assert.assertEquals; + +import java.util.Arrays; +import java.util.List; + +import org.activiti.engine.RuntimeService; +import org.activiti.engine.runtime.ProcessInstance; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; + +import com.fasterxml.jackson.databind.ObjectMapper; + +@RunWith(SpringJUnit4ClassRunner.class) +@WebAppConfiguration +@SpringBootTest +public class ActivitiControllerTest { + private static final Logger logger = LoggerFactory.getLogger(ActivitiControllerTest.class); + private MockMvc mockMvc; + + @Autowired + private WebApplicationContext wac; + + @Autowired + RuntimeService runtimeService; + + @Before + public void setUp() { + this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac) + .build(); + + for (ProcessInstance instance : runtimeService.createProcessInstanceQuery() + .list()) { + runtimeService.deleteProcessInstance(instance.getId(), "Reset Processes"); + } + } + + @Test + public void givenProcess_whenStartProcess_thenIncreaseInProcessInstanceCount() throws Exception { + + String responseBody = this.mockMvc.perform(MockMvcRequestBuilders.get("/start-process")) + .andReturn() + .getResponse() + .getContentAsString(); + assertEquals("Process started. Number of currently running process instances = 1", responseBody); + + responseBody = this.mockMvc.perform(MockMvcRequestBuilders.get("/start-process")) + .andReturn() + .getResponse() + .getContentAsString(); + assertEquals("Process started. Number of currently running process instances = 2", responseBody); + + responseBody = this.mockMvc.perform(MockMvcRequestBuilders.get("/start-process")) + .andReturn() + .getResponse() + .getContentAsString(); + assertEquals("Process started. Number of currently running process instances = 3", responseBody); + } + + @Test + public void givenProcess_whenProcessInstance_thenReceivedRunningTask() throws Exception { + + this.mockMvc.perform(MockMvcRequestBuilders.get("/start-process")) + .andReturn() + .getResponse(); + ProcessInstance pi = runtimeService.createProcessInstanceQuery() + .orderByProcessInstanceId() + .desc() + .list() + .get(0); + + logger.info("process instance = " + pi.getId()); + String responseBody = this.mockMvc.perform(MockMvcRequestBuilders.get("/get-tasks/" + pi.getId())) + .andReturn() + .getResponse() + .getContentAsString(); + + ObjectMapper mapper = new ObjectMapper(); + List tasks = Arrays.asList(mapper.readValue(responseBody, TaskRepresentation[].class)); + assertEquals(1, tasks.size()); + assertEquals("A", tasks.get(0).getName()); + + } + + @Test + public void givenProcess_whenCompleteTaskA_thenReceivedNextTask() throws Exception { + + this.mockMvc.perform(MockMvcRequestBuilders.get("/start-process")) + .andReturn() + .getResponse(); + ProcessInstance pi = runtimeService.createProcessInstanceQuery() + .orderByProcessInstanceId() + .desc() + .list() + .get(0); + + logger.info("process instance = " + pi.getId()); + String responseBody = this.mockMvc.perform(MockMvcRequestBuilders.get("/complete-task-A/" + pi.getId())) + .andReturn() + .getResponse() + .getContentAsString(); + + ObjectMapper mapper = new ObjectMapper(); + TaskRepresentation task = mapper.readValue(responseBody, TaskRepresentation.class); + assertEquals("B", task.getName()); + + } +} diff --git a/spring-activiti/src/test/java/com/example/activitiwithspring/ActivitiWithSpringApplicationTests.java b/spring-activiti/src/test/java/com/example/activitiwithspring/ActivitiWithSpringApplicationTests.java new file mode 100644 index 0000000000..da22c6c7fa --- /dev/null +++ b/spring-activiti/src/test/java/com/example/activitiwithspring/ActivitiWithSpringApplicationTests.java @@ -0,0 +1,16 @@ +package com.example.activitiwithspring; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class ActivitiWithSpringApplicationTests { + + @Test + public void contextLoads() { + } + +} From a219184b4670d45ded0d6f94c8cdbadb356d072e Mon Sep 17 00:00:00 2001 From: Parth Karia Date: Sun, 9 Jul 2017 15:53:21 +0530 Subject: [PATCH 07/89] BAEL-1004 changes in variable names (#2238) --- .../java/com/baeldung/algorithms/minimax/MiniMax.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/algorithms/src/main/java/com/baeldung/algorithms/minimax/MiniMax.java b/algorithms/src/main/java/com/baeldung/algorithms/minimax/MiniMax.java index ce2ba03af5..fed4ebed48 100644 --- a/algorithms/src/main/java/com/baeldung/algorithms/minimax/MiniMax.java +++ b/algorithms/src/main/java/com/baeldung/algorithms/minimax/MiniMax.java @@ -18,12 +18,12 @@ public class MiniMax { constructTree(root); } - private void constructTree(Node node) { - List listofPossibleHeaps = GameOfBones.getPossibleStates(node.getNoOfBones()); - boolean isMaxPlayer = !node.isMaxPlayer(); + private void constructTree(Node parentNode) { + List listofPossibleHeaps = GameOfBones.getPossibleStates(parentNode.getNoOfBones()); + boolean isChildMaxPlayer = !parentNode.isMaxPlayer(); listofPossibleHeaps.forEach(n -> { - Node newNode = new Node(n, isMaxPlayer); - node.addChild(newNode); + Node newNode = new Node(n, isChildMaxPlayer); + parentNode.addChild(newNode); if (newNode.getNoOfBones() > 0) { constructTree(newNode); } From e422edadd08886a3b1173f9339c063e5184c82a1 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sun, 9 Jul 2017 12:28:04 +0200 Subject: [PATCH 08/89] Either refactor (#2237) --- .../com/baeldung/vavr/either/EitherDemo.java | 57 +------------------ .../vavr/PatternMatchingUnitTest.java | 6 +- .../baeldung/vavr/either/EitherUnitTest.java | 16 ++++-- 3 files changed, 15 insertions(+), 64 deletions(-) diff --git a/vavr/src/main/java/com/baeldung/vavr/either/EitherDemo.java b/vavr/src/main/java/com/baeldung/vavr/either/EitherDemo.java index 38df03980f..95f8191342 100644 --- a/vavr/src/main/java/com/baeldung/vavr/either/EitherDemo.java +++ b/vavr/src/main/java/com/baeldung/vavr/either/EitherDemo.java @@ -18,7 +18,7 @@ public class EitherDemo { } public static Map computeWithoutEitherUsingMap(int marks) { - Map results = new HashMap(); + Map results = new HashMap<>(); if (marks < 85) { results.put("FAILURE", "Marks not acceptable"); } else { @@ -27,64 +27,11 @@ public class EitherDemo { return results; } - public static Either computeWithEither(int marks) { + static Either computeWithEither(int marks) { if (marks < 85) { return Either.left("Marks not acceptable"); } else { return Either.right(marks); } } - - public static String getError(Either result) { - return result.getLeft(); - } - - public static int getMarks(Either result) { - return result.get(); - } - - public static int getModifiedMarks(Either result) { - result = result.right().map(i -> i * 2).toEither(); - return result.get(); - } - - public void utilities() { - - String error; - int marks; - - Either result = computeWithEither(100); - - result.toArray(); - result.toCharSeq(); - result.toLinkedSet(); - result.toList(); - result.toOption(); - result.toPriorityQueue(); - result.iterator(); - result.toVector(); - result.toTree(); - result.toStream(); - - result.toJavaArray(); - result.toJavaList(); - result.toJavaOptional(); - result.toJavaParallelStream(); - result.toJavaSet(); - result.toJavaStream(); - result.toJavaList(); - - Either.RightProjection projection = computeWithEither(9).right(); - - result.contains(800); - result.isLeft(); - result.isRight(); - - if (result.isLeft()) { - error = result.getLeft(); - } else { - marks = result.get(); - } - } - } diff --git a/vavr/src/test/java/com/baeldung/vavr/PatternMatchingUnitTest.java b/vavr/src/test/java/com/baeldung/vavr/PatternMatchingUnitTest.java index ef5afe0e29..1adff2e845 100644 --- a/vavr/src/test/java/com/baeldung/vavr/PatternMatchingUnitTest.java +++ b/vavr/src/test/java/com/baeldung/vavr/PatternMatchingUnitTest.java @@ -100,13 +100,11 @@ public class PatternMatchingUnitTest { }))); } - - - public void displayEven() { + private void displayEven() { System.out.println("Input is even"); } - public void displayOdd() { + private void displayOdd() { System.out.println("Input is odd"); } } diff --git a/vavr/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java b/vavr/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java index 90cd1ace35..6b0a34f9e4 100644 --- a/vavr/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java +++ b/vavr/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java @@ -1,8 +1,7 @@ package com.baeldung.vavr.either; -import org.junit.Test; - import io.vavr.control.Either; +import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -11,21 +10,28 @@ public class EitherUnitTest { @Test public void givenMarks_whenPassNumber_thenExpectNumber() { Either result = EitherDemo.computeWithEither(100); - int marks = EitherDemo.getMarks(result); + int marks = result.right() + .getOrElseThrow(x -> new IllegalStateException()); + assertEquals(100, marks); } @Test public void givenMarks_whenFailNumber_thenExpectErrorMesssage() { Either result = EitherDemo.computeWithEither(50); - String error = EitherDemo.getError(result); + String error = result.left() + .getOrNull(); + assertEquals("Marks not acceptable", error); } @Test public void givenPassMarks_whenModified_thenExpectNumber() { Either result = EitherDemo.computeWithEither(90); - int marks = EitherDemo.getModifiedMarks(result); + int marks = result.right() + .map(x -> x * 2) + .get(); + assertEquals(180, marks); } From fc33d62cc3aed06165d21b690b8a5eb7a5799236 Mon Sep 17 00:00:00 2001 From: Doha2012 Date: Sun, 9 Jul 2017 21:10:38 +0200 Subject: [PATCH 09/89] kotlin collection (#2241) * minor logging fix * spring security sso * use basic auth * use form login * cleanup * cleanup * final cleanup * second client app for sso * spring boot bootstrap * add logic * cleanup * add simple controller * add thymeleaf and security * minor fix * minor fix * add more boot properties * fix live test * fix live test * minor fix * semaphores * fix configuration * kotlin collection --- .../com/baeldung/kotlin/CollectionsTest.kt | 121 ++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 kotlin/src/test/kotlin/com/baeldung/kotlin/CollectionsTest.kt diff --git a/kotlin/src/test/kotlin/com/baeldung/kotlin/CollectionsTest.kt b/kotlin/src/test/kotlin/com/baeldung/kotlin/CollectionsTest.kt new file mode 100644 index 0000000000..81a01ca4fb --- /dev/null +++ b/kotlin/src/test/kotlin/com/baeldung/kotlin/CollectionsTest.kt @@ -0,0 +1,121 @@ +package com.baeldung.kotlin + +import org.junit.Test +import kotlin.test.assertTrue +import kotlin.test.assertFalse +import kotlin.test.assertEquals + +class CollectionsTest { + + @Test + fun whenUseDifferentCollections_thenSuccess () { + val theList = listOf("one", "two", "three") + assertTrue(theList.contains("two")) + + val theMutableList = mutableListOf("one", "two", "three") + theMutableList.add("four") + assertTrue(theMutableList.contains("four")) + + val theSet = setOf("one", "two", "three") + assertTrue(theSet.contains("three")) + + val theMutableSet = mutableSetOf("one", "two", "three") + theMutableSet.add("four") + assertTrue(theMutableSet.contains("four")) + + val theMap = mapOf(1 to "one", 2 to "two", 3 to "three") + assertEquals(theMap[2],"two") + + val theMutableMap = mutableMapOf(1 to "one", 2 to "two", 3 to "three") + theMutableMap[4] = "four" + assertEquals(theMutableMap[4],"four") + } + + @Test + fun whenSliceCollection_thenSuccess () { + val theList = listOf("one", "two", "three") + val resultList = theList.slice(1..2) + + assertEquals(2, resultList.size) + assertTrue(resultList.contains("two")) + } + + @Test + fun whenJoinTwoCollections_thenSuccess () { + val firstList = listOf("one", "two", "three") + val secondList = listOf("four", "five", "six") + val resultList = firstList + secondList + + assertEquals(6, resultList.size) + assertTrue(resultList.contains("two")) + assertTrue(resultList.contains("five")) + } + + @Test + fun whenFilterNullValues_thenSuccess () { + val theList = listOf("one", null, "two", null, "three") + val resultList = theList.filterNotNull() + + assertEquals(3, resultList.size) + } + + @Test + fun whenFilterNonPositiveValues_thenSuccess () { + val theList = listOf(1, 2, -3, -4, 5, -6) + val resultList = theList.filter{ it > 0} + //val resultList = theList.filter{ x -> x > 0} + + assertEquals(3, resultList.size) + assertTrue(resultList.contains(1)) + assertFalse(resultList.contains(-4)) + } + + @Test + fun whenDropFirstItems_thenRemoved () { + val theList = listOf("one", "two", "three", "four") + val resultList = theList.drop(2) + + assertEquals(2, resultList.size) + assertFalse(resultList.contains("one")) + assertFalse(resultList.contains("two")) + } + + @Test + fun whenDropFirstItemsBasedOnCondition_thenRemoved () { + val theList = listOf("one", "two", "three", "four") + val resultList = theList.dropWhile{ it.length < 4 } + + assertEquals(2, resultList.size) + assertFalse(resultList.contains("one")) + assertFalse(resultList.contains("two")) + } + + @Test + fun whenExcludeItems_thenRemoved () { + val firstList = listOf("one", "two", "three") + val secondList = listOf("one", "three") + val resultList = firstList - secondList + + assertEquals(1, resultList.size) + assertTrue(resultList.contains("two")) + } + + @Test + fun whenSearchForExistingItem_thenFound () { + val theList = listOf("one", "two", "three") + + assertTrue("two" in theList) + } + + @Test + fun whenGroupItems_thenSuccess () { + val theList = listOf(1, 2, 3, 4, 5, 6) + val resultMap = theList.groupBy{ it % 3} + + assertEquals(3, resultMap.size) + print(resultMap[1]) + assertTrue(resultMap[1]!!.contains(1)) + assertTrue(resultMap[2]!!.contains(5)) + } + +} \ No newline at end of file From 2e119a5e997608925cc6b0398e2a0591a57733b8 Mon Sep 17 00:00:00 2001 From: Daniele Demichelis Date: Sun, 9 Jul 2017 21:22:17 +0200 Subject: [PATCH 10/89] BAEL-557 Spring Remoting with RMI (#2240) * Burlap & Hessian server added * Burlap & Hessian client work * Fixed main * Fixed formatting * Spring Remote example based on Burlap & Hessian runs in a JUnit test * Fixed main * Fixed formatting * Spring Remote example based on Burlap & Hessian runs in a JUnit test * Spring Remote example based on Burlap & Hessian runs in a JUnit test * Burlap & Hessian client work * Fixed main * Fixed main * Fixed formatting * Fixed formatting * Spring Remote example based on Burlap & Hessian runs in a JUnit test * Spring Remote example based on Burlap & Hessian runs in a JUnit test * Fixed POM * First version of remoting example based on RMI * Fixed format * Fixed format * Fixed format --- spring-remoting/pom.xml | 1 + spring-remoting/spring-remoting-rmi/pom.xml | 19 +++++++++ .../remoting-rmi-client/pom.xml | 30 ++++++++++++++ .../java/com/baeldung/client/RmiClient.java | 26 ++++++++++++ .../remoting-rmi-server/pom.xml | 40 +++++++++++++++++++ .../server/CabBookingServiceImpl.java | 16 ++++++++ .../java/com/baeldung/server/RmiServer.java | 34 ++++++++++++++++ 7 files changed, 166 insertions(+) create mode 100644 spring-remoting/spring-remoting-rmi/pom.xml create mode 100644 spring-remoting/spring-remoting-rmi/remoting-rmi-client/pom.xml create mode 100644 spring-remoting/spring-remoting-rmi/remoting-rmi-client/src/main/java/com/baeldung/client/RmiClient.java create mode 100644 spring-remoting/spring-remoting-rmi/remoting-rmi-server/pom.xml create mode 100644 spring-remoting/spring-remoting-rmi/remoting-rmi-server/src/main/java/com/baeldung/server/CabBookingServiceImpl.java create mode 100644 spring-remoting/spring-remoting-rmi/remoting-rmi-server/src/main/java/com/baeldung/server/RmiServer.java diff --git a/spring-remoting/pom.xml b/spring-remoting/pom.xml index 0b751d1fc9..b40f77eb50 100644 --- a/spring-remoting/pom.xml +++ b/spring-remoting/pom.xml @@ -33,6 +33,7 @@ remoting-hessian-burlap remoting-amqp remoting-jms + spring-remoting-rmi \ No newline at end of file diff --git a/spring-remoting/spring-remoting-rmi/pom.xml b/spring-remoting/spring-remoting-rmi/pom.xml new file mode 100644 index 0000000000..723158775f --- /dev/null +++ b/spring-remoting/spring-remoting-rmi/pom.xml @@ -0,0 +1,19 @@ + + + + spring-remoting + com.baeldung + 1.0-SNAPSHOT + + 4.0.0 + pom + + remoting-rmi-server + remoting-rmi-client + + spring-remoting-rmi + + + \ No newline at end of file diff --git a/spring-remoting/spring-remoting-rmi/remoting-rmi-client/pom.xml b/spring-remoting/spring-remoting-rmi/remoting-rmi-client/pom.xml new file mode 100644 index 0000000000..003976dc7b --- /dev/null +++ b/spring-remoting/spring-remoting-rmi/remoting-rmi-client/pom.xml @@ -0,0 +1,30 @@ + + + + spring-remoting-rmi + com.baeldung + 1.0-SNAPSHOT + + 4.0.0 + + remoting-rmi-client + + + + org.springframework.boot + spring-boot-starter-activemq + + + org.springframework.boot + spring-boot-starter-tomcat + + + + + com.baeldung + api + + + \ No newline at end of file diff --git a/spring-remoting/spring-remoting-rmi/remoting-rmi-client/src/main/java/com/baeldung/client/RmiClient.java b/spring-remoting/spring-remoting-rmi/remoting-rmi-client/src/main/java/com/baeldung/client/RmiClient.java new file mode 100644 index 0000000000..a568b749f9 --- /dev/null +++ b/spring-remoting/spring-remoting-rmi/remoting-rmi-client/src/main/java/com/baeldung/client/RmiClient.java @@ -0,0 +1,26 @@ +package com.baeldung.client; + +import com.baeldung.api.Booking; +import com.baeldung.api.BookingException; +import com.baeldung.api.CabBookingService; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.remoting.rmi.RmiProxyFactoryBean; + +@SpringBootApplication public class RmiClient { + + @Bean RmiProxyFactoryBean service() { + RmiProxyFactoryBean rmiProxyFactory = new RmiProxyFactoryBean(); + rmiProxyFactory.setServiceUrl("rmi://localhost:1099/CabBookingService"); + rmiProxyFactory.setServiceInterface(CabBookingService.class); + return rmiProxyFactory; + } + + public static void main(String[] args) throws BookingException { + CabBookingService service = SpringApplication.run(RmiClient.class, args).getBean(CabBookingService.class); + Booking bookingOutcome = service.bookRide("13 Seagate Blvd, Key Largo, FL 33037"); + System.out.println(bookingOutcome); + } + +} diff --git a/spring-remoting/spring-remoting-rmi/remoting-rmi-server/pom.xml b/spring-remoting/spring-remoting-rmi/remoting-rmi-server/pom.xml new file mode 100644 index 0000000000..5ce3f7f949 --- /dev/null +++ b/spring-remoting/spring-remoting-rmi/remoting-rmi-server/pom.xml @@ -0,0 +1,40 @@ + + + + spring-remoting-rmi + com.baeldung + 1.0-SNAPSHOT + + 4.0.0 + + remoting-rmi-server + + + UTF-8 + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-tomcat + + + + + com.baeldung + api + + + com.baeldung + api + ${project.version} + + + + \ No newline at end of file diff --git a/spring-remoting/spring-remoting-rmi/remoting-rmi-server/src/main/java/com/baeldung/server/CabBookingServiceImpl.java b/spring-remoting/spring-remoting-rmi/remoting-rmi-server/src/main/java/com/baeldung/server/CabBookingServiceImpl.java new file mode 100644 index 0000000000..55ec9c5733 --- /dev/null +++ b/spring-remoting/spring-remoting-rmi/remoting-rmi-server/src/main/java/com/baeldung/server/CabBookingServiceImpl.java @@ -0,0 +1,16 @@ +package com.baeldung.server; + +import com.baeldung.api.Booking; +import com.baeldung.api.BookingException; +import com.baeldung.api.CabBookingService; + +import static java.lang.Math.random; +import static java.util.UUID.randomUUID; + +public class CabBookingServiceImpl implements CabBookingService { + + @Override public Booking bookRide(String pickUpLocation) throws BookingException { + if (random() < 0.3) throw new BookingException("Cab unavailable"); + return new Booking(randomUUID().toString()); + } +} diff --git a/spring-remoting/spring-remoting-rmi/remoting-rmi-server/src/main/java/com/baeldung/server/RmiServer.java b/spring-remoting/spring-remoting-rmi/remoting-rmi-server/src/main/java/com/baeldung/server/RmiServer.java new file mode 100644 index 0000000000..7778c65e85 --- /dev/null +++ b/spring-remoting/spring-remoting-rmi/remoting-rmi-server/src/main/java/com/baeldung/server/RmiServer.java @@ -0,0 +1,34 @@ +package com.baeldung.server; + +import com.baeldung.api.CabBookingService; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.remoting.rmi.RmiServiceExporter; + +@SpringBootApplication public class RmiServer { + + @Bean CabBookingService bookingService() { + return new CabBookingServiceImpl(); + } + + @Bean RmiServiceExporter exporter(CabBookingService implementation) { + + // Expose a service via RMI. Remote obect URL is: + // rmi://:/ + // 1099 is the default port + + Class serviceInterface = CabBookingService.class; + RmiServiceExporter exporter = new RmiServiceExporter(); + exporter.setServiceInterface(serviceInterface); + exporter.setService(implementation); + exporter.setServiceName(serviceInterface.getSimpleName()); + exporter.setRegistryPort(1099); + return exporter; + } + + public static void main(String[] args) { + SpringApplication.run(RmiServer.class, args); + } + +} From 2f3398beaf47999cba34dbb020c2f211ae81235a Mon Sep 17 00:00:00 2001 From: Doha2012 Date: Mon, 10 Jul 2017 07:47:58 +0200 Subject: [PATCH 11/89] add more collection examples (#2243) * minor logging fix * spring security sso * use basic auth * use form login * cleanup * cleanup * final cleanup * second client app for sso * spring boot bootstrap * add logic * cleanup * add simple controller * add thymeleaf and security * minor fix * minor fix * add more boot properties * fix live test * fix live test * minor fix * semaphores * fix configuration * kotlin collection * add more collection examples --- .../com/baeldung/kotlin/CollectionsTest.kt | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/kotlin/src/test/kotlin/com/baeldung/kotlin/CollectionsTest.kt b/kotlin/src/test/kotlin/com/baeldung/kotlin/CollectionsTest.kt index 81a01ca4fb..59d6adccac 100644 --- a/kotlin/src/test/kotlin/com/baeldung/kotlin/CollectionsTest.kt +++ b/kotlin/src/test/kotlin/com/baeldung/kotlin/CollectionsTest.kt @@ -118,4 +118,29 @@ class CollectionsTest { assertTrue(resultMap[2]!!.contains(5)) } + @Test + fun whenApplyFunctionToAllItems_thenSuccess () { + val theList = listOf(1, 2, 3, 4, 5, 6) + val resultList = theList.map{ it * it } + print(resultList) + assertEquals(4, resultList[1]) + assertEquals(9, resultList[2]) + } + + @Test + fun whenApplyMultiOutputFunctionToAllItems_thenSuccess () { + val theList = listOf("John", "Tom") + val resultList = theList.flatMap{ it.toLowerCase().toList()} + print(resultList) + assertEquals(7, resultList.size) + assertTrue(resultList.contains('j')) + } + + @Test + fun whenApplyFunctionToAllItemsWithStartingValue_thenSuccess () { + val theList = listOf(1, 2, 3, 4, 5, 6) + val finalResult = theList.fold( 1000, { oldResult, currentItem -> oldResult + (currentItem *currentItem)}) + print(finalResult) + assertEquals(1091, finalResult) + } } \ No newline at end of file From 2e5cae0f20d9611c4f0a58078e51939b16628aa6 Mon Sep 17 00:00:00 2001 From: slavisa-baeldung Date: Mon, 10 Jul 2017 07:37:59 +0100 Subject: [PATCH 12/89] BAEL-964 - map util test --- libraries/pom.xml | 10 +- .../commons/collections/MapUtilsTest.java | 147 ++++++++++++++++++ 2 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 libraries/src/test/java/com/baeldung/commons/collections/MapUtilsTest.java diff --git a/libraries/pom.xml b/libraries/pom.xml index a3b78f1695..94ca015ae6 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -59,7 +59,8 @@ ${basedir}/datanucleus.properties ${basedir}/log4j.properties true - false + false + @@ -372,6 +373,12 @@ ${awaitility.version} test + + org.hamcrest + java-hamcrest + ${org.hamcrest.version} + test + 0.7.0 @@ -404,6 +411,7 @@ 0.10 3.5.0 3.0.0 + 2.0.0.0 diff --git a/libraries/src/test/java/com/baeldung/commons/collections/MapUtilsTest.java b/libraries/src/test/java/com/baeldung/commons/collections/MapUtilsTest.java new file mode 100644 index 0000000000..4954f2574a --- /dev/null +++ b/libraries/src/test/java/com/baeldung/commons/collections/MapUtilsTest.java @@ -0,0 +1,147 @@ +package com.baeldung.commons.collections; + +import org.apache.commons.collections4.MapIterator; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.collections4.PredicateUtils; +import org.apache.commons.collections4.TransformerUtils; +import org.junit.Before; +import org.junit.Test; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.util.HashMap; +import java.util.Map; + +import static org.hamcrest.Matchers.is; +import static org.hamcrest.collection.IsMapContaining.hasEntry; +import static org.hamcrest.collection.IsMapWithSize.aMapWithSize; +import static org.hamcrest.collection.IsMapWithSize.anEmptyMap; +import static org.junit.Assert.*; + +public class MapUtilsTest { + + private String[][] color2DArray = new String[][] { + {"RED", "#FF0000"}, + {"GREEN", "#00FF00"}, + {"BLUE", "#0000FF"} + }; + private String[] color1DArray = new String[] { + "RED", "#FF0000", + "GREEN", "#00FF00", + "BLUE", "#0000FF" + }; + private Map colorMap; + + @Before + public void createMap() { + this.colorMap = MapUtils.putAll(new HashMap(), this.color2DArray); + } + + @Test + public void whenCreateMapFrom2DArray_theMapIsCreated() { + this.colorMap = MapUtils.putAll(new HashMap(), this.color2DArray); + + assertThat(this.colorMap, is(aMapWithSize(this.color2DArray.length))); + + assertThat(this.colorMap, hasEntry("RED", "#FF0000")); + assertThat(this.colorMap, hasEntry("GREEN", "#00FF00")); + assertThat(this.colorMap, hasEntry("BLUE", "#0000FF")); + } + + @Test + public void whenCreateMapFrom1DArray_theMapIsCreated() { + this.colorMap = MapUtils.putAll(new HashMap(), this.color1DArray); + + assertThat(this.colorMap, is(aMapWithSize(this.color1DArray.length / 2))); + + assertThat(this.colorMap, hasEntry("RED", "#FF0000")); + assertThat(this.colorMap, hasEntry("GREEN", "#00FF00")); + assertThat(this.colorMap, hasEntry("BLUE", "#0000FF")); + } + + @Test + public void whenVerbosePrintMap_thenMustPrintFormattedMap() { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + PrintStream outPrint = new PrintStream(out); + + outPrint.println("Optional Label = "); + outPrint.println("{"); + outPrint.println(" RED = #FF0000"); + outPrint.println(" BLUE = #0000FF"); + outPrint.println(" GREEN = #00FF00"); + outPrint.println("}"); + + String expectedOut = out.toString(); + + out.reset(); + + MapUtils.verbosePrint(outPrint, "Optional Label", this.colorMap); + assertEquals(expectedOut, out.toString()); + } + + @Test + public void whenGetKeyNotPresent_thenMustReturnDefaultValue() { + String defaultColorStr = "COLOR_NOT_FOUND"; + String color = MapUtils.getString(this.colorMap, "BLACK", defaultColorStr); + + assertEquals(color, defaultColorStr); + } + + @Test + public void whenGetOnNullMap_thenMustReturnDefaultValue() { + String defaultColorStr = "COLOR_NOT_FOUND"; + String color = MapUtils.getString(null, "RED", defaultColorStr); + + assertEquals(color, defaultColorStr); + } + + @Test + public void whenInvertMap_thenMustReturnInvertedMap() { + Map invColorMap = MapUtils.invertMap(this.colorMap); + assertEquals(this.colorMap.size(), invColorMap.size()); + + MapIterator itColorMap + = MapUtils.iterableMap(this.colorMap).mapIterator(); + + while (itColorMap.hasNext()) { + String colorMapKey = itColorMap.next(); + String colorMapValue = itColorMap.getValue(); + + String invColorMapValue = MapUtils.getString(invColorMap, colorMapValue); + + assertTrue(invColorMapValue.equals(colorMapKey)); + } + } + + @Test(expected = IllegalArgumentException.class) + public void whenCreateFixedSizedMapAndAdd_thenMustThrowException() { + Map rgbMap = MapUtils.fixedSizeMap(MapUtils.putAll( + new HashMap(), + this.color1DArray)); + + rgbMap.put("ORANGE", "#FFA500"); + } + + @Test(expected = IllegalArgumentException.class) + public void whenAddDuplicateToUniqueValuesPredicateMap_thenMustThrowException() { + Map uniqValuesMap + = MapUtils.predicatedMap(this.colorMap, null, PredicateUtils.uniquePredicate()); + + uniqValuesMap.put("NEW_RED", "#FF0000"); + } + + @Test + public void whenCreateLazyMap_theMapIsCreated() { + Map intStrMap = MapUtils.lazyMap( + new HashMap(), + TransformerUtils.stringValueTransformer()); + + assertThat(intStrMap, is(anEmptyMap())); + + intStrMap.get(1); + intStrMap.get(2); + intStrMap.get(3); + + assertThat(intStrMap, is(aMapWithSize(3))); + } +} From c2a0fba1a1395161e5028d6fb85f8c6a76f811ef Mon Sep 17 00:00:00 2001 From: slavisa-baeldung Date: Mon, 10 Jul 2017 11:41:09 +0100 Subject: [PATCH 13/89] BAEL-964 - fixing version variable in maven --- libraries/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/pom.xml b/libraries/pom.xml index 94ca015ae6..b810bc5757 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -376,7 +376,7 @@ org.hamcrest java-hamcrest - ${org.hamcrest.version} + ${org.hamcrest.java-hamcrest.version} test @@ -411,7 +411,7 @@ 0.10 3.5.0 3.0.0 - 2.0.0.0 + 2.0.0.0 From 54c6928bfe1e1586474c30f1d52194c235f6802d Mon Sep 17 00:00:00 2001 From: Jesus Boadas Date: Mon, 10 Jul 2017 12:11:23 -0400 Subject: [PATCH 14/89] Introduction to Vaadin (#2247) * deleted OpenNLP * Introduction to Vaadin --- libraries/pom.xml | 185 +- .../java/com/baeldung/vaadin/VaadinUI.java | 221 + .../webapp/VAADIN/themes/mytheme/addons.scss | 7 + .../webapp/VAADIN/themes/mytheme/favicon.ico | Bin 0 -> 31005 bytes .../webapp/VAADIN/themes/mytheme/mytheme.scss | 38 + .../webapp/VAADIN/themes/mytheme/styles.css | 12986 ++++++++++++++++ .../webapp/VAADIN/themes/mytheme/styles.scss | 11 + .../webapp/VAADIN/themes/valo/addons.scss | 7 + .../com/baeldung/vaadin/VaadinUITests.java | 99 + 9 files changed, 13552 insertions(+), 2 deletions(-) create mode 100644 libraries/src/main/java/com/baeldung/vaadin/VaadinUI.java create mode 100644 libraries/src/main/webapp/VAADIN/themes/mytheme/addons.scss create mode 100644 libraries/src/main/webapp/VAADIN/themes/mytheme/favicon.ico create mode 100644 libraries/src/main/webapp/VAADIN/themes/mytheme/mytheme.scss create mode 100644 libraries/src/main/webapp/VAADIN/themes/mytheme/styles.css create mode 100644 libraries/src/main/webapp/VAADIN/themes/mytheme/styles.scss create mode 100644 libraries/src/main/webapp/VAADIN/themes/valo/addons.scss create mode 100644 libraries/src/test/java/com/baeldung/vaadin/VaadinUITests.java diff --git a/libraries/pom.xml b/libraries/pom.xml index b810bc5757..28dd36fceb 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -71,9 +71,78 @@ + + + org.apache.maven.plugins + maven-war-plugin + 3.0.0 + + false + WEB-INF/classes/VAADIN/widgetsets/WEB-INF/** + + + + com.vaadin + vaadin-maven-plugin + ${vaadin.plugin.version} + + + + update-theme + update-widgetset + compile + compile-theme + + + + + + org.apache.maven.plugins + maven-clean-plugin + 3.0.0 + + + + src/main/webapp/VAADIN/themes + + **/styles.css + **/styles.scss.cache + + + + + + + org.eclipse.jetty + jetty-maven-plugin + ${jetty.version} + + 2 + true + + + - + + + + vaadin-addons + http://maven.vaadin.com/vaadin-addons + + + + + + com.vaadin + vaadin-bom + ${vaadin.version} + pom + import + + + + @@ -379,6 +448,72 @@ ${org.hamcrest.java-hamcrest.version} test + + + com.vaadin + vaadin-server + + + com.vaadin + vaadin-push + + + com.vaadin + vaadin-client-compiled + + + com.vaadin + vaadin-themes + + + org.seleniumhq.selenium + selenium-java + test + 3.4.0 + + + org.seleniumhq.selenium + htmlunit-driver + 2.27 + + + org.eclipse.jetty.websocket + websocket-server + ${jetty.version} + + + org.eclipse.jetty.websocket + websocket-client + ${jetty.version} + + + org.eclipse.jetty.websocket + websocket-api + ${jetty.version} + + + org.eclipse.jetty.websocket + websocket-common + ${jetty.version} + + + org.eclipse.jetty + jetty-continuation + ${jetty.version} + + + org.eclipse.jetty + jetty-util + ${jetty.version} + + + org.seleniumhq.selenium + selenium-api + 3.4.0 + test + jar + + 0.7.0 @@ -412,6 +547,52 @@ 3.5.0 3.0.0 2.0.0.0 + + 7.7.10 + 8.0.6 + mytheme + - + + + + vaadin-prerelease + + false + + + + vaadin-prereleases + http://maven.vaadin.com/vaadin-prereleases + + + vaadin-snapshots + https://oss.sonatype.org/content/repositories/vaadin-snapshots/ + + false + + + true + + + + + + vaadin-prereleases + http://maven.vaadin.com/vaadin-prereleases + + + vaadin-snapshots + https://oss.sonatype.org/content/repositories/vaadin-snapshots/ + + false + + + true + + + + + + diff --git a/libraries/src/main/java/com/baeldung/vaadin/VaadinUI.java b/libraries/src/main/java/com/baeldung/vaadin/VaadinUI.java new file mode 100644 index 0000000000..659d45248f --- /dev/null +++ b/libraries/src/main/java/com/baeldung/vaadin/VaadinUI.java @@ -0,0 +1,221 @@ +package com.baeldung.vaadin; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.servlet.annotation.WebServlet; + +import com.vaadin.annotations.Theme; +import com.vaadin.annotations.VaadinServletConfiguration; +import com.vaadin.server.ExternalResource; +import com.vaadin.server.FontAwesome; +import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinServlet; +import com.vaadin.ui.Button; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.DateField; +import com.vaadin.ui.FormLayout; +import com.vaadin.ui.Grid; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.InlineDateField; +import com.vaadin.ui.Label; +import com.vaadin.ui.Link; +import com.vaadin.ui.ListSelect; +import com.vaadin.ui.NativeButton; +import com.vaadin.ui.NativeSelect; +import com.vaadin.ui.Panel; +import com.vaadin.ui.PasswordField; +import com.vaadin.ui.RichTextArea; +import com.vaadin.ui.TextArea; +import com.vaadin.ui.TextField; +import com.vaadin.ui.TwinColSelect; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; + +@SuppressWarnings("serial") +@Theme("mytheme") +public class VaadinUI extends UI { + + @Override + protected void init(VaadinRequest vaadinRequest) { + final VerticalLayout verticalLayout = new VerticalLayout(); + verticalLayout.setSpacing(true); + verticalLayout.setMargin(true); + final GridLayout gridLayout = new GridLayout(3,2); + gridLayout.setSpacing(true); + gridLayout.setMargin(true); + final HorizontalLayout horizontalLayout = new HorizontalLayout(); + horizontalLayout.setSpacing(true); + horizontalLayout.setMargin(true); + final FormLayout formLayout = new FormLayout(); + formLayout.setSpacing(true); + formLayout.setMargin(true); + final GridLayout buttonLayout = new GridLayout(3, 5); + buttonLayout.setMargin(true); + buttonLayout.setSpacing(true); + + final Label label = new Label(); + label.setId("Label"); + label.setValue("Label Value"); + label.setCaption("Label"); + gridLayout.addComponent(label); + + final Link link = new Link("Baeldung", + new ExternalResource("http://www.baeldung.com/")); + link.setId("Link"); + link.setTargetName("_blank"); + gridLayout.addComponent(link); + + final TextField textField = new TextField(); + textField.setId("TextField"); + textField.setCaption("TextField:"); + textField.setValue("TextField Value"); + textField.setIcon(FontAwesome.USER); + gridLayout.addComponent(textField); + + final TextArea textArea = new TextArea(); + textArea.setCaption("TextArea"); + textArea.setId("TextArea"); + textArea.setValue("TextArea Value"); + gridLayout.addComponent(textArea); + + final DateField dateField = new DateField("DateField", new Date(0)); + dateField.setId("DateField"); + gridLayout.addComponent(dateField); + + final PasswordField passwordField = new PasswordField(); + passwordField.setId("PasswordField"); + passwordField.setCaption("PasswordField:"); + passwordField.setValue("password"); + gridLayout.addComponent(passwordField); + + final RichTextArea richTextArea = new RichTextArea(); + richTextArea.setCaption("Rich Text Area"); + richTextArea.setValue("

RichTextArea

"); + richTextArea.setSizeFull(); + + Panel richTextPanel = new Panel(); + richTextPanel.setContent(richTextArea); + + final InlineDateField inlineDateField = new InlineDateField(); + inlineDateField.setValue(new Date(0)); + inlineDateField.setCaption("Inline Date Field"); + horizontalLayout.addComponent(inlineDateField); + + Button normalButton = new Button("Normal Button"); + normalButton.setId("NormalButton"); + normalButton.addClickListener(e -> { + label.setValue("CLICK"); + }); + buttonLayout.addComponent(normalButton); + + Button tinyButton = new Button("Tiny Button"); + tinyButton.addStyleName("tiny"); + buttonLayout.addComponent(tinyButton); + + Button smallButton = new Button("Small Button"); + smallButton.addStyleName("small"); + buttonLayout.addComponent(smallButton); + + + Button largeButton = new Button("Large Button"); + largeButton.addStyleName("large"); + buttonLayout.addComponent(largeButton); + + + Button hugeButton = new Button("Huge Button"); + hugeButton.addStyleName("huge"); + buttonLayout.addComponent(hugeButton); + + + Button disabledButton = new Button("Disabled Button"); + disabledButton.setDescription("This button cannot be clicked"); + disabledButton.setEnabled(false); + buttonLayout.addComponent(disabledButton); + + + Button dangerButton = new Button("Danger Button"); + dangerButton.addStyleName("danger"); + buttonLayout.addComponent(dangerButton); + + + Button friendlyButton = new Button("Friendly Button"); + friendlyButton.addStyleName("friendly"); + buttonLayout.addComponent(friendlyButton); + + Button primaryButton = new Button("Primary Button"); + primaryButton.addStyleName("primary"); + buttonLayout.addComponent(primaryButton); + + NativeButton nativeButton = new NativeButton("Native Button"); + buttonLayout.addComponent(nativeButton); + + Button iconButton = new Button("Icon Button"); + iconButton.setIcon(FontAwesome.ALIGN_LEFT); + buttonLayout.addComponent(iconButton); + + Button borderlessButton = new Button("BorderLess Button"); + borderlessButton.addStyleName("borderless"); + buttonLayout.addComponent(borderlessButton); + + Button linkButton = new Button("Link Button"); + linkButton.addStyleName("link"); + buttonLayout.addComponent(linkButton); + + Button quietButton = new Button("Quiet Button"); + quietButton.addStyleName("quiet"); + buttonLayout.addComponent(quietButton); + + horizontalLayout.addComponent(buttonLayout); + + final CheckBox checkbox = new CheckBox("CheckBox"); + checkbox.setValue(true); + checkbox.addValueChangeListener(e -> + checkbox.setValue(!checkbox.getValue())); + formLayout.addComponent(checkbox); + + List numbers = new ArrayList(); + numbers.add("One"); + numbers.add("Ten"); + numbers.add("Eleven"); + ComboBox comboBox = new ComboBox("ComboBox"); + comboBox.addItems(numbers); + formLayout.addComponent(comboBox); + + ListSelect listSelect = new ListSelect("ListSelect"); + listSelect.addItems(numbers); + listSelect.setRows(2); + formLayout.addComponent(listSelect); + + NativeSelect nativeSelect = new NativeSelect("NativeSelect"); + nativeSelect.addItems(numbers); + formLayout.addComponent(nativeSelect); + + TwinColSelect twinColSelect = new TwinColSelect("TwinColSelect"); + twinColSelect.addItems(numbers); + + Grid grid = new Grid("Grid"); + grid.setColumns(new Object[] {"Column1", "Column2", "Column3"}); + grid.addRow(new Object[] {"Item1", "Item2", "Item3"}); + grid.addRow(new Object[] {"Item4", "Item5", "Item6"}); + + Panel panel = new Panel("Panel"); + panel.setContent(grid); + panel.setSizeUndefined(); + + verticalLayout.addComponent(gridLayout); + verticalLayout.addComponent(richTextPanel); + verticalLayout.addComponent(horizontalLayout); + verticalLayout.addComponent(formLayout); + verticalLayout.addComponent(twinColSelect); + verticalLayout.addComponent(panel); + setContent(verticalLayout); + } + + @WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true) + @VaadinServletConfiguration(ui = VaadinUI.class, productionMode = false) + public static class MyUIServlet extends VaadinServlet { + } +} \ No newline at end of file diff --git a/libraries/src/main/webapp/VAADIN/themes/mytheme/addons.scss b/libraries/src/main/webapp/VAADIN/themes/mytheme/addons.scss new file mode 100644 index 0000000000..a5670b70c7 --- /dev/null +++ b/libraries/src/main/webapp/VAADIN/themes/mytheme/addons.scss @@ -0,0 +1,7 @@ +/* This file is automatically managed and will be overwritten from time to time. */ +/* Do not manually edit this file. */ + +/* Import and include this mixin into your project theme to include the addon themes */ +@mixin addons { +} + diff --git a/libraries/src/main/webapp/VAADIN/themes/mytheme/favicon.ico b/libraries/src/main/webapp/VAADIN/themes/mytheme/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..ffb34a65c73eb1b3d59dcbb8f18ec78a8b0fc767 GIT binary patch literal 31005 zcmeHu2UL{1_U{a!(mMiDMY@6o1XQYkh@c=AiU^1bD4-}RAjLsZnt+0I1!+Td!Kp9Hw%BW`h2+b(v-dAMJ3Bkc2MUEok)UX4Q6T3= z32s86j-XH|Ztk^bMilBAsN1t=?O6nc3Sb2UCv6?I zxbZY7k9leAEoyaTW*ECNH-?4f@ieBT@igKUNJHR3XgiXIl7PJNZJAcbQ-JJ}o7k0w zNhD2`*u+&O8XmYxYan>hgFGc6q!TyFAu~ z#bQ@+Fu^iX2i`#%NDJE#>c`d$4fq=G!xo1j|Src!$scT7v$d z4o4Ee_~lFDfQ*%iY?;-uHz<5xV1Eb+)JOq}|wd-F}l%i2cIxg<}Nu3==HFI>def4QxwjgOq-e~bKpkNu}VIIg%t z6v;;a_A4*=4xw4|nZLgOC(nr71QhYcwu7%w%s(O{Al$fZa|_XX5Q1+CD79I^-RofwY8n8+j1w{-+$#<657gor8Iq zIF*UQVGD_H3pqqMSRPNKz)oarUx5jhVI6!2XC*@rN5KEaeM&}bI`BV zm3$J|KP*UKtpPqcjbau0U&L<$zY5Dp9ez$j8tht|Rmg)NZzFF)-Nt<5`>{0QKpf}` z^fPO65&u4sPL7wCwHLeCTL#vl57>$91Nb`dZjBzn3d@iO(<`LkVExA}_EjL|xt6y$WDEe! z#x~;!ZoCaa-cSbYH$f)BN5DCYpI3;T=;|RK+tqs7Zr24H-C zGX{_ce*Pfyl;9r-J{97Dz6H)*K=+5f6Lbjq!dPvpKo_rjsB=)B%vHmI-~qvai~+z0 zZG_N{pbJEwfHxuo$U=0m!Jk9l1^ow*58?!9>-aSumM79l0Y63_ZCsH@xm4na#I|1~Ri0=L{j(|6m0c9cb*L)K6-9YZty8aQFYh#{H0{X*($XOby zMdZLg3tjn$EIg*n_4=hBjR-BoI|16_@vn^|7=tw#QybR{xPGkpaQrwS{m0K?$YUaX zP5x*LA_u#=1Y&q=eE(rQ|Nbft&IR~e9`F2ve0=}$zJp)`P!^O4bpU^G4f`3V<8@EK zjUPv#OQ7qCEFs)RsX-*AL8f0Jen*v#?IA8 z;N}`ZKM4u=p1Fny+|uArTZCm;2mR7I9i#_sArI&?5T3uWKf-#nKL64=R>qRR9;L>Q z&_B4&{PqVnalq~te*12%5@`#0L7wA)_pkGhuokTQAF#)SI$N3QgDn11Hhj6zQwUNK zEdJdO3wc4FaR2%z|FgCZ;QjArXjfowLW}H^Ak(FhR_t6`8rUyo0pF8}PaRo6-;qG4 z&@Yi9<#|xI{vOc6Hn1(^0ry#uC*(bqxf!?7|H3&ySPRBdw}ABr;v`>MU6_PTag%w+ zuw(Iv{UK{SvIm3vFko9?T}2XNo3M_M;9e87naoo~LZv zPJp=%u&=JpjR4!;4dxOn7MW9-JV^Wj*Fj`nuJs=&BXv6f9iTzxA7}&GLLQJ8 z%xsI0C*-|R7A$Z4t&c+*RUobi;7x_`7d40-;Fv&}gaqXh%7px9-5M?EFExx)LHq?| z1D;S8LB>Y8gfd|+!e>a2E208&fZxQ&y+~a1XSoFVgdCxVwuY?ZkOx6F z&ROWAfd2pE`!6Vu@cX~H|0H05IU!cuXdfHjBQ*bk{r9gj{`>r24g6OF|L*s{v?&UxAL)I1$d%*RjDj2m1_e( z`+)2>@q5mV?eP0dFm_NcfZv*|Xo7zuVEI>YLmFuB1X_q4p1T7bK|8_UJO2UmS|5O3 z!G0F6_q>zX)#W+3$H%ADCG2F8A<{2|X2Tf#+K;udSVm-~qoN5oHew>w{Vqr5&e~js zVcE33EWlis^AcqMD&U{+_I1e^p z|CJYFo2h8n2Q0)un9~Go1gyX21Utj~Nb~?HNOLFXKA=;9q(*Y4ETN{bp3g0 ztR1;e#AB!W!#p7HBIN7+0Jgh^Wtp%}6R;BWzj1EB_563b|CKL%M(PmT0do@CPT_fA zJ2Pu|SHU+lmPj2A_#eCt&11ox1Qwq8PGoFfx1rzhCg4YG7uXTR1kMWaV*t++)_e>y zCTli@#9|;Of$KWpx%{i$sF)EYvr_XRgc)0-FN<6x<;%Pxh|Y&$Yfq z{1Afw7yJLU9|RkMSk~f{AB32XFjqI?2lPg3aTRiQ^-~9bVK)eN5GSOAx%-RlEPgLV z^bGD{!1qx3>-d+U4I#Eq3&wzXt&G=8d)k<62~#z#TC` z_XIwK9Iq36f8hLs>(OWeu$_FZKdf0ZHGX*fz*c6e+}82qRu+LDGRBU^LmLA9UYo-N zU2Wt~kO{HCm=9tb1sD`q;E~*Z2q9A@Cva#y_w5dte{4HNN0`srGe@ z@H@82yc2kT55GZpCk?)f8(n|DJkf=ntqa;Pmm#m8y8m+-@k7f9Hn4vn?13P5f*s-a zP3UPDql0lk&S5w5A@l*s5xd!re5(cS?bdNY-6Ct%a3eCG!M9mJ#~jEwEDly9@4)w9 z>-5u~9wIyl-xvHr#xMPWnAWgO13x4{upzjwhGn?FgMMml@3DT44Eyk>ejxb4oCUT$ z{prCv9>Uz6ZHmVG`3!LH01~(d0e&?2PjoY%pW^3oCNJI({32_kTwoik5F36UN2~}j z6V3@>8SYWn*4y$!hYg;{p0C?GEF)`fmgrA9*yeY<;I}ku z^WYCT9{->0=kMk((jMsx)Ez!%gzFTH75*+k-@f?0d>ub5!@9p~gS>;hfjmSO7%#%u ztl{|m{9TJ3{>p#i*B5%cT?5{e`DelUV~WJWFdqJ6GQ&<5U%<}RJ_CEliFN$24C~;# z$@hTfPwgNdz!UI>n2~vci~~MCMezTH|NO)H1=fZ?u3xY{7*C+@nMzmSJ36tei_=If z599gYB^;~jDq<8A40@Ds*wO$L;S%w_m3 zLps&p$IlyVh_HW|NTXf?>kDo?V-twqzpv{M?!#xQJV4y=@GsL;>2) zye}lIuYbzn+6w(3n16)td!Q}+iH@*71OEVdPL-Gg`@zqDC=<$t7^Wc>Fn|AQ|A_Cw z&%H4`OIwG|(S{+VvA zE&M+Zz!UBZ2>78)C>vscSSC`@!HAwWoUIXX6LLZ@H)4d4ZM!gC4y+0iQat|$dB8(;w6=KM?NCrJO+ z?n03Bs~j?XJORdVs^ARx{tc|b(4N=gMZ9i*VkJC7tbdgVG#hhRMtCCQ%7KNl!2eI+ z&#wT6fA#zd!M|Z{Or)T|`5`%Cd%%9-xjy*b=4Z@>my5?wz(dgUulRp`|7%+~Um$NN z1ImK-4rPOWAZO7V_qhan`Kz3;Cd2nYPBgBF9DXYW_LQ`LeSW)U7X;kD;@w#PC+zEO z;r#)S0c1g$P&NVMMofgdzsm`80rnezehzgH>|*`={HNYG;@PNwLjCXR2=5S{kS~6X zMZOWjf^V`w{XafGC-kfE-?_g)#{Z9f`b(X!(IS`uZeS~axW6ErIYS&9F%WS5J2_z- zU>i7({-^t+je7lEc>`wXzu=w1f9(E<&`)T4g!4MQZ~dG5I}qmr8^iBGp`OJxE8|o9N_o?&&A;S4&&QD+@Iq6 zf%N6C?oZ*FCShHLcwihr(AB?#?_Z^b_OwwqNX!S~Rv3GOw0?gL_o9URYgpcRe+|#j zfbIMry}$mof4|ccJQoAH6!@#}2jDxx*%^V~uj5Ln|38rIO$@ZV9|bcB&k=5V? z$p1ZJn{G90o_N^fT+Pl9zMiPZBoX>SeBGu|4qGngpH>Y)_00>`*DpL*N9|z@Hmn-p zkFapxr_9JY<~~J)B7IhRAnzu%=i&jgFqG{p)9)T6?yAPG=)MMB=^OlDvNV}?YSDP_ z&SxdZd)#c*Yi80Zz4tINfS8Ef%(PaXOt^mHBXY`OGB$ zNKKf+<1pPWi;*|G^S7erc=bX#(hB^~pwcZj%lGxX(HQ4OO>IJ@cRruyd}LwZTl$Ss zfWmWR#KIaKZZ5iWP;xo^{`F6Vj}FWSSB@>8J@krM&UuF_lh|eDzE`oY)Rd~KD5(Q$ zF0Ibf;(Ch?T>1R5WY_cXBIe15gJ(_-J|lB+H_Lq}?X2@e^b)zty~dtIul;RFz-fMDqi5!Q|(e5SxP>^Sq_%zAdXWw1yz!DdQzQ?s5 zbp@VN{d1H)mu~V!?qZGVa!#081 z_0aIWAF2EYQsTNJI;3oqN{655@S^Fqn?L1=CW==Mc|sk{_Rj0*(;MH3H@ik$2x8e< z&f4p$`?$yW?1d)dV|yBdE(V=dXYQ9Up%rspydPuSnDR@6!}pPZ&FF zFCf3ievh-uhpW6$;0c)?iTQn+?E&1p7QClvw~-EzuDZ~@7eDD7r*Vtt5v^URzOhh> zce6sCDm(uPKStF@yv$m>Lc!_Ir&X`=oadL}&)@F%@!%zun=HEW1{!a9!?_LlXnf@~ zp9%6aY8+!%KHPHRz_EAocJg+LFXVT4i(Ah<$AxNvKg+y z{28*#e3#Gl3HGt~ZR<<>q_z3|9-{>@E!LRFevfk>`%H`XzpLr3X_H90Vt~sN@?R9b zChXwP<8R`R_V-CpKXbj2vGGNMWr9Y-o~!&u&U9v)_CwdP(%Lp{-R!!jb_EYVoEZ=$K@vGypvIk|| zWxZq>3horVcHF&iVU=k0&Qizp*NK6puge-FQY3H42FasIj*y()B1^H4jDFK?l9FO{ zaqfMt-CqoO^&7Sl9bQqq^H7>>KjnF*C2JPZUE*)}N9?lC*gDzTkcb#7D=C)d9`*U~ z<%5c+*H*QyHb*|Hlqol=99Oni4pdeP)Y+w*_Wj6Xy~o_IWVUj#G1>FpxfwtIr9;iN zcjOy+@0h5Ven8qt>&=Y5_{y5MPYjE7ZwPa;adC9f;@lbD$M>nfoiTi8(?{~vFV}V1 zcc6UdfY;>th07~XNdjF`UFwtqOV7JsRDG+;q}ofQp^(viJJoQ?`Fs4cC(ojU#NzAX zKVNZ4Ur4V%%y+>fdFOdC8G-!WCE`(g6mvdZX&gJl5Gh~xR9(>Eh^f7NJ z-veEWw5zF|rYe`iKb@?i>!0}^^8H#R$H(c9%TD`E_S@VxEx3byv{Jl(%$z#$Vbfdv zws$9N&KKwO%oYs$SaMq)ZJDS%Qt5S>t?QacXT!;tCzA_|%+kjD%MZUhe6lBBr1~7S zMVSSY#b}2~TH@8VKpum-S>wuY9^W+h+I@$+bRD%9JF4bfM)PClVwP>X?~vNGcMRoB z>jWF?8no2D?LME_S2Yzmm6fYKQgHUdxf@0_S9~t{r0-;TFdT8ZGL$iHnLlKewi?iz=v}bMabW5E^6t*L9LGLy z+zU2h&&^9?q6PLigLauA$IjKdE%7u4a#eSwR?Su~j`T(fkZTBsCCDYNHZFWMiO-)I zdHL0-Ce6*%=TWxeZk+#Ol19m`npcg?#@FYi03>x4oHw5Td6oVG=eI+6vQY4jgEn8lwU z9~Vi^cms8%&Do8YdT;Ue?WAUy!=p(&BD?KYQ4L7dr7n5GS_+N6y#}XNl4KDiL8PydwFr+H@T;g%0)X{p9=`}dgZ>V%}!-i>Qs;P zWe`-p9er9PRmZhZZ%P^~LpQ(k!>PU&4IYOtnu|Lf#&>AtN9Pr5)U^5R5y|fKDBN0F zcZ}6RYw5gnme<{-tWzcF`Pl;W7fBvba+m80(l@fPsm0yIezdAR@Ju+EctD!?K=>x+ zFti*e7ZrJeAETv8>vd;tgBbO@Vx%Twx3Am!ZQJ&xZjd*ANkN{ph(_;%Z0_4$-cNCM z&!+l|TWXviyzu^B@i6|rf}TvR9mOptYP)6^X^Tj{#_MdQ0t&>3+OtiG&iH>;@yF7i z4rPwoCbvWQOr)x|rAjB4awk{BTP#(>o>?RDyNosohfx;-aE^%#SG2AkXdR{6gY}&J z$Z>;*oa0HDo)6aLNNb?3;!g8<3c((3ZW3DY>XlbXyUstl>PXx3)H*J zi~Oz0k}r?n+y7iHa<3g5tGgn5%eyV}ku-hOdS~-RsJG?5iK4}*4vA+yS2Gy;T5ETE z)APboUSYCf2DI`OqXLhHqEQwthbB`qyA?$e7t}5Fi1^jR>RI`l8dp4T-B)9&Bo&Nagf5$TZdu5kC})i(QR8B|4DzFod-cLTNk3x zeckyMT+U1A+wq}s7p7#l?7wxGZ#%}JthW78PhNvu$)r#9yqmrcn#e z{2Y`&ADGRX`<=4K_f3scmGFva#(c+NL+Mvyy1Mn1UbLv*rUs`2k7mb;&f#ojSoluA zq1C*)^hvGA7z1j|&{ae{by&vQ#4C>^O z)V5C^K;138HMQx&*}WcOZK_AL>%ROjEI(>)p782T8DpTE?e+ZIqg^gJKAzJRF||Yu z)>h93Cf^)Swqy)u)TZk0$*+&gn~D8WVtDDSf!Q6q=$F^KeTF=Qa>=Ra=LbAoQ6YM} z%f&mFCz`^y%^zl1C03HJ<5U+gP@T;fCRQ&Cj`Qmx>Arg2dO6X`X+%z-di-(Uy9ClU z(l+uobvkh}-}A&~t@gY8pUGnOFEQs_y&f4@Ng5X`D3g5uN9@QgT{VUdUp16@YjqJ( zSVi|ry*kP_xy&2W`tYH$r`h6nZ9g}qeW9q~R?(OAH0C8`i+*P5J^f@7rJ1D?{_?7v z=r@*06+E1jlXi_{yLNxnVkEs}NhaZ+ktoPWD*E{noxF9$eybH%^w;ceZoeQ;M&}#4 zZN_YBPk3EXO_?2T23W41q(Odb-VdA|)#Pnk+gRH44)c<|z;K$}aHJVsP2!JM=VeQg zm+w$jyNV@Bn5z4c;&00!-)r7?`oOAO(I@TlOcJHZ1)i6K3O}51Y7KjGcfSpG+l@}1 z);@lnXu_dAz>S-hiO5Im>+xqNhAXnL(qj9;Yc1OM6vNEu1<-6ZOKDWQ^QI$sbv~sY_qC`f?0Z?0M|Q z-7QSy@wTj=XFfZj(<=X)BI@&K<=%#QG1dVt1DB~bA(91YBCUH$YUWK+G1{D$zbT+v z?3#l-gv3^+7^C#>P&#uyS5AHspx!wcWS|n)D~lG-_#E+UKDugDE^_4ieK0Q@6|UTl z7=BIK!H+4PU8$)|kPQ?$f2-056+j=mrTUJY9NI<&Z7Ug2{8{>v%snRxze6W>6sftV zZ1*ZTMDb1yb%vtQU9xcGdvCh4=go^dP;Aw$Q_UJjCS5|0V~VMy?P%m|$b>z<_=@+s zW8NQ73Z5}$mfUvR2bFrxCNQ6JAh5%}_sUr0>`~H*YbB1W*5})9wkJyN%JNTLp7Wgc zxukegq?~ku!ppKP1&hieeL3~*UXfLosj+@lWDfTeE_CK-g6H*Wocw}K`xPR}u*Qmt z+wYW*^#r;{2VEk`mcy7u>@=mzQ9wP2ow=EdGdp+LP`kfQh(YVLXN{hLnmYFOccBFULhfFv}cQ{&~m-5eU(0irMvrRg(&12fo zNnOaXH=6ulYz_$nDa}AuQvv1vu^+K*og*>x_99#3R6F_JFp#PzO$?U%?Tovi$J!Xc zWkB{>P`T!I^ibRN`7a3_#QjTCp5B&WgVX&_gUhV4U4zPEm~-M+Z;s?vA6nc-MjGnm zV8VCa&SEiWa)db4aPqLgYAVyPgpvoRb4_DFZHcK@tZJNyHy_Q|NR*siOsHmrcwlFN@< zdch{y9e#!3)7#@vzeSVQ%aoX(y`k`}}V-%AWcHSW=)zbrmT z5hcUWoNq?@GTt&KkxZ_>*53Y^f@;;b6warSO5MBDQTlFW69!f)4}Ms+4kE<@SM-z6>PB_fZZzhIjPDvx%ag-OcJ5y?!jO zCt`;X8PNrvqJm;s`bZZQl=-=u2h)bzj5~RS6u6y8lYNqtTzGrvExlhu!o z#E|S`N%i(_ix$_xojtVjr?SBgDJ7xc(o-un~Lwwd6fMhaJy z)-AQ}19j@%r}oG2?r;w2E|X#jT#QZN2qW3*TSKCO`YbYF{G~?uZ7aDp@vzUGW?KDC zqWyP86oWNx1uwRkHro&dbdweBT)kUlx5pcMF4kDV?eTGzUY0;oTcU2ch^iNXvJ9(omjdxs#zTeD^ zveDFfE&ap+Z z3UAi*i)X0b#avh(m6Slxy)wAod>F;Y6oX%nRlww04hsyW>XRP77;={TWBp>(tI4`gXg-bB^rgjT(|$D~Wp= zUUzr5@1n`zCU2^Gu?5GRFmAqg=FCxMmg{e4rmYhO^<3ya`k>nMv(F!%h<|gv@2l#7 zwdFe8pzI@v+cj4lGJ!+oRcjVhwlw zD`~C{w99%vV5{FpuW41>wI^*QxlCha4maigWk_2P1AX38Hx(+0`V1A+1DR(O7Q)(Q z`YdDBC)z}27LD(DYZNBREomASovE+rq3Ih=V|G^xp@aBA$3t_fuY6x zd-bT}(`PFB4EeWyM0jKR4qT%By5bUV6P;NuTV7zIIzoq;5>1KrJ1Z{N)}b+;Bd%+> zleuS;o{O%N{zAqeLy)Ub0nfwjMH1ziTjOE6F+oAN1{?{Z7|;d4Y!G)z4UOh9mW?nK#0A?xA{)$mfGF}mu|`JU<; z@}1WeqQ%%qCdl55FbGkiGet5}2FpU7N8fi__Zz#S;&^9La8FaKr=8#0rg+{h(TzRe zOP-P=!A8+vlbUx#_AF{aGr-crvhu|N(>o5;^yu16vdNS)bF)Z$*zO0o>0 zy?e>r9($qM7~29Ajmri`XfXqytw~vOOjYC@=Pie5SYE4RQ6yH+bM1S5Vw}w8TLPM2 zJ*QWbH7(#O%JKF?Rh>KGJRPwQN8H;cSDJb@xJTmVkX1(JVH2DeCH31o=3W|8gM)RdH=~mtAW-$#VS{5pFCS9h#*ab0*Lnk~p zbsZAtP?wB7_Tm8(CMQCX%vDBgsH=0h1}hS`v&=YXYNS7a!FHbFX{1Uw_vSe}u`^*k z^Ga$u_71w37mhWWRnjk0Qd|W?N<2I{9bcQsoGaSv*CfCD1%?-+VZIaQ*qNyFHzVuj9!%OgiOvCH~$yKx3x2+*` zD2*c%#|(W0r=9sKV=GQa-6^`H2^^6w--j#ow?f_I_}^$4vE$fjn}>oL{K(_^1B$O^ zi^OrtZP{{{PVwT1W}f1h?8@zukNUo%*_#hJZn-slJMT!+!_aL~USQ)K!L-%6Dg^Z@ z^uZ>1cLs@PG)4_8%*+QkOYHJOYr>6p%kjVEcHtPhR^^gwZohkU(49s?!Kg?5`N#vM zRuZEovLNA}Qe}2|49C><&Ors&0cUysHxs-p-l6rh12!*fVLEJnRLO=7d@S=$U z=Lb)ec9Udgu+J51cCE=8iZo(LD_gTB=GoJA0+>&!!FN@U#U;}&jGvgkv77CNi+@+- zaZ~*k%8tBY2Fz4CL*tpV?-vz|%7-!>RC2$+8q+-6d&B-z3Y}{_ zHNDd=k{QR7;V7-sk^y=*<@8AI%!e>wyrd$PBS^I*CzKtDG!rsOUwYl%y0~)CFRK24 zg}7;V*|xa}f8-^1Jle(Z3s%d4Yd>ayDl_Fe8K+0#UUkO? zjYXQCJJ>TFkaKWsG?XfM>&W$r$Xv{4w@BZG*Q677x(6Dc)$V0_P*$VpsL@;6)^$!_ z!R*WhcMD3A1}8nOs53hxn`xE8ZT4x>Q5|E{B4Wn&b^D%&C znbb_OVwSXfY@ib3?lfKOD6g!jz zR2EkfP~Z+D6=bJ-HM{RC`ONksSku5#2K_ocS}P8;rJ*=CDn_oN;kJ~roC5b*(!u3O zS+pQfmhr*6!?L)zkNYrdUb|w?eqy@E zn#_kIFf!!iiRmFlo8izGSMG9D+^{T@y(c>U<@P=kRwwc_%Gm813xV1>RxZt=Rq_s0 z_FMDPyBx;f=aDg$cqte*e2NEx8^0~Z7wNgV(3)*OA&BkgI$JByvl3P_y>jQ4=^!qz zQEh%~(E7)l-07Z~tgwCFvZsc-qHUL_#(T0;#(QrWP~-+Z)V%M_S6mP$6lFCNv^Udx z(M8&dg-8ngo4Mr)KAE|XlR=(_KiU=#r1tJSb?a+|@K6SYK<%zP%c!l@^@ZWOs%&yH z3YCkxIEJS_aflRIm6Q-fo7@0l5a3iFy)X>}jn zUNy7&*oyjKsc+K4J;K-@X$gaB6)hj@pSwSgB@<_g<@8)QEZ@dFn^-ZOu3MqqL_ak# zD-cl6b-b6gVeY%x^NR&PMkb>&Ge%?XTvEr)H{3}7ZkB8Jt+mMKWEAbBGcpSDk3dtE zCi+RiuMO`$bGbZs`B1obXHd3E{rre3-;6)&oz9h#`ggakvVKkyVRh1V8c-}MVxA?# zd>QYrS9#0jUF2U8aMJP}y1`Y&rZg!j{ItS_uOYZ?(SB1c&UP-}qVyL&J)TgtWW3E@ z7&Gp<`D}dV0dEhnA0i>&3QgO6rc@#X#(2CsZRDTeyJc% z10}QCMsX&oIXu+y^u(*YOIMSrgU>x;J|P<69#wVjgX7uxW!}WWRwWNk zNtF`PxHoyOM6_aFJnUI@a3e9w?cE)2=i+>>AidX`LpEquS;h-=q5f3*`Q0tw$S?Ok zsZOEoy-<9rB9v)B=L%&9ji<$2<=gLyPX=(}GYY3X?RFNL+%zS1&N|#`Vg0eLSd#bz z`r~uTR5HE0d(SN7a|ZM1qpFWU*BLf{6-~Z%bw{BE*}$1hk`hw|H62H)!eY^~Z@5j* zUPaJ^(8=@Xze6#3VxKPC%rO+!-4Cz}@-gJF;_IH?{)Do()SN?!T)wDw%V*M}Q-@KT zp3#lx-urr}nC;e;Pf^OJ?!VroPV`P6Lx*|!P@7aX{k7cSC11Kigzx+#NoQk?eNQMQ zm?f``MrhB)J~&R2vPDDw45uWGrcM0CmB_WgVzCqwrLt!Pl3emBT9Tvj=n*){*grgKc$KL44lmm~Vs z1uE%r(wV(gEZ-ZgUcJBm<9Gmvdky`YwB#`7*9*9$+nD5Hy3xZKW)yc0TwQt@o*k}K zDnK-1|H$|RN~lJMtVFtWpOnO0#C|TyOSnh-l5gH+1@UM?M0jg>`zc)3xzTH_7O$5I zw^lpxo#5Jk@ z_9~HYo_}2W93^FU*??*9C*{LL(+yu$=30ZrFIgAJ`jL${T@>C@JAPs3y;nJ}zJ6O%q#j%#JKUF6;-(9w*QZbp=6%*enYwC{r;-g!6_Nht(r9hAOzEg|4 zn(EIDYE&g$F!ypkjXSQkUowvavQZoEls{x-|Mu?Gc^c;jgB-X;&S{gPYfbAEXB(cgyv;9hY`jpWBz4eyj`Zd0 zd&Cl?WKLzCGAu8=+_PxRIxouVOK`Bw-*br6rEBAUdgnCmt7|%MYs=w`7?x$0MaXK(eeQ0bu8-C>4bLHiZRG$_;jAQVAL6%%=P0#dbyS(QWpO5#k zvv)_>Hw1XSBN35mwI%Mydg>^=4BYHkb?g$m`*|WA-CV9TqRS^RG2c@5UaO9!F-%DD z@KNn$e{NtQOcS+qJ%R`5;qd#{D(;R|k0?x*V(#Wd!Awy#^A8C>4(>Cn>Ze&MlU*2iTzF4=;&X}eQ2HgOlz%AY;Smw{5- zWYT+lX^YfnSB+UArIjbj1q)7(eiYi}^BInm-I0+p6t3dAHNiPCrgBc6nx?V%nhr~+ zqEAKr@fg|)6JMj$JxpxTmlG8Cy)SW1Enrl?c7F$^^6J54iSACL2GO@VcI+<>HK@lt zc_{PnNvY1=k)lVgg&BE5LpoRZ=VX^@m$l^S+0n`GKjjkha#JZ#JT&d~x+{BUuCLzl zh~MF(#_1Cdq<&x8DEm9q26R~%a)N}_2j>L$8k(Y%)c&S!Bd2NHG{)EIGk!> zX2&T?V+I4N733ZF}Rq{#c3!>C)?qwvB)ZFK`P;my=xXbLMFz3F0pI-qPi4`rr|WB zyzOBMQnDF3qLHQcViVyV`9r~s3;GHSi!#;AcW)H3Dg;M|zf9JseOW^i#+ODvA7#Mr z=oenm*YcDu`D7XAm2lkCqZckwO&MlHoWnMI4xVr;pyx#IdhNLFqGF+7q%kG$Yw3dO z-Vy%yu`85v2dm0|$gw#x@-H4!(wU>1^MArCP1H?E6~}hj0HgbHY9Yr<((;-J<|C$t zLHuc=RISl8TFiK#svO+~yY_HLUL~?Xl;~?aRyJ2Gcj*e>J|Q-?NBv_=W*4V?@>WHH zwk>a7KI%pUOto3%;rKVMDNGEd*rS$*A!P34~IY*%e&Gjp>5&l59Jj95suz7Ov6mW&;! z&kuR+@?KPQ9CtZH6sRX9SDP+j?CVP6QdV$9*U*i3XB}P9RI5ny!I9jj-w$qg4>{O* z!(T}6KzCp9iZW|tX(N=>P~akqVVLBa+a6rXiI9qpuA&9|XU2LI?ppI7>P^~Ax!g1(`B2ri zj-Q2tx5r&aOZ1ZrzQPhc+R?R--MiuVp}8L0a;`R~QhFKm9#n^;c4a$CMlCtz)DweG zK~K#t@E(>N)p70JdoR;&ODPqRSx^p}j{YY4C!M_EM^ZNRju)0lIWY1x-lJ;RV!0yB zK2Z41?C+XSd^WgFg$aRi<#?u>)HcA618GGz&E1PF99k zKC|?9ofb-+XGh0var6vZRnoO}w^(sI5O&LWwlKL_0!lmwN zmJ94T2?}}flIhf%YWMc+_pC*e^C~o7YLXy!mrgzkF48E=d_xN5?-eOJN6=5ZEwbDg zOHLD_8GAO$HvKJru=vgKe#fE?wn<*pX>{E3>TaSYm5zrJ2S3|B$98hevCmnm?^}we zl`kN2WXxRPYfrDtUero+kapentw@tP8x_#7^6oJ;JJF@VbJJnyoCOe)7FOVfb0rf8$2$ijlH8_g zitPsd?3Y{mjmK7=Z(r3e*)G+-*wlW5>e=GI2ps)!^Od(+2FzIlvmiz89WqNbL?(1|K&|0iMoE{&Qb;%oM_NV&g^RFgU;QQ40r2SP&_r{M6Nq9 zeS)xCxv4o)YFdM;3>LXBcT~xUGvZ&Z$C!g@A}n3cCUy-du|Lav{z2a zM34$*5c^}<;tEX89Jbc6%Jj(E{Dgvz?Xdm$mFRt4<(KU#hOFzKjEi#DhKpPjHNSzi zuscd+l&$;rip+~+S~d|96Kh{6baP^F_21Pq$mJ`4m;5$|R$lgKXzN)maH(~RzMoi- z|LZ%y-F}M)O{P1T8N3wFoC-lLcAGpHs(yaICt^G*sunAeyZFU__zrFNzTVW{eT)M& zp79N+sl$HO7jG}?zX{E!%5YY*e)~yVo36Wa6?}Vf{_J$>YvG*8Kw3<=uTI-t&Q}aw z9^4cwBz~rfirr-Dz4`6|jj|ki9(y&8lFG-TLR)v2CijR83g#UZ$aYD2jM36C))_aM z8Iikupubc_fW%0v6x>PqYA@ZMq0{&7ceYS8xgXP&++IF!#uV?|cI8S(n$v^I=?A2w z=;maX3=XlBi&a#6KD^$Wbv4gRkk8wJH0}iLSbp>55c0K3*QuNNd%#C1bf@KRPB^EhUTS z(jEn|fN#{V8Wf~tBy2yo?`T{xQdc15X3?i9YlWWx1&9*UIiQu2NhO7;JDy$N!CmV) zxm?k`Kyz}wNbhP8IXx{IIeI(hA2F`Dh(t7&nZ-Th`Oy+al8@zCn3?O06I|f8o05*O@!UeR#%wG_`S??dnxd zksn6Ybvs>3_$(4j?{CG>LnO}B-!mPwgUe&qzay^o`eAAb`WP<7P^_2E0RQ$+6zFWd zC&LF%L_Q92wa)7=zEO=9dQN?&_hu_ycx2k9gL1CY7Kb?{>U@7>oqw1UG)qt9rZyxg z5un+(;&;+A?7`3n>uw`c`B~jTl_2MSMI~#R)QeMX5f$gG=Ct=x*@z{~gvQ&Kgf`T2 zQ^cVj5A%?8-z8&;H0*sVbXr$};rkxq&u$ERj=!TOIqCWG_QLCj)>Gr|+#cjof(JP# zRa>Y(L`)5wlCPtSttB3(a=P2;Zl2%!?}|Z-N$fqll~{NY_B5Rmf% .v-caption, .v-app .v-gridlayout-slot > .v-caption, .v-app .v-has-caption > .v-caption, .v-app .v-formlayout-captioncell > .v-caption, .v-app .v-csslayout > .v-caption { + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; +} + +.v-app input::-ms-clear { + display: none; +} + +.v-ui { + position: relative; +} + +.v-ui.v-ui-embedded { + margin-top: -1px; + border-top: 1px solid transparent; +} + +.v-ui:focus { + outline: none; +} + +.v-overlay-container { + width: 0; + height: 0; +} + +.v-drag-element { + z-index: 60000; + position: absolute !important; + cursor: default; +} + +.v-clip { + overflow: hidden; +} + +.v-scrollable { + overflow: auto; +} + +.v-scrollable > .v-widget { + vertical-align: middle; + overflow: hidden; +} + +.v-ios.v-webkit .v-scrollable { + -webkit-overflow-scrolling: touch; +} + +.v-ios5.v-webkit .v-scrollable { + -webkit-overflow-scrolling: none; +} + +.v-webkit.v-ios .v-browserframe { + -webkit-overflow-scrolling: touch; + overflow: auto; +} + +.v-assistive-device-only { + position: absolute; + top: -2000px; + left: -2000px; + width: 10px; + overflow: hidden; +} + +.v-icon { + cursor: inherit; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.v-icon, .v-errorindicator, .v-required-field-indicator { + display: inline-block; + line-height: inherit; +} + +.v-caption { + display: inline-block; + white-space: nowrap; + line-height: 1.55; +} + +.v-captiontext { + display: inline-block; + line-height: inherit; +} + +div.v-layout.v-horizontal.v-widget { + white-space: nowrap; +} + +.v-layout.v-vertical > .v-expand, .v-layout.v-horizontal > .v-expand { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + width: 100%; + height: 100%; +} + +.v-slot, .v-spacing { + display: inline-block; + white-space: nowrap; + vertical-align: top; +} + +.v-vertical > .v-slot:after { + display: inline-block; + clear: both; + width: 0; + height: 0; + overflow: hidden; +} + +.v-vertical > .v-slot, .v-vertical > .v-expand > .v-slot { + display: block; + clear: both; +} + +.v-horizontal > .v-slot, .v-horizontal > .v-expand > .v-slot { + height: 100%; +} + +.v-horizontal > .v-expand > .v-slot { + position: relative; +} + +.v-vertical > .v-spacing, .v-vertical > .v-expand > .v-spacing { + width: 0 !important; + display: block; + clear: both; +} + +.v-horizontal > .v-spacing, .v-horizontal > .v-expand > .v-spacing { + height: 0 !important; +} + +.v-align-middle:before, .v-align-bottom:before, .v-expand > .v-align-middle:before, .v-expand > .v-align-bottom:before { + content: ""; + display: inline-block; + height: 100%; + vertical-align: middle; + width: 0; +} + +.v-align-middle, .v-align-bottom { + white-space: nowrap; +} + +.v-align-middle > .v-widget, .v-align-bottom > .v-widget { + display: inline-block; +} + +.v-align-middle, .v-align-middle > .v-widget { + vertical-align: middle; +} + +.v-align-bottom, .v-align-bottom > .v-widget { + vertical-align: bottom; +} + +.v-align-center { + text-align: center; +} + +.v-align-center > .v-widget { + margin-left: auto; + margin-right: auto; +} + +.v-align-right { + text-align: right; +} + +.v-align-right > .v-widget { + margin-left: auto; +} + +.v-has-caption, .v-has-caption > .v-caption { + display: inline-block; +} + +.v-caption-on-left, .v-caption-on-right { + white-space: nowrap; +} + +.v-caption-on-top > .v-caption, .v-caption-on-bottom > .v-caption { + display: block; +} + +.v-caption-on-left > .v-caption { + padding-right: 0.5em; +} + +.v-caption-on-left > .v-widget, .v-caption-on-right > .v-widget { + display: inline-block; +} + +.v-has-caption.v-has-width > .v-widget { + width: 100% !important; +} + +.v-has-caption.v-has-height > .v-widget { + height: 100% !important; +} + +.v-gridlayout { + position: relative; +} + +.v-gridlayout-slot { + position: absolute; + line-height: 1.55; +} + +.v-gridlayout-spacing-on { + overflow: hidden; +} + +.v-gridlayout-spacing, .v-gridlayout-spacing-off { + padding-left: 0; + padding-top: 0; +} + +.v-gridlayout-spacing-off { + overflow: hidden; +} + +.v-calendar-month-day-scrollable { + overflow-y: scroll; +} + +.v-calendar-week-wrapper { + position: relative; + overflow: hidden; +} + +.v-calendar-current-time { + position: absolute; + left: 0; + width: 100%; + height: 1px; + background: red; + z-index: 2; +} + +.v-calendar-event-resizetop, .v-calendar-event-resizebottom { + position: absolute; + height: 5%; + min-height: 3px; + width: 100%; + z-index: 1; +} + +.v-calendar-event-resizetop { + cursor: row-resize; + top: 0; +} + +.v-calendar-event-resizebottom { + cursor: row-resize; + bottom: 0; +} + +.v-calendar-header-month td:first-child { + padding-left: 20px; +} + +.v-calendar-month-sizedheight .v-calendar-month-day { + height: 100px; +} + +.v-calendar-month-sizedwidth .v-calendar-month-day { + width: 100px; +} + +.v-calendar-header-month-Hsized .v-calendar-header-day { + width: 101px; +} + +.v-calendar-header-month-Hsized td:first-child { + padding-left: 21px; +} + +.v-calendar-header-day-Hsized { + width: 200px; +} + +.v-calendar-week-numbers-Vsized .v-calendar-week-number { + height: 100px; + line-height: 100px; +} + +.v-calendar-week-wrapper-Vsized { + height: 400px; + overflow-x: hidden !important; +} + +.v-calendar-times-Vsized .v-calendar-time { + height: 38px; +} + +.v-calendar-times-Hsized .v-calendar-time { + width: 42px; +} + +.v-calendar-day-times-Vsized .v-datecellslot, .v-calendar-day-times-Vsized .v-datecellslot-even { + height: 18px; +} + +.v-calendar-day-times-Hsized, .v-calendar-day-times-Hsized .v-datecellslot, .v-calendar-day-times-Hsized .v-datecellslot-even { + width: 200px; +} + +.v-colorpicker-popup.v-window { + min-width: 220px !important; +} + +.v-colorpicker-gradient-container { + overflow: visible !important; +} + +.v-colorpicker-gradient-clicklayer { + opacity: 0; + filter: alpha(opacity=0) ; +} + +.rgb-gradient .v-colorpicker-gradient-background { + background: url(../valo/components/img/colorpicker/gradient2.png); +} + +.hsv-gradient .v-colorpicker-gradient-foreground { + background: url(../valo/components/img/colorpicker/gradient.png); +} + +.v-colorpicker-gradient-higherbox:before { + content: ""; + width: 11px; + height: 11px; + border-radius: 7px; + border: 1px solid #fff; + -webkit-box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), inset 0 0 0 1px rgba(0, 0, 0, 0.3); + box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), inset 0 0 0 1px rgba(0, 0, 0, 0.3); + position: absolute; + bottom: -6px; + left: -6px; +} + +.v-colorpicker-popup .v-slider.v-slider-red:before { + background-color: red; +} + +.v-colorpicker-popup .v-slider.v-slider-green:before { + background-color: green; +} + +.v-colorpicker-popup .v-slider.v-slider-blue:before { + background-color: blue; +} + +.v-colorpicker-popup .v-slider.hue-slider:before { + background: url(../valo/components/img/colorpicker/slider_hue_bg.png); +} + +.v-colorpicker-popup input.v-textfield-dark { + color: #fff; +} + +.v-colorpicker-popup input.v-textfield-light { + color: #000; +} + +.v-colorpicker-grid { + height: 319px; +} + +.v-colorpicker-popup .colorselect td { + line-height: 15px; +} + +.v-table-header table, .v-table-footer table, .v-table-table { + border-spacing: 0; + border-collapse: separate; + margin: 0; + padding: 0; + border: 0; + line-height: 1.55; +} + +.v-table-resizer, .v-table-sort-indicator { + float: right; +} + +.v-table-caption-container-align-center { + text-align: center; +} + +.v-table-caption-container-align-right { + text-align: right; +} + +.v-table-header td, .v-table-footer td, .v-table-cell-content { + padding: 0; +} + +.v-table-sort-indicator { + width: 0; +} + +.v-tabsheet-hidetabs > .v-tabsheet-tabcontainer, .v-tabsheet-spacertd, .v-disabled .v-tabsheet-scroller, .v-tabsheet .v-disabled .v-tabsheet-caption-close { + display: none; +} + +.v-tabsheet { + overflow: visible !important; + position: relative; +} + +.v-tabsheet-tabcontainer table, .v-tabsheet-tabcontainer tbody, .v-tabsheet-tabcontainer tr { + display: inline-block; + border-spacing: 0; + border-collapse: collapse; + vertical-align: top; +} + +.v-tabsheet-tabcontainer td { + display: inline-block; + padding: 0; +} + +.v-tabsheet-tabs { + white-space: nowrap; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +.v-tabsheet-content { + position: relative; +} + +.v-tabsheet-content > div > .v-scrollable > .v-margin-top { + padding-top: 12px; +} + +.v-tabsheet-content > div > .v-scrollable > .v-margin-right { + padding-right: 12px; +} + +.v-tabsheet-content > div > .v-scrollable > .v-margin-bottom { + padding-bottom: 12px; +} + +.v-tabsheet-content > div > .v-scrollable > .v-margin-left { + padding-left: 12px; +} + +.v-splitpanel-vertical, .v-splitpanel-horizontal { + overflow: hidden; + white-space: nowrap; +} + +.v-splitpanel-hsplitter { + z-index: 100; + cursor: e-resize; + cursor: col-resize; +} + +.v-splitpanel-vsplitter { + z-index: 100; + cursor: s-resize; + cursor: row-resize; +} + +.v-splitpanel-hsplitter:after, .v-splitpanel-vsplitter:after { + content: ""; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; +} + +.v-splitpanel-hsplitter div, .v-splitpanel-vsplitter div { + width: inherit; + height: inherit; + overflow: hidden; + position: relative; +} + +.v-splitpanel-hsplitter div:before, .v-splitpanel-vsplitter div:before { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + content: ""; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; +} + +.v-disabled [class$="splitter"] div { + cursor: default; +} + +.v-disabled [class$="splitter"] div:before { + display: none; +} + +.v-splitpanel-horizontal > div > .v-splitpanel-second-container { + position: static !important; + display: inline-block; + vertical-align: top; +} + +.v-splitpanel-horizontal > div > .v-splitpanel-first-container { + display: inline-block; + vertical-align: top; +} + +.mytheme.v-app, .mytheme.v-app-loading { + font: 300 16px/1.55 "Open Sans", sans-serif; + color: #464646; + background-color: #fafafa; + cursor: default; +} + +.mytheme .v-app-loading { + width: 100%; + height: 100%; + background: #fafafa; +} + +.mytheme .v-app-loading:before { + content: ""; + position: fixed; + z-index: 100; + top: 45%; + left: 50%; + width: 28px; + height: 28px; + padding: 9px; + margin-top: -24px; + margin-left: -24px; + background: #fff url(../valo/shared/img/spinner.gif) no-repeat 50%; + border-radius: 4px; +} + +.mytheme .v-loading-indicator { + position: fixed !important; + z-index: 99999; + left: 0; + right: auto; + top: 0; + width: 50%; + opacity: 1; + height: 4px; + background-color: #197de1; + pointer-events: none; + -webkit-transition: none; + -moz-transition: none; + transition: none; + -webkit-animation: v-progress-start 1000ms 200ms both; + -moz-animation: v-progress-start 1000ms 200ms both; + animation: v-progress-start 1000ms 200ms both; +} + +.mytheme .v-loading-indicator[style*="none"] { + display: block !important; + width: 100% !important; + opacity: 0; + -webkit-animation: none; + -moz-animation: none; + animation: none; + -webkit-transition: opacity 500ms 300ms, width 300ms; + -moz-transition: opacity 500ms 300ms, width 300ms; + transition: opacity 500ms 300ms, width 300ms; +} + +.mytheme .v-loading-indicator-delay { + width: 90%; + -webkit-animation: v-progress-delay 3.8s forwards; + -moz-animation: v-progress-delay 3.8s forwards; + animation: v-progress-delay 3.8s forwards; +} + +.v-ff .mytheme .v-loading-indicator-delay { + width: 50%; +} + +.mytheme .v-loading-indicator-wait { + width: 96%; + -webkit-animation: v-progress-wait 5s forwards, v-progress-wait-pulse 1s 4s infinite backwards; + -moz-animation: v-progress-wait 5s forwards, v-progress-wait-pulse 1s 4s infinite backwards; + animation: v-progress-wait 5s forwards, v-progress-wait-pulse 1s 4s infinite backwards; +} + +.v-ff .mytheme .v-loading-indicator-wait { + width: 90%; +} + +.v-ie8 .mytheme .v-loading-indicator, .v-ie8 .mytheme .v-loading-indicator-delay, .v-ie8 .mytheme .v-loading-indicator-wait, .v-ie9 .mytheme .v-loading-indicator, .v-ie9 .mytheme .v-loading-indicator-delay, .v-ie9 .mytheme .v-loading-indicator-wait { + width: 28px !important; + height: 28px; + padding: 9px; + background: #fff url(../valo/shared/img/spinner.gif) no-repeat 50%; + border-radius: 4px; + top: 9px; + right: 9px; + left: auto; + filter: alpha(opacity=50); +} + +.v-ie8 .mytheme .v-loading-indicator[style*="none"], .v-ie8 .mytheme .v-loading-indicator-delay[style*="none"], .v-ie8 .mytheme .v-loading-indicator-wait[style*="none"], .v-ie9 .mytheme .v-loading-indicator[style*="none"], .v-ie9 .mytheme .v-loading-indicator-delay[style*="none"], .v-ie9 .mytheme .v-loading-indicator-wait[style*="none"] { + display: none !important; +} + +.v-ie8 .mytheme .v-loading-indicator-wait, .v-ie9 .mytheme .v-loading-indicator-wait { + filter: alpha(opacity=100); +} + +.mytheme .v-scrollable:focus { + outline: none; +} + +.mytheme img.v-icon { + vertical-align: middle; +} + +.mytheme .v-caption { + font-size: 14px; + font-weight: 400; + padding-bottom: 0.3em; + padding-left: 1px; +} + +.mytheme .v-caption-on-left .v-caption, .mytheme .v-caption-on-right .v-caption { + padding-top: 0; + padding-bottom: 0; +} + +.mytheme .v-icon + .v-captiontext, .mytheme .v-icon + span { + margin-left: 7px; +} + +.mytheme .v-icon + .v-captiontext:empty, .mytheme .v-icon + span:empty { + margin-left: 0; +} + +.mytheme .v-errorindicator { + color: #ed473b; + font-weight: 600; + width: 19px; + text-align: center; +} + +.mytheme .v-errorindicator:before { + content: "!"; +} + +.mytheme .v-required-field-indicator { + color: #ed473b; + padding: 0 0.2em; +} + +.mytheme select { + font: inherit; + font-weight: 400; + line-height: inherit; + padding: 5px; + margin: 0; + border-radius: 4px; + border: 1px solid #c5c5c5; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + color: #464646; +} + +.mytheme select:focus { + outline: none; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); +} + +.mytheme button { + font: inherit; + font-weight: 400; + line-height: 1.55; +} + +.mytheme a { + cursor: pointer; + color: #197de1; + text-decoration: underline; + font-weight: inherit; + -webkit-transition: color 140ms; + -moz-transition: color 140ms; + transition: color 140ms; +} + +.mytheme a:hover { + color: #4396ea; +} + +.mytheme a.v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-disabled { + cursor: default !important; +} + +.mytheme .v-drag-element { + background: #fafafa; + color: #464646; + -webkit-box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2); + box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2); + border-radius: 4px; + overflow: hidden; + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-tooltip { + background-color: #323232; + background-color: rgba(50, 50, 50, 0.9); + -webkit-box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2); + box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2); + color: white; + padding: 5px 9px; + border-radius: 3px; + max-width: 35em; + overflow: hidden !important; + font-size: 14px; +} + +.mytheme .v-tooltip div[style*="width"] { + width: auto !important; +} + +.mytheme .v-tooltip .v-errormessage { + background-color: white; + background-color: #fff; + color: #ed473b; + margin: -5px -9px; + padding: 5px 9px; + max-height: 10em; + overflow: auto; + font-weight: 400; +} + +.mytheme .v-tooltip .v-errormessage h2:only-child { + font: inherit; + line-height: inherit; +} + +.mytheme .v-tooltip .v-tooltip-text { + max-height: 10em; + overflow: auto; + margin-top: 10px; +} + +.mytheme .v-tooltip .v-errormessage[aria-hidden="true"] + .v-tooltip-text { + margin-top: 0; +} + +.mytheme .v-tooltip h1, .mytheme .v-tooltip h2, .mytheme .v-tooltip h3, .mytheme .v-tooltip h4 { + color: inherit; +} + +.mytheme .v-contextmenu { + padding: 4px 4px; + border-radius: 4px; + background-color: white; + color: #474747; + -webkit-box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.1), 0 3px 5px 0 rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.09098); + box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.1), 0 3px 5px 0 rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.09098); + -webkit-backface-visibility: hidden; + -moz-backface-visibility: hidden; + -ms-backface-visibility: hidden; + backface-visibility: hidden; + padding: 4px 4px; +} + +.mytheme .v-contextmenu[class*="animate-in"] { + -webkit-animation: valo-overlay-animate-in 120ms; + -moz-animation: valo-overlay-animate-in 120ms; + animation: valo-overlay-animate-in 120ms; +} + +.mytheme .v-contextmenu[class*="animate-out"] { + -webkit-animation: valo-animate-out-fade 120ms; + -moz-animation: valo-animate-out-fade 120ms; + animation: valo-animate-out-fade 120ms; +} + +.mytheme .v-contextmenu table { + border-spacing: 0; +} + +.mytheme .v-contextmenu .gwt-MenuItem { + cursor: pointer; + line-height: 27px; + padding: 0 20px 0 10px; + border-radius: 3px; + font-weight: 400; + white-space: nowrap; + position: relative; + display: block; +} + +.mytheme .v-contextmenu .gwt-MenuItem:active:before { + content: ""; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + background: #0957a6; + opacity: 0.15; + filter: alpha(opacity=15.0) ; + pointer-events: none; + border-radius: inherit; +} + +.mytheme .v-contextmenu .gwt-MenuItem .v-icon { + max-height: 27px; + margin-right: 5px; + min-width: 1em; +} + +.mytheme .v-contextmenu .gwt-MenuItem-selected { + background-color: #197de1; + background-image: -webkit-linear-gradient(top, #1b87e3 2%, #166ed5 98%); + background-image: linear-gradient(to bottom,#1b87e3 2%, #166ed5 98%); + color: #ecf2f8; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.05); +} + +.mytheme .v-reconnect-dialog { + color: white; + top: 12px; + right: 12px; + max-width: 100%; + border-radius: 0; + -webkit-box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); + box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); + padding: 12px 15px; + background-color: #444; + background-color: rgba(68, 68, 68, 0.9); + line-height: 22px; + text-align: center; +} + +.mytheme .v-reconnect-dialog .text { + display: inline-block; + padding-left: 10px; +} + +.mytheme .v-reconnect-dialog .spinner { + height: 24px !important; + width: 24px !important; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + border: 2px solid rgba(25, 125, 225, 0.2); + border-top-color: #197de1; + border-right-color: #197de1; + border-radius: 100%; + -webkit-animation: v-rotate-360 500ms infinite linear; + -moz-animation: v-rotate-360 500ms infinite linear; + animation: v-rotate-360 500ms infinite linear; + pointer-events: none; + display: none; + vertical-align: middle; +} + +.v-ie8 .mytheme .v-reconnect-dialog .spinner, .v-ie9 .mytheme .v-reconnect-dialog .spinner { + border: none; + border-radius: 4px; + background: #fff url(../valo/shared/img/spinner.gif) no-repeat 50% 50%; + background-size: 80%; +} + +.v-ie8 .mytheme .v-reconnect-dialog .spinner { + min-width: 30px; + min-height: 30px; +} + +.mytheme .v-reconnect-dialog.active .spinner { + display: inline-block; +} + +.mytheme .v-absolutelayout-wrapper { + position: absolute; +} + +.mytheme .v-absolutelayout-margin, .mytheme .v-absolutelayout-canvas { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +.mytheme .v-absolutelayout.v-has-height > div, .mytheme .v-absolutelayout.v-has-height .v-absolutelayout-margin { + height: 100%; +} + +.mytheme .v-absolutelayout.v-has-height > div, .mytheme .v-absolutelayout.v-has-width .v-absolutelayout-margin { + width: 100%; +} + +.mytheme .v-margin-top { + padding-top: 37px; +} + +.mytheme .v-margin-right { + padding-right: 37px; +} + +.mytheme .v-margin-bottom { + padding-bottom: 37px; +} + +.mytheme .v-margin-left { + padding-left: 37px; +} + +.mytheme .v-spacing { + width: 12px; + height: 12px; +} + +.mytheme .v-verticallayout-well, .mytheme .v-horizontallayout-well { + background: #f5f5f5; + color: #454545; + -webkit-box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.05), inset 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.05), inset 0 2px 3px rgba(0, 0, 0, 0.05); + border-radius: 4px; + border: 1px solid #c5c5c5; +} + +.mytheme .v-verticallayout-well > div > [class*="-caption"], .mytheme .v-horizontallayout-well > div > [class*="-caption"] { + background: transparent; + -webkit-box-shadow: none; + box-shadow: none; +} + +.mytheme .v-verticallayout-well > .v-margin-top, .mytheme .v-horizontallayout-well > .v-margin-top { + padding-top: 12px; +} + +.mytheme .v-verticallayout-well > .v-margin-right, .mytheme .v-horizontallayout-well > .v-margin-right { + padding-right: 12px; +} + +.mytheme .v-verticallayout-well > .v-margin-bottom, .mytheme .v-horizontallayout-well > .v-margin-bottom { + padding-bottom: 12px; +} + +.mytheme .v-verticallayout-well > .v-margin-left, .mytheme .v-horizontallayout-well > .v-margin-left { + padding-left: 12px; +} + +.mytheme .v-verticallayout-card, .mytheme .v-horizontallayout-card { + background: white; + color: #474747; + border-radius: 4px; + border: 1px solid #d5d5d5; + -webkit-box-shadow: 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: 0 2px 3px rgba(0, 0, 0, 0.05); +} + +.mytheme .v-verticallayout-card > .v-margin-top, .mytheme .v-horizontallayout-card > .v-margin-top { + padding-top: 12px; +} + +.mytheme .v-verticallayout-card > .v-margin-right, .mytheme .v-horizontallayout-card > .v-margin-right { + padding-right: 12px; +} + +.mytheme .v-verticallayout-card > .v-margin-bottom, .mytheme .v-horizontallayout-card > .v-margin-bottom { + padding-bottom: 12px; +} + +.mytheme .v-verticallayout-card > .v-margin-left, .mytheme .v-horizontallayout-card > .v-margin-left { + padding-left: 12px; +} + +.mytheme .v-horizontallayout-wrapping { + white-space: normal !important; +} + +.mytheme .v-horizontallayout-wrapping > .v-spacing + .v-slot, .mytheme .v-horizontallayout-wrapping > .v-slot:first-child { + margin-bottom: 12px; +} + +.mytheme .v-horizontallayout-wrapping > .v-slot:first-child:last-child { + margin-bottom: 0; +} + +.mytheme .v-button { + position: relative; + text-align: center; + white-space: nowrap; + outline: none; + -webkit-tap-highlight-color: transparent; + -webkit-touch-callout: none; + cursor: pointer; + height: 37px; + padding: 0 16px; + color: #191919; + font-weight: 400; + + + border-radius: 4px; + border: 1px solid #c5c5c5; + border-top-color: #c5c5c5; + border-bottom-color: #bcbcbc; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + -webkit-box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.05); +} + +.mytheme .v-button:before { + content: ""; + display: inline-block; + width: 0; + height: 100%; + vertical-align: middle; +} + +.mytheme .v-button > div { + vertical-align: middle; +} + +.v-sa .mytheme .v-button:before { + height: 110%; +} + +.v-ff .mytheme .v-button:before { + height: 107%; +} + +.v-ie .mytheme .v-button:before { + margin-top: 4px; +} + +.mytheme .v-button:after { + content: ""; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + border-radius: inherit; + -webkit-transition: box-shadow 180ms, border 180ms; + -moz-transition: box-shadow 180ms, border 180ms; + transition: box-shadow 180ms, border 180ms; +} + +.mytheme .v-button:focus:after { + -webkit-transition: none; + -moz-transition: none; + transition: none; +} + +.mytheme .v-button.v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-button.v-disabled:after { + display: none; +} + +.mytheme .v-button:after { + border: inherit; + top: -1px; + right: -1px; + bottom: -1px; + left: -1px; +} + +.mytheme .v-button:hover:after { + background-color: rgba(186, 186, 186, 0.1); +} + +.mytheme .v-button:focus:after { + border-color: #197de1; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); +} + +.mytheme .v-button:active:after { + background-color: rgba(125, 125, 125, 0.2); +} + +.mytheme .v-button-primary { + height: 37px; + padding: 0 16px; + color: #ecf2f8; + font-weight: 400; + + + border-radius: 4px; + border: 1px solid #1362b1; + border-top-color: #156ab3; + border-bottom-color: #1156a8; + background-color: #197de1; + background-image: -webkit-linear-gradient(top, #1b87e3 2%, #166ed5 98%); + background-image: linear-gradient(to bottom,#1b87e3 2%, #166ed5 98%); + -webkit-box-shadow: inset 0 1px 0 #4d98e6, inset 0 -1px 0 #166bca, 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 1px 0 #4d98e6, inset 0 -1px 0 #166bca, 0 2px 3px rgba(0, 0, 0, 0.05); + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.05); + padding: 0 19px; + font-weight: bold; + min-width: 81px; +} + +.mytheme .v-button-primary:after { + border: inherit; + top: -1px; + right: -1px; + bottom: -1px; + left: -1px; +} + +.mytheme .v-button-primary:hover:after { + background-color: rgba(90, 163, 237, 0.1); +} + +.mytheme .v-button-primary:focus:after { + border: inherit; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); +} + +.mytheme .v-button-primary:active:after { + background-color: rgba(2, 62, 122, 0.2); +} + +.v-ie8 .mytheme .v-button-primary { + min-width: 43px; +} + +.mytheme .v-button-friendly { + height: 37px; + padding: 0 16px; + color: #eaf4e9; + font-weight: 400; + + + border-radius: 4px; + border: 1px solid #227719; + border-top-color: #257d1a; + border-bottom-color: #1e6b15; + background-color: #2c9720; + background-image: -webkit-linear-gradient(top, #2f9f22 2%, #26881b 98%); + background-image: linear-gradient(to bottom,#2f9f22 2%, #26881b 98%); + -webkit-box-shadow: inset 0 1px 0 #46b33a, inset 0 -1px 0 #26811b, 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 1px 0 #46b33a, inset 0 -1px 0 #26811b, 0 2px 3px rgba(0, 0, 0, 0.05); + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.05); +} + +.mytheme .v-button-friendly:after { + border: inherit; + top: -1px; + right: -1px; + bottom: -1px; + left: -1px; +} + +.mytheme .v-button-friendly:hover:after { + background-color: rgba(65, 211, 48, 0.1); +} + +.mytheme .v-button-friendly:focus:after { + border: inherit; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); +} + +.mytheme .v-button-friendly:active:after { + background-color: rgba(14, 86, 6, 0.2); +} + +.mytheme .v-button-danger { + height: 37px; + padding: 0 16px; + color: #f9f0ef; + font-weight: 400; + + + border-radius: 4px; + border: 1px solid #bb382e; + border-top-color: #bc3c31; + border-bottom-color: #b13028; + background-color: #ed473b; + background-image: -webkit-linear-gradient(top, #ee4c3f 2%, #e13e33 98%); + background-image: linear-gradient(to bottom,#ee4c3f 2%, #e13e33 98%); + -webkit-box-shadow: inset 0 1px 0 #ef786f, inset 0 -1px 0 #da3c31, 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 1px 0 #ef786f, inset 0 -1px 0 #da3c31, 0 2px 3px rgba(0, 0, 0, 0.05); + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.05); +} + +.mytheme .v-button-danger:after { + border: inherit; + top: -1px; + right: -1px; + bottom: -1px; + left: -1px; +} + +.mytheme .v-button-danger:hover:after { + background-color: rgba(243, 137, 129, 0.1); +} + +.mytheme .v-button-danger:focus:after { + border: inherit; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); +} + +.mytheme .v-button-danger:active:after { + background-color: rgba(146, 12, 2, 0.2); +} + +.mytheme .v-button-borderless { + border: none; + -webkit-box-shadow: none; + box-shadow: none; + background: transparent; + color: inherit; +} + +.mytheme .v-button-borderless:hover:after { + background: transparent; +} + +.mytheme .v-button-borderless:active { + opacity: 0.7; + filter: alpha(opacity=70) ; +} + +.mytheme .v-button-borderless:active:after { + background: transparent; +} + +.mytheme .v-button-borderless-colored { + border: none; + -webkit-box-shadow: none; + box-shadow: none; + background: transparent; + color: #197de1; +} + +.mytheme .v-button-borderless-colored:hover { + color: #4396ea; +} + +.mytheme .v-button-borderless-colored:hover:after { + background: transparent; +} + +.mytheme .v-button-borderless-colored:active { + opacity: 0.7; + filter: alpha(opacity=70) ; +} + +.mytheme .v-button-borderless-colored:active:after { + background: transparent; +} + +.mytheme .v-button-quiet { + visibility: hidden; +} + +.mytheme .v-button-quiet:focus, .mytheme .v-button-quiet:hover { + visibility: visible; +} + +.mytheme .v-button-quiet [class*="wrap"] { + visibility: visible; +} + +.mytheme .v-button-quiet [class*="caption"] { + display: inline-block; +} + +.mytheme .v-button-link { + border: none; + -webkit-box-shadow: none; + box-shadow: none; + background: transparent; + color: inherit; + cursor: pointer; + color: #197de1; + text-decoration: underline; + font-weight: inherit; + -webkit-transition: color 140ms; + -moz-transition: color 140ms; + transition: color 140ms; +} + +.mytheme .v-button-link:hover:after { + background: transparent; +} + +.mytheme .v-button-link:active { + opacity: 0.7; + filter: alpha(opacity=70) ; +} + +.mytheme .v-button-link:active:after { + background: transparent; +} + +.mytheme .v-button-link:hover { + color: #4396ea; +} + +.mytheme .v-button-link.v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-button-tiny { + height: 28px; + padding: 0 13px; + + + font-size: 12px; + + border-radius: 4px; +} + +.mytheme .v-button-tiny:after { + border: inherit; + top: -1px; + right: -1px; + bottom: -1px; + left: -1px; +} + +.mytheme .v-button-small { + height: 31px; + padding: 0 14px; + + + font-size: 14px; + + border-radius: 4px; +} + +.mytheme .v-button-small:after { + border: inherit; + top: -1px; + right: -1px; + bottom: -1px; + left: -1px; +} + +.mytheme .v-button-large { + height: 44px; + padding: 0 19px; + + + font-size: 20px; + + border-radius: 4px; +} + +.mytheme .v-button-large:after { + border: inherit; + top: -1px; + right: -1px; + bottom: -1px; + left: -1px; +} + +.mytheme .v-button-huge { + height: 59px; + padding: 0 26px; + + + font-size: 26px; + + border-radius: 4px; +} + +.mytheme .v-button-huge:after { + border: inherit; + top: -1px; + right: -1px; + bottom: -1px; + left: -1px; +} + +.mytheme .v-button-icon-align-right [class*="wrap"] { + display: inline-block; +} + +.mytheme .v-button-icon-align-right .v-icon { + float: right; + margin-left: 13px; +} + +.mytheme .v-button-icon-align-right .v-icon + span:not(:empty) { + margin-left: 0; +} + +.mytheme .v-button-icon-align-top { + height: auto; + padding-top: 5px; + padding-bottom: 5px; +} + +.mytheme .v-button-icon-align-top [class*="wrap"] { + display: inline-block; +} + +.mytheme .v-button-icon-align-top .v-icon { + display: block; + margin-left: auto; + margin-right: auto; +} + +.mytheme .v-button-icon-align-top .v-icon + span:not(:empty) { + margin-top: 7px; + margin-left: 0; +} + +.mytheme .v-button-icon-only { + width: 37px; + padding: 0; +} + +.mytheme .v-button-icon-only.v-button-tiny { + width: 28px; +} + +.mytheme .v-button-icon-only.v-button-small { + width: 31px; +} + +.mytheme .v-button-icon-only.v-button-large { + width: 44px; +} + +.mytheme .v-button-icon-only.v-button-huge { + width: 59px; +} + +.mytheme .v-button-icon-only .v-button-caption { + display: none; +} + +.mytheme .v-checkbox { + position: relative; + line-height: 19px; + white-space: nowrap; +} + +.mytheme .v-checkbox.v-has-width label { + white-space: normal; +} + +:root .mytheme .v-checkbox { + padding-left: 25px; +} + +:root .mytheme .v-checkbox label { + -webkit-tap-highlight-color: transparent; + -webkit-touch-callout: none; + cursor: pointer; + display: inline-block; +} + +:root .mytheme .v-checkbox > input { + position: absolute; + clip: rect(0, 0, 0, 0); + left: 0.2em; + top: 0.2em; + z-index: 0; + margin: 0; +} + +:root .mytheme .v-checkbox > input:focus ~ label:before { + border-color: #197de1; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); +} + +:root .mytheme .v-checkbox > input ~ label:before, :root .mytheme .v-checkbox > input ~ label:after { + content: ""; + display: inline-block; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + width: 19px; + height: 19px; + position: absolute; + top: 0; + left: 0; + border-radius: 4px; + font-size: 13px; + text-align: center; +} + +:root .mytheme .v-checkbox > input ~ label:before { + height: 18.5px; + padding: 0 9px; + color: #191919; + font-weight: 400; + + + border-radius: 4px; + border: 1px solid #c5c5c5; + border-top-color: #c5c5c5; + border-bottom-color: #bcbcbc; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + -webkit-box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.05); + padding: 0; + height: 19px; +} + +:root .mytheme .v-checkbox > input ~ label:after { + content: "\f00c"; + font-family: ThemeIcons; + color: transparent; + -webkit-transition: color 100ms; + -moz-transition: color 100ms; + transition: color 100ms; +} + +:root .mytheme .v-checkbox > input:active ~ label:after { + background-color: rgba(125, 125, 125, 0.2); +} + +:root .mytheme .v-checkbox > input:checked ~ label:after { + color: #197de1; +} + +.mytheme .v-checkbox > .v-icon, .mytheme .v-checkbox > label .v-icon { + margin: 0 6px 0 3px; + min-width: 1em; + cursor: pointer; +} + +.mytheme .v-checkbox.v-disabled > label, .mytheme .v-checkbox.v-disabled > .v-icon { + cursor: default; + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-checkbox.v-disabled > label > .v-icon { + cursor: default; +} + +:root .mytheme .v-checkbox.v-disabled > input:active ~ label:after { + background: transparent; +} + +.mytheme .v-checkbox.v-readonly > label, .mytheme .v-checkbox.v-readonly > .v-icon { + cursor: default; +} + +.mytheme .v-checkbox.v-readonly > label > .v-icon { + cursor: default; +} + +:root .mytheme .v-checkbox.v-readonly > input:active ~ label:after { + background: transparent; +} + +:root .mytheme .v-checkbox.v-readonly > input ~ label:after { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-checkbox-small { + position: relative; + line-height: 16px; + white-space: nowrap; + font-size: 14px; +} + +.mytheme .v-checkbox-small.v-has-width label { + white-space: normal; +} + +:root .mytheme .v-checkbox-small { + padding-left: 21px; +} + +:root .mytheme .v-checkbox-small label { + -webkit-tap-highlight-color: transparent; + -webkit-touch-callout: none; + cursor: pointer; + display: inline-block; +} + +:root .mytheme .v-checkbox-small > input { + position: absolute; + clip: rect(0, 0, 0, 0); + left: 0.2em; + top: 0.2em; + z-index: 0; + margin: 0; +} + +:root .mytheme .v-checkbox-small > input:focus ~ label:before { + border-color: #197de1; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); +} + +:root .mytheme .v-checkbox-small > input ~ label:before, :root .mytheme .v-checkbox-small > input ~ label:after { + content: ""; + display: inline-block; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + width: 16px; + height: 16px; + position: absolute; + top: 0; + left: 0; + border-radius: 4px; + font-size: 11px; + text-align: center; +} + +:root .mytheme .v-checkbox-small > input ~ label:before { + height: 15.5px; + padding: 0 7px; + color: #191919; + font-weight: 400; + + + border-radius: 4px; + border: 1px solid #c5c5c5; + border-top-color: #c5c5c5; + border-bottom-color: #bcbcbc; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + -webkit-box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.05); + padding: 0; + height: 16px; +} + +:root .mytheme .v-checkbox-small > input ~ label:after { + content: "\f00c"; + font-family: ThemeIcons; + color: transparent; + -webkit-transition: color 100ms; + -moz-transition: color 100ms; + transition: color 100ms; +} + +:root .mytheme .v-checkbox-small > input:active ~ label:after { + background-color: rgba(125, 125, 125, 0.2); +} + +:root .mytheme .v-checkbox-small > input:checked ~ label:after { + color: #197de1; +} + +.mytheme .v-checkbox-small > .v-icon, .mytheme .v-checkbox-small > label .v-icon { + margin: 0 5px 0 3px; + min-width: 1em; + cursor: pointer; +} + +.mytheme .v-checkbox-small.v-disabled > label, .mytheme .v-checkbox-small.v-disabled > .v-icon { + cursor: default; + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-checkbox-small.v-disabled > label > .v-icon { + cursor: default; +} + +:root .mytheme .v-checkbox-small.v-disabled > input:active ~ label:after { + background: transparent; +} + +.mytheme .v-checkbox-small.v-readonly > label, .mytheme .v-checkbox-small.v-readonly > .v-icon { + cursor: default; +} + +.mytheme .v-checkbox-small.v-readonly > label > .v-icon { + cursor: default; +} + +:root .mytheme .v-checkbox-small.v-readonly > input:active ~ label:after { + background: transparent; +} + +:root .mytheme .v-checkbox-small.v-readonly > input ~ label:after { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-checkbox-large { + position: relative; + line-height: 22px; + white-space: nowrap; + font-size: 20px; +} + +.mytheme .v-checkbox-large.v-has-width label { + white-space: normal; +} + +:root .mytheme .v-checkbox-large { + padding-left: 29px; +} + +:root .mytheme .v-checkbox-large label { + -webkit-tap-highlight-color: transparent; + -webkit-touch-callout: none; + cursor: pointer; + display: inline-block; +} + +:root .mytheme .v-checkbox-large > input { + position: absolute; + clip: rect(0, 0, 0, 0); + left: 0.2em; + top: 0.2em; + z-index: 0; + margin: 0; +} + +:root .mytheme .v-checkbox-large > input:focus ~ label:before { + border-color: #197de1; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); +} + +:root .mytheme .v-checkbox-large > input ~ label:before, :root .mytheme .v-checkbox-large > input ~ label:after { + content: ""; + display: inline-block; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + width: 22px; + height: 22px; + position: absolute; + top: 0; + left: 0; + border-radius: 4px; + font-size: 15px; + text-align: center; +} + +:root .mytheme .v-checkbox-large > input ~ label:before { + height: 22px; + padding: 0 10px; + color: #191919; + font-weight: 400; + + + border-radius: 4px; + border: 1px solid #c5c5c5; + border-top-color: #c5c5c5; + border-bottom-color: #bcbcbc; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + -webkit-box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.05); + padding: 0; + height: 22px; +} + +:root .mytheme .v-checkbox-large > input ~ label:after { + content: "\f00c"; + font-family: ThemeIcons; + color: transparent; + -webkit-transition: color 100ms; + -moz-transition: color 100ms; + transition: color 100ms; +} + +:root .mytheme .v-checkbox-large > input:active ~ label:after { + background-color: rgba(125, 125, 125, 0.2); +} + +:root .mytheme .v-checkbox-large > input:checked ~ label:after { + color: #197de1; +} + +.mytheme .v-checkbox-large > .v-icon, .mytheme .v-checkbox-large > label .v-icon { + margin: 0 7px 0 4px; + min-width: 1em; + cursor: pointer; +} + +.mytheme .v-checkbox-large.v-disabled > label, .mytheme .v-checkbox-large.v-disabled > .v-icon { + cursor: default; + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-checkbox-large.v-disabled > label > .v-icon { + cursor: default; +} + +:root .mytheme .v-checkbox-large.v-disabled > input:active ~ label:after { + background: transparent; +} + +.mytheme .v-checkbox-large.v-readonly > label, .mytheme .v-checkbox-large.v-readonly > .v-icon { + cursor: default; +} + +.mytheme .v-checkbox-large.v-readonly > label > .v-icon { + cursor: default; +} + +:root .mytheme .v-checkbox-large.v-readonly > input:active ~ label:after { + background: transparent; +} + +:root .mytheme .v-checkbox-large.v-readonly > input ~ label:after { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-filterselect { + position: relative; + width: 185px; + height: 37px; + border-radius: 4px; + white-space: nowrap; +} + +.mytheme .v-filterselect [class*="input"] { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; + margin: 0; + font: inherit; + + font-weight: 400; + line-height: normal; + height: 37px; + border-radius: 4px; + padding: 4px 9px; + border: 1px solid #c5c5c5; + background: white; + color: #474747; + -webkit-box-shadow: inset 0 1px 0 #f7f7f7, 0 1px 0 rgba(255, 255, 255, 0.1); + box-shadow: inset 0 1px 0 #f7f7f7, 0 1px 0 rgba(255, 255, 255, 0.1); + -webkit-transition: box-shadow 180ms, border 180ms; + -moz-transition: box-shadow 180ms, border 180ms; + transition: box-shadow 180ms, border 180ms; + width: 100% !important; + height: 100%; + padding-right: 38px; + border-radius: inherit; +} + +.v-ie8 .mytheme .v-filterselect [class*="input"], .v-ie9 .mytheme .v-filterselect [class*="input"] { + line-height: 37px; + padding-top: 0; + padding-bottom: 0; +} + +.mytheme .v-filterselect [class*="input"].v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-filterselect [class*="input"]:focus { + outline: none; + -webkit-transition: none; + -moz-transition: none; + transition: none; + border-color: #197de1; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 #f7f7f7, 0 1px 0 rgba(255, 255, 255, 0.1); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 #f7f7f7, 0 1px 0 rgba(255, 255, 255, 0.1); + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); +} + +.mytheme .v-filterselect [class*="input"][class*="prompt"] { + color: #a3a3a3; +} + +.mytheme .v-filterselect .v-icon + [class*="input"] { + padding-left: 37px; +} + +.mytheme .v-filterselect img.v-icon { + max-height: 37px; + margin-left: 9px; +} + +.mytheme .v-filterselect span.v-icon { + color: #474747; + width: 37px; + line-height: 1; + padding-top: 0.12em; +} + +.mytheme .v-filterselect[class*="prompt"] > [class*="input"] { + color: #a3a3a3; +} + +.mytheme .v-filterselect [class$="button"] { + -webkit-tap-highlight-color: transparent; + -webkit-touch-callout: none; + cursor: pointer; + position: absolute; + width: 37px; + top: 1px; + right: 1px; + bottom: 1px; + border-left: 1px solid #e4e4e4; + color: #a3a3a3; + border-radius: 0 3px 3px 0; +} + +.v-ie8 .mytheme .v-filterselect [class$="button"] { + background-color: white; +} + +.mytheme .v-filterselect [class$="button"]:before { + font-family: ThemeIcons; + content: "\f078"; + -webkit-transition: color 140ms; + -moz-transition: color 140ms; + transition: color 140ms; + position: absolute; + width: 37px; + text-align: center; + top: 50%; + line-height: 1; + margin-top: -0.47em; +} + +.mytheme .v-filterselect [class$="button"]:hover:before { + color: #474747; +} + +.mytheme .v-filterselect [class$="button"]:active:after { + content: ""; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + border-radius: inherit; + background-color: rgba(128, 128, 128, 0.2); +} + +.mytheme .v-filterselect.v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-filterselect.v-disabled [class$="button"] { + cursor: default; + pointer-events: none; +} + +.mytheme .v-filterselect.v-disabled [class$="button"]:active:after { + display: none; +} + +.mytheme .v-filterselect.v-readonly [class*="input"] { + background: #fafafa; + color: #464646; + -webkit-box-shadow: none; + box-shadow: none; +} + +.mytheme .v-filterselect.v-readonly [class*="input"]:focus { + box-shadow: none; + border-color: #c5c5c5; +} + +.mytheme .v-filterselect.v-readonly [class$="button"] { + cursor: default; + pointer-events: none; +} + +.mytheme .v-filterselect.v-readonly [class$="button"]:active:after { + display: none; +} + +.mytheme .v-filterselect .v-icon { + position: absolute; + pointer-events: none; +} + +.mytheme .v-filterselect-error .v-filterselect-input { + border-color: #ed473b !important; + background: #fffbfb; + color: #6c2621; +} + +.mytheme .v-filterselect-error .v-filterselect-button { + color: #ed473b; + border-color: #ed473b; +} + +.mytheme .v-filterselect-suggestpopup { + margin-top: 5px !important; +} + +.mytheme .v-filterselect-suggestpopup[class*="animate-in"] { + -webkit-animation: valo-overlay-animate-in 120ms; + -moz-animation: valo-overlay-animate-in 120ms; + animation: valo-overlay-animate-in 120ms; +} + +.mytheme .v-filterselect-suggestpopup [class$="suggestmenu"] { + padding: 4px 4px; + border-radius: 4px; + background-color: white; + color: #474747; + -webkit-box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.1), 0 3px 5px 0 rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.09098); + box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.1), 0 3px 5px 0 rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.09098); + -webkit-backface-visibility: hidden; + -moz-backface-visibility: hidden; + -ms-backface-visibility: hidden; + backface-visibility: hidden; + padding: 4px 4px; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + position: relative; + z-index: 1; + display: block; +} + +.mytheme .v-filterselect-suggestpopup table, .mytheme .v-filterselect-suggestpopup tbody, .mytheme .v-filterselect-suggestpopup tr, .mytheme .v-filterselect-suggestpopup td { + display: block; + width: 100%; + overflow-y: hidden; + float: left; + clear: both; +} + +.mytheme .v-filterselect-suggestpopup .gwt-MenuItem { + cursor: pointer; + line-height: 27px; + padding: 0 20px 0 10px; + border-radius: 3px; + font-weight: 400; + white-space: nowrap; + position: relative; + height: 27px; + box-sizing: border-box; + text-overflow: ellipsis; + overflow-x: hidden; +} + +.mytheme .v-filterselect-suggestpopup .gwt-MenuItem:active:before { + content: ""; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + background: #0957a6; + opacity: 0.15; + filter: alpha(opacity=15.0) ; + pointer-events: none; + border-radius: inherit; +} + +.mytheme .v-filterselect-suggestpopup .gwt-MenuItem .v-icon { + max-height: 27px; + margin-right: 5px; + min-width: 1em; +} + +.mytheme .v-filterselect-suggestpopup .gwt-MenuItem-selected { + background-color: #197de1; + background-image: -webkit-linear-gradient(top, #1b87e3 2%, #166ed5 98%); + background-image: linear-gradient(to bottom,#1b87e3 2%, #166ed5 98%); + color: #ecf2f8; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.05); +} + +.mytheme .v-filterselect-suggestpopup [class$="status"] { + position: absolute; + right: 4px; + background: rgba(212, 212, 212, 0.9); + color: #3b3b3b; + border-radius: 0 0 4px 4px; + height: 23px; + bottom: -23px; + font-size: 12px; + line-height: 23px; + padding: 0 6px; + cursor: default; + pointer-events: none; + -webkit-animation: valo-animate-in-slide-down 200ms 80ms backwards; + -moz-animation: valo-animate-in-slide-down 200ms 80ms backwards; + animation: valo-animate-in-slide-down 200ms 80ms backwards; +} + +.mytheme .v-filterselect-suggestpopup [class$="status"] > * { + color: #3b3b3b; + text-decoration: none; +} + +.mytheme .v-filterselect-suggestpopup div[class*="page"] { + position: absolute; + z-index: 3; + right: 0; + opacity: 0.2; + filter: alpha(opacity=20) ; + cursor: pointer; + -webkit-transition: all 200ms; + -moz-transition: all 200ms; + transition: all 200ms; + width: 25px; + height: 25px; + line-height: 25px; + text-align: center; + font-family: ThemeIcons; + -webkit-transform: scale(0.8); + -moz-transform: scale(0.8); + -ms-transform: scale(0.8); + -o-transform: scale(0.8); + transform: scale(0.8); + color: #464646; +} + +.mytheme .v-filterselect-suggestpopup div[class*="page"]:after { + content: ""; + position: absolute; + display: block; + border-radius: 50%; +} + +.mytheme .v-filterselect-suggestpopup div[class*="page"]:hover { + opacity: 1; + filter: none ; + background: rgba(250, 250, 250, 0.5); +} + +.mytheme .v-filterselect-suggestpopup div[class*="page"]:hover:after { + top: -10px; + bottom: -10px; + left: -20px; + right: -20px; +} + +.mytheme .v-filterselect-suggestpopup div[class*="page"] span { + display: none; +} + +.mytheme .v-filterselect-suggestpopup:hover div[class*="page"] { + -webkit-transform: scale(1); + -moz-transform: scale(1); + -ms-transform: scale(1); + -o-transform: scale(1); + transform: scale(1); +} + +.mytheme .v-filterselect-suggestpopup div[class*="prev"] { + top: 0; + -webkit-transform-origin: 100% 0%; + -moz-transform-origin: 100% 0%; + -ms-transform-origin: 100% 0%; + -o-transform-origin: 100% 0%; + transform-origin: 100% 0%; + border-radius: 0 4px 0 4px; +} + +.mytheme .v-filterselect-suggestpopup div[class*="prev"]:before { + content: "\f0d8"; +} + +.mytheme .v-filterselect-suggestpopup div[class*="next"] { + bottom: 0; + -webkit-transform-origin: 100% 100%; + -moz-transform-origin: 100% 100%; + -ms-transform-origin: 100% 100%; + -o-transform-origin: 100% 100%; + transform-origin: 100% 100%; + border-radius: 4px 0 4px 0; +} + +.mytheme .v-filterselect-suggestpopup div[class*="next"]:before { + content: "\f0d7"; +} + +.mytheme .v-filterselect-suggestpopup div[class*="-off"] { + display: none; +} + +.mytheme .v-filterselect-no-input { + cursor: pointer; + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.05); +} + +.mytheme .v-filterselect-no-input [class*="input"] { + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + cursor: inherit; + -webkit-box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + border: 1px solid #c5c5c5; + border-top-color: #c5c5c5; + border-bottom-color: #bcbcbc; + text-shadow: inherit; + text-overflow: ellipsis; + border-radius: inherit; +} + +.mytheme .v-filterselect-no-input [class*="input"]:focus { + outline: none; + -webkit-transition: none; + -moz-transition: none; + transition: none; + border-color: #197de1; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); +} + +.mytheme .v-filterselect-no-input [class$="button"] { + border-left: none !important; +} + +.mytheme .v-filterselect-no-input:hover [class$="button"]:before { + color: inherit; +} + +.mytheme .v-filterselect-borderless .v-filterselect-input { + border: none; + border-radius: 0; + background: transparent; + -webkit-box-shadow: none; + box-shadow: none; + color: inherit; +} + +.mytheme .v-filterselect-borderless .v-filterselect-input:focus { + -webkit-box-shadow: none; + box-shadow: none; +} + +.mytheme .v-filterselect-borderless .v-filterselect-input[class*="prompt"] { + color: inherit; + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-filterselect-borderless .v-filterselect-button { + border: none; + color: inherit; + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-filterselect-borderless.v-filterselect-prompt .v-filterselect-input { + color: inherit; + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-filterselect-align-right input { + text-align: right; +} + +.mytheme .v-filterselect-align-center input { + text-align: center; +} + +.mytheme .v-filterselect-tiny { + height: 28px; + + font-size: 12px; +} + +.mytheme .v-filterselect-tiny [class*="input"] { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; + margin: 0; + font: inherit; + + font-weight: 400; + line-height: normal; + height: 28px; + + padding: 3px 5px; + + + -webkit-transition: box-shadow 180ms, border 180ms; + -moz-transition: box-shadow 180ms, border 180ms; + transition: box-shadow 180ms, border 180ms; + width: 100% !important; + height: 100%; + padding-right: 29px; + border-radius: inherit; +} + +.v-ie8 .mytheme .v-filterselect-tiny [class*="input"], .v-ie9 .mytheme .v-filterselect-tiny [class*="input"] { + line-height: 28px; + padding-top: 0; + padding-bottom: 0; +} + +.mytheme .v-filterselect-tiny .v-icon + [class*="input"] { + padding-left: 28px; +} + +.mytheme .v-filterselect-tiny img.v-icon { + max-height: 28px; + margin-left: 5px; +} + +.mytheme .v-filterselect-tiny span.v-icon { + + width: 28px; + line-height: 1; + padding-top: 0.12em; +} + +.mytheme .v-filterselect-tiny [class$="button"] { + -webkit-tap-highlight-color: transparent; + -webkit-touch-callout: none; + cursor: pointer; + position: absolute; + width: 28px; + border-radius: 0 4px 4px 0; +} + +.mytheme .v-filterselect-tiny [class$="button"]:before { + font-family: ThemeIcons; + content: "\f078"; + -webkit-transition: color 140ms; + -moz-transition: color 140ms; + transition: color 140ms; + position: absolute; + width: 28px; + text-align: center; + top: 50%; + line-height: 1; + margin-top: -0.47em; +} + +.mytheme .v-filterselect-tiny [class$="button"]:active:after { + content: ""; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + border-radius: inherit; +} + +.mytheme .v-filterselect-tiny.v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-filterselect-tiny.v-disabled [class$="button"] { + cursor: default; + pointer-events: none; +} + +.mytheme .v-filterselect-tiny.v-disabled [class$="button"]:active:after { + display: none; +} + +.mytheme .v-filterselect-tiny.v-readonly [class*="input"] { + background: #fafafa; + color: #464646; + -webkit-box-shadow: none; + box-shadow: none; +} + +.mytheme .v-filterselect-tiny.v-readonly [class*="input"]:focus { + box-shadow: none; + border-color: #c5c5c5; +} + +.mytheme .v-filterselect-tiny.v-readonly [class$="button"] { + cursor: default; + pointer-events: none; +} + +.mytheme .v-filterselect-tiny.v-readonly [class$="button"]:active:after { + display: none; +} + +.mytheme .v-filterselect-compact, .mytheme .v-filterselect-small { + height: 31px; + +} + +.mytheme .v-filterselect-compact [class*="input"], .mytheme .v-filterselect-small [class*="input"] { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; + margin: 0; + font: inherit; + + font-weight: 400; + line-height: normal; + height: 31px; + + padding: 3px 6px; + + + -webkit-transition: box-shadow 180ms, border 180ms; + -moz-transition: box-shadow 180ms, border 180ms; + transition: box-shadow 180ms, border 180ms; + width: 100% !important; + height: 100%; + padding-right: 32px; + border-radius: inherit; +} + +.v-ie8 .mytheme .v-filterselect-compact [class*="input"], .v-ie9 .mytheme .v-filterselect-compact [class*="input"], .v-ie8 .mytheme .v-filterselect-small [class*="input"], .v-ie9 .mytheme .v-filterselect-small [class*="input"] { + line-height: 31px; + padding-top: 0; + padding-bottom: 0; +} + +.mytheme .v-filterselect-compact .v-icon + [class*="input"], .mytheme .v-filterselect-small .v-icon + [class*="input"] { + padding-left: 31px; +} + +.mytheme .v-filterselect-compact img.v-icon, .mytheme .v-filterselect-small img.v-icon { + max-height: 31px; + margin-left: 6px; +} + +.mytheme .v-filterselect-compact span.v-icon, .mytheme .v-filterselect-small span.v-icon { + + width: 31px; + line-height: 1; + padding-top: 0.12em; +} + +.mytheme .v-filterselect-compact [class$="button"], .mytheme .v-filterselect-small [class$="button"] { + -webkit-tap-highlight-color: transparent; + -webkit-touch-callout: none; + cursor: pointer; + position: absolute; + width: 31px; + border-radius: 0 4px 4px 0; +} + +.mytheme .v-filterselect-compact [class$="button"]:before, .mytheme .v-filterselect-small [class$="button"]:before { + font-family: ThemeIcons; + content: "\f078"; + -webkit-transition: color 140ms; + -moz-transition: color 140ms; + transition: color 140ms; + position: absolute; + width: 31px; + text-align: center; + top: 50%; + line-height: 1; + margin-top: -0.47em; +} + +.mytheme .v-filterselect-compact [class$="button"]:active:after, .mytheme .v-filterselect-small [class$="button"]:active:after { + content: ""; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + border-radius: inherit; +} + +.mytheme .v-filterselect-compact.v-disabled, .mytheme .v-filterselect-small.v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-filterselect-compact.v-disabled [class$="button"], .mytheme .v-filterselect-small.v-disabled [class$="button"] { + cursor: default; + pointer-events: none; +} + +.mytheme .v-filterselect-compact.v-disabled [class$="button"]:active:after, .mytheme .v-filterselect-small.v-disabled [class$="button"]:active:after { + display: none; +} + +.mytheme .v-filterselect-compact.v-readonly [class*="input"], .mytheme .v-filterselect-small.v-readonly [class*="input"] { + background: #fafafa; + color: #464646; + -webkit-box-shadow: none; + box-shadow: none; +} + +.mytheme .v-filterselect-compact.v-readonly [class*="input"]:focus, .mytheme .v-filterselect-small.v-readonly [class*="input"]:focus { + box-shadow: none; + border-color: #c5c5c5; +} + +.mytheme .v-filterselect-compact.v-readonly [class$="button"], .mytheme .v-filterselect-small.v-readonly [class$="button"] { + cursor: default; + pointer-events: none; +} + +.mytheme .v-filterselect-compact.v-readonly [class$="button"]:active:after, .mytheme .v-filterselect-small.v-readonly [class$="button"]:active:after { + display: none; +} + +.mytheme .v-filterselect-small { + font-size: 14px; +} + +.mytheme .v-filterselect-large { + height: 44px; + + font-size: 20px; +} + +.mytheme .v-filterselect-large [class*="input"] { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; + margin: 0; + font: inherit; + + font-weight: 400; + line-height: normal; + height: 44px; + + padding: 5px 8px; + + + -webkit-transition: box-shadow 180ms, border 180ms; + -moz-transition: box-shadow 180ms, border 180ms; + transition: box-shadow 180ms, border 180ms; + width: 100% !important; + height: 100%; + padding-right: 45px; + border-radius: inherit; +} + +.v-ie8 .mytheme .v-filterselect-large [class*="input"], .v-ie9 .mytheme .v-filterselect-large [class*="input"] { + line-height: 44px; + padding-top: 0; + padding-bottom: 0; +} + +.mytheme .v-filterselect-large .v-icon + [class*="input"] { + padding-left: 44px; +} + +.mytheme .v-filterselect-large img.v-icon { + max-height: 44px; + margin-left: 8px; +} + +.mytheme .v-filterselect-large span.v-icon { + + width: 44px; + line-height: 1; + padding-top: 0.12em; +} + +.mytheme .v-filterselect-large [class$="button"] { + -webkit-tap-highlight-color: transparent; + -webkit-touch-callout: none; + cursor: pointer; + position: absolute; + width: 44px; + border-radius: 0 4px 4px 0; +} + +.mytheme .v-filterselect-large [class$="button"]:before { + font-family: ThemeIcons; + content: "\f078"; + -webkit-transition: color 140ms; + -moz-transition: color 140ms; + transition: color 140ms; + position: absolute; + width: 44px; + text-align: center; + top: 50%; + line-height: 1; + margin-top: -0.47em; +} + +.mytheme .v-filterselect-large [class$="button"]:active:after { + content: ""; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + border-radius: inherit; +} + +.mytheme .v-filterselect-large.v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-filterselect-large.v-disabled [class$="button"] { + cursor: default; + pointer-events: none; +} + +.mytheme .v-filterselect-large.v-disabled [class$="button"]:active:after { + display: none; +} + +.mytheme .v-filterselect-large.v-readonly [class*="input"] { + background: #fafafa; + color: #464646; + -webkit-box-shadow: none; + box-shadow: none; +} + +.mytheme .v-filterselect-large.v-readonly [class*="input"]:focus { + box-shadow: none; + border-color: #c5c5c5; +} + +.mytheme .v-filterselect-large.v-readonly [class$="button"] { + cursor: default; + pointer-events: none; +} + +.mytheme .v-filterselect-large.v-readonly [class$="button"]:active:after { + display: none; +} + +.mytheme .v-filterselect-huge { + height: 59px; + + font-size: 26px; +} + +.mytheme .v-filterselect-huge [class*="input"] { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; + margin: 0; + font: inherit; + + font-weight: 400; + line-height: normal; + height: 59px; + + padding: 7px 10px; + + + -webkit-transition: box-shadow 180ms, border 180ms; + -moz-transition: box-shadow 180ms, border 180ms; + transition: box-shadow 180ms, border 180ms; + width: 100% !important; + height: 100%; + padding-right: 60px; + border-radius: inherit; +} + +.v-ie8 .mytheme .v-filterselect-huge [class*="input"], .v-ie9 .mytheme .v-filterselect-huge [class*="input"] { + line-height: 59px; + padding-top: 0; + padding-bottom: 0; +} + +.mytheme .v-filterselect-huge .v-icon + [class*="input"] { + padding-left: 59px; +} + +.mytheme .v-filterselect-huge img.v-icon { + max-height: 59px; + margin-left: 10px; +} + +.mytheme .v-filterselect-huge span.v-icon { + + width: 59px; + line-height: 1; + padding-top: 0.12em; +} + +.mytheme .v-filterselect-huge [class$="button"] { + -webkit-tap-highlight-color: transparent; + -webkit-touch-callout: none; + cursor: pointer; + position: absolute; + width: 59px; + border-radius: 0 4px 4px 0; +} + +.mytheme .v-filterselect-huge [class$="button"]:before { + font-family: ThemeIcons; + content: "\f078"; + -webkit-transition: color 140ms; + -moz-transition: color 140ms; + transition: color 140ms; + position: absolute; + width: 59px; + text-align: center; + top: 50%; + line-height: 1; + margin-top: -0.47em; +} + +.mytheme .v-filterselect-huge [class$="button"]:active:after { + content: ""; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + border-radius: inherit; +} + +.mytheme .v-filterselect-huge.v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-filterselect-huge.v-disabled [class$="button"] { + cursor: default; + pointer-events: none; +} + +.mytheme .v-filterselect-huge.v-disabled [class$="button"]:active:after { + display: none; +} + +.mytheme .v-filterselect-huge.v-readonly [class*="input"] { + background: #fafafa; + color: #464646; + -webkit-box-shadow: none; + box-shadow: none; +} + +.mytheme .v-filterselect-huge.v-readonly [class*="input"]:focus { + box-shadow: none; + border-color: #c5c5c5; +} + +.mytheme .v-filterselect-huge.v-readonly [class$="button"] { + cursor: default; + pointer-events: none; +} + +.mytheme .v-filterselect-huge.v-readonly [class$="button"]:active:after { + display: none; +} + +.mytheme .v-csslayout-well { + background: #f5f5f5; + color: #454545; + -webkit-box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.05), inset 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.05), inset 0 2px 3px rgba(0, 0, 0, 0.05); + border-radius: 4px; + border: 1px solid #c5c5c5; +} + +.mytheme .v-csslayout-well > div > [class*="-caption"] { + background: transparent; + -webkit-box-shadow: none; + box-shadow: none; +} + +.mytheme .v-csslayout-well > .v-margin-top { + padding-top: 12px; +} + +.mytheme .v-csslayout-well > .v-margin-right { + padding-right: 12px; +} + +.mytheme .v-csslayout-well > .v-margin-bottom { + padding-bottom: 12px; +} + +.mytheme .v-csslayout-well > .v-margin-left { + padding-left: 12px; +} + +.mytheme .v-csslayout-card { + background: white; + color: #474747; + border-radius: 4px; + border: 1px solid #d5d5d5; + -webkit-box-shadow: 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: 0 2px 3px rgba(0, 0, 0, 0.05); +} + +.mytheme .v-csslayout-card > .v-margin-top { + padding-top: 12px; +} + +.mytheme .v-csslayout-card > .v-margin-right { + padding-right: 12px; +} + +.mytheme .v-csslayout-card > .v-margin-bottom { + padding-bottom: 12px; +} + +.mytheme .v-csslayout-card > .v-margin-left { + padding-left: 12px; +} + +.mytheme .v-csslayout-v-component-group { + white-space: nowrap; + position: relative; +} + +.mytheme .v-csslayout-v-component-group .v-widget ~ .v-widget:not(:last-child) { + border-radius: 0; +} + +.mytheme .v-csslayout-v-component-group .v-widget:last-child { + border-top-left-radius: 0; + border-bottom-left-radius: 0; +} + +.mytheme .v-csslayout-v-component-group .v-widget:first-child, .mytheme .v-csslayout-v-component-group .v-caption:first-child + .v-widget { + border-top-right-radius: 0; + border-bottom-right-radius: 0; +} + +.mytheme .v-csslayout-v-component-group .v-widget ~ .v-widget.first.first { + border-radius: 4px 0 0 4px; +} + +.mytheme .v-csslayout-v-component-group .v-widget ~ .v-widget.last.last { + border-radius: 0 4px 4px 0; +} + +.mytheme .v-csslayout-v-component-group .v-widget { + vertical-align: middle; + margin-left: -1px; +} + +.mytheme .v-csslayout-v-component-group .v-widget:first-child { + margin-left: 0; +} + +.mytheme .v-csslayout-v-component-group .v-widget:focus, .mytheme .v-csslayout-v-component-group .v-widget[class*="focus"], .mytheme .v-csslayout-v-component-group .v-widget [class*="focus"] { + position: relative; + z-index: 5; +} + +.mytheme .v-form fieldset { + border: none; + padding: 0; + margin: 0; + height: 100%; +} + +.mytheme .v-form-content { + height: 100%; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +.mytheme [class*="spacing"] > tbody > [class*="row"] > td { + padding-top: 12px; +} + +.mytheme [class*="spacing"] > tbody > [class*="firstrow"] > td { + padding-top: 0; +} + +.mytheme [class*="margin-top"] > tbody > [class*="firstrow"] > td { + padding-top: 37px; +} + +.mytheme [class*="margin-bottom"] > tbody > [class*="lastrow"] > td { + padding-bottom: 37px; +} + +.mytheme [class*="margin-left"] > tbody > [class*="row"] > [class*="captioncell"] { + padding-left: 37px; +} + +.mytheme [class*="margin-left"] > tbody > [class*="row"] > [class*="contentcell"] > .v-label-h2, .mytheme [class*="margin-left"] > tbody > [class*="row"] > [class*="contentcell"] > .v-label-h3, .mytheme [class*="margin-left"] > tbody > [class*="row"] > [class*="contentcell"] > .v-label-h4 { + left: 37px; +} + +.mytheme [class*="margin-right"] > tbody > [class*="row"] > [class*="contentcell"] { + padding-right: 37px; +} + +.mytheme [class*="margin-right"] > tbody > [class*="row"] > [class*="contentcell"] > .v-label-h2, .mytheme [class*="margin-right"] > tbody > [class*="row"] > [class*="contentcell"] > .v-label-h3, .mytheme [class*="margin-right"] > tbody > [class*="row"] > [class*="contentcell"] > .v-label-h4 { + right: 37px; +} + +.mytheme .v-formlayout > table { + border-spacing: 0; + position: relative; +} + +.mytheme .v-formlayout.v-has-width > table, .mytheme .v-formlayout.v-has-width .v-formlayout-contentcell { + width: 100%; +} + +.mytheme .v-formlayout-error-indicator { + width: 19px; +} + +.mytheme .v-formlayout-captioncell { + vertical-align: top; + line-height: 36px; +} + +.mytheme .v-formlayout-captioncell .v-caption { + padding-bottom: 0; +} + +.mytheme .v-formlayout-captioncell .v-caption-h2, .mytheme .v-formlayout-captioncell .v-caption-h3, .mytheme .v-formlayout-captioncell .v-caption-h4 { + height: 3em; +} + +.mytheme .v-formlayout-contentcell .v-checkbox, .mytheme .v-formlayout-contentcell .v-radiobutton { + font-weight: 400; +} + +.mytheme .v-formlayout-contentcell > .v-label-h2, .mytheme .v-formlayout-contentcell > .v-label-h3, .mytheme .v-formlayout-contentcell > .v-label-h4 { + position: absolute; + left: 0; + right: 0; + width: auto !important; + margin-top: -0.5em; + padding-bottom: 0.5em; + border-bottom: 1px solid #dfdfdf; +} + +.mytheme .v-formlayout.light > table { + padding: 0; +} + +.mytheme .v-formlayout.light > table > tbody > tr > td { + padding-top: 0; + height: 37px; + border-bottom: 1px solid #eaeaea; +} + +.mytheme .v-formlayout.light > table > tbody > [class*="lastrow"] > td { + border-bottom: none; +} + +.mytheme .v-formlayout.light > table > tbody > tr > [class*="captioncell"] { + color: #7d7d7d; + text-align: right; + padding-left: 13px; + line-height: 37px; +} + +.mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] { + padding-right: 0; +} + +.mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-textfield, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-textarea, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-filterselect, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-datefield, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-filterselect-input, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-datefield-textfield { + width: 100%; +} + +.mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-textfield, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-textarea, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-filterselect input, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-datefield input, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-richtextarea { + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; + margin: 0; + font: inherit; + + font-weight: 400; + line-height: normal; + height: 37px; + border-radius: 0; + padding: 4px 7px; + + -webkit-box-shadow: none; + box-shadow: none; + -webkit-transition: box-shadow 180ms, border 180ms; + -moz-transition: box-shadow 180ms, border 180ms; + transition: box-shadow 180ms, border 180ms; + background: transparent; + border: none; + color: inherit; +} + +.v-ie8 .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-textfield, .v-ie9 .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-textfield, .v-ie8 .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-textarea, .v-ie9 .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-textarea, .v-ie8 .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-filterselect input, .v-ie9 .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-filterselect input, .v-ie8 .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-datefield input, .v-ie9 .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-datefield input, .v-ie8 .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-richtextarea, .v-ie9 .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-richtextarea { + line-height: 37px; + padding-top: 0; + padding-bottom: 0; +} + +.mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-textfield.v-disabled, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-textarea.v-disabled, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-filterselect input.v-disabled, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-datefield input.v-disabled, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-richtextarea.v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-textfield:focus, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-textarea:focus, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-filterselect input:focus, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-datefield input:focus, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-richtextarea:focus { + outline: none; + -webkit-transition: none; + -moz-transition: none; + transition: none; + border-color: #197de1; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), none; + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), none; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); +} + +.mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-textfield:focus, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-textarea:focus, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-filterselect input:focus, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-datefield input:focus, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-richtextarea:focus { + box-shadow: none; +} + +.mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-textfield-prompt, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-textarea-prompt, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-filterselect-prompt input, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-datefield-prompt input { + color: #a3a3a3; +} + +.mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-textarea, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-richtextarea { + height: auto; +} + +.mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-label-h2, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-label-h3, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-label-h4 { + border-bottom: none; + left: 0; + right: 0; +} + +.mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-label-h3, .mytheme .v-formlayout.light > table > tbody > [class*="row"] > [class*="contentcell"] > .v-label-h4 { + margin-top: 0; +} + +.mytheme .v-formlayout.light .v-richtextarea { + margin: 5px 0; +} + +.mytheme .v-formlayout.light .v-filterselect-button, .mytheme .v-formlayout.light .v-datefield-button { + border: none; +} + +.mytheme .v-formlayout.light .v-filterselect-button:active:after, .mytheme .v-formlayout.light .v-datefield-button:active:after { + display: none; +} + +.mytheme .v-formlayout.light .v-datefield-button { + right: 0; + left: auto; +} + +.mytheme .v-formlayout.light .v-checkbox { + margin-left: 7px; +} + +.mytheme .v-grid { + position: relative; +} + +.mytheme .v-grid-scroller { + position: absolute; + z-index: 1; + outline: none; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +.mytheme .v-grid-scroller-horizontal { + left: 0; + right: 0; + bottom: 0; + overflow-y: hidden; + -ms-overflow-y: hidden; +} + +.mytheme .v-grid-scroller-vertical { + right: 0; + top: 0; + bottom: 0; + overflow-x: hidden; + -ms-overflow-x: hidden; +} + +.mytheme .v-grid-tablewrapper { + position: absolute; + overflow: hidden; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + z-index: 5; +} + +.mytheme .v-grid-tablewrapper > table { + border-spacing: 0; + table-layout: fixed; + width: inherit; +} + +.mytheme .v-grid-header-deco, .mytheme .v-grid-footer-deco { + position: absolute; + right: 0; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +.mytheme .v-grid-horizontal-scrollbar-deco { + position: absolute; + bottom: 0; + left: 0; + right: 0; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +.mytheme .v-grid-header, .mytheme .v-grid-body, .mytheme .v-grid-footer { + position: absolute; + left: 0; + width: inherit; + z-index: 10; +} + +.mytheme .v-grid-header, .mytheme .v-grid-header-deco { + top: 0; +} + +.mytheme .v-grid-footer, .mytheme .v-grid-footer-deco { + bottom: 0; +} + +.mytheme .v-grid-body { + -ms-touch-action: none; + touch-action: none; + z-index: 0; + top: 0; +} + +.mytheme .v-grid-body .v-grid-row { + position: absolute; + top: 0; + left: 0; +} + +.mytheme .v-grid-row { + display: block; +} + +.v-ie8 .mytheme .v-grid-row, .v-ie9 .mytheme .v-grid-row { + float: left; + clear: left; + margin-top: 0; +} + +.mytheme .v-grid-row > td, .mytheme .v-grid-row > th { + background-color: white; +} + +.mytheme .v-grid-row { + width: inherit; +} + +.mytheme .v-grid-cell { + display: block; + float: left; + padding: 2px; + white-space: nowrap; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + overflow: hidden; + font-size: 16px; +} + +.mytheme .v-grid-cell.frozen { + position: relative; + z-index: 1; +} + +.mytheme .v-grid-spacer { + position: absolute; + display: block; + background-color: white; +} + +.mytheme .v-grid-spacer > td { + width: 100%; + height: 100%; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +.v-ie8 .mytheme .v-grid-spacer, .v-ie9 .mytheme .v-grid-spacer { + margin-top: 0; +} + +.mytheme .v-grid { + outline: none; +} + +.mytheme .v-grid-scroller-vertical, .mytheme .v-grid-scroller-horizontal { + border: 1px solid #d4d4d4; +} + +.mytheme .v-grid-scroller-vertical { + border-left: none; +} + +.mytheme .v-grid-scroller-horizontal { + border-top: none; +} + +.mytheme .v-grid-tablewrapper { + border: 1px solid #d4d4d4; +} + +.mytheme .v-grid .header-drag-table { + border-spacing: 0; + position: relative; + table-layout: fixed; + width: inherit; +} + +.mytheme .v-grid .header-drag-table .v-grid-header { + position: absolute; +} + +.mytheme .v-grid .header-drag-table .v-grid-header > .v-grid-cell { + border: 1px solid #d4d4d4; + margin-top: -10px; + opacity: 0.9; + filter: alpha(opacity=90); + z-index: 30000; +} + +.mytheme .v-grid .header-drag-table .v-grid-header > .v-grid-drop-marker { + background-color: #197de1; + position: absolute; + width: 3px; +} + +.mytheme .v-grid-sidebar.v-contextmenu { + -webkit-box-shadow: none; + box-shadow: none; + border-radius: 0; + position: absolute; + top: 0; + right: 0; + background-color: #fafafa; + border: 1px solid #d4d4d4; + padding: 0; + z-index: 5; +} + +.mytheme .v-grid-sidebar.v-contextmenu.v-grid-sidebar-popup { + right: auto; +} + +.mytheme .v-grid-sidebar.v-contextmenu .v-grid-sidebar-button { + background: transparent; + border: none; + color: inherit; + cursor: pointer; + outline: none; + padding: 0 4px; + text-align: right; + line-height: 1; +} + +.mytheme .v-grid-sidebar.v-contextmenu .v-grid-sidebar-button[disabled] { + cursor: default; +} + +.mytheme .v-grid-sidebar.v-contextmenu .v-grid-sidebar-button::-moz-focus-inner { + border: 0; +} + +.mytheme .v-grid-sidebar.v-contextmenu .v-grid-sidebar-button:after { + content: "\f0c9"; + display: block; + font-family: ThemeIcons, sans-serif; + font-size: 14px; +} + +.mytheme .v-grid-sidebar.v-contextmenu.closed { + border-radius: 0; +} + +.mytheme .v-grid-sidebar.v-contextmenu.open .v-grid-sidebar-button { + width: 100%; +} + +.mytheme .v-grid-sidebar.v-contextmenu.open .v-grid-sidebar-button:after { + content: "\f0c9"; + font-size: 14px; + line-height: 1; +} + +.v-ie .mytheme .v-grid-sidebar.v-contextmenu.open .v-grid-sidebar-button { + vertical-align: middle; +} + +.v-ie8 .mytheme .v-grid-sidebar.v-contextmenu.open .v-grid-sidebar-button:after { + vertical-align: middle; + text-align: center; + display: inline; +} + +.mytheme .v-grid-sidebar.v-contextmenu .v-grid-sidebar-content { + padding: 4px 0; + overflow-y: auto; + overflow-x: hidden; +} + +.mytheme .v-grid-sidebar.v-contextmenu .v-grid-sidebar-content .gwt-MenuBar .gwt-MenuItem .column-hiding-toggle { + text-shadow: none; +} + +.mytheme .v-grid-cell { + background-color: white; + padding: 0 18px; + line-height: 37px; + text-overflow: ellipsis; +} + +.mytheme .v-grid-cell > * { + line-height: 1.55; + vertical-align: middle; +} + +.mytheme .v-grid-cell > div { + display: inline-block; +} + +.mytheme .v-grid-cell.frozen { + -webkit-box-shadow: 1px 0 2px rgba(0, 0, 0, 0.1); + box-shadow: 1px 0 2px rgba(0, 0, 0, 0.1); + border-right: 1px solid #d4d4d4; +} + +.mytheme .v-grid-cell.frozen + th, .mytheme .v-grid-cell.frozen + td { + border-left: none; +} + +.mytheme .v-grid-row > td, .mytheme .v-grid-editor-cells > div { + border-left: 1px solid #d4d4d4; + border-bottom: 1px solid #d4d4d4; +} + +.mytheme .v-grid-row > td:first-child, .mytheme .v-grid-editor-cells > div:first-child { + border-left: none; +} + +.mytheme .v-grid-editor-cells.frozen > div { + -webkit-box-shadow: 1px 0 2px rgba(0, 0, 0, 0.1); + box-shadow: 1px 0 2px rgba(0, 0, 0, 0.1); + border-right: 1px solid #d4d4d4; + border-left: none; +} + +.mytheme .v-grid-row-stripe > td { + background-color: #f5f5f5; +} + +.mytheme .v-grid-row-selected > td { + background: #197de1; +} + +.mytheme .v-grid-row-focused > td { + +} + +.mytheme .v-grid-header th { + position: relative; + background-color: #fafafa; + font-size: 14px; + font-weight: inherit; + border-left: 1px solid #d4d4d4; + border-bottom: 1px solid #d4d4d4; + + text-align: left; +} + +.mytheme .v-grid-header th:first-child { + border-left: none; +} + +.mytheme .v-grid-header .sort-asc, .mytheme .v-grid-header .sort-desc { + padding-right: 35px; +} + +.mytheme .v-grid-header .sort-asc:after, .mytheme .v-grid-header .sort-desc:after { + font-family: ThemeIcons, sans-serif; + content: "\f0de" " " attr(sort-order); + position: absolute; + right: 18px; + font-size: 12px; +} + +.mytheme .v-grid-header .sort-desc:after { + content: "\f0dd" " " attr(sort-order); +} + +.mytheme .v-grid-column-resize-handle { + position: absolute; + width: 36px; + right: -18px; + top: 0px; + bottom: 0px; + cursor: col-resize; + z-index: 10; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.mytheme .v-grid-column-resize-simple-indicator { + position: absolute; + width: 3px; + top: 0px; + left: 18px; + z-index: 9001; + background: #fff; + box-shadow: 0px 0px 5px #000; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.mytheme .v-grid-footer td { + background-color: #fafafa; + font-size: 14px; + font-weight: inherit; + border-left: 1px solid #d4d4d4; + border-top: 1px solid #d4d4d4; + border-bottom: none; + +} + +.mytheme .v-grid-footer td:first-child { + border-left: none; +} + +.mytheme .v-grid-header .v-grid-cell, .mytheme .v-grid-footer .v-grid-cell { + overflow: visible; +} + +.mytheme .v-grid-column-header-content, .mytheme .v-grid-column-footer-content { + width: 100%; + overflow: hidden; + text-overflow: ellipsis; + line-height: 37px; + vertical-align: baseline; +} + +.mytheme .v-grid-header-deco { + border-top: 1px solid #d4d4d4; + border-right: 1px solid #d4d4d4; + background-color: #fafafa; +} + +.mytheme .v-grid-footer-deco { + border-bottom: 1px solid #d4d4d4; + border-right: 1px solid #d4d4d4; + background-color: #fafafa; +} + +.mytheme .v-grid-horizontal-scrollbar-deco { + background-color: #fafafa; + border: 1px solid #d4d4d4; + border-top: none; +} + +.mytheme .v-grid-cell-focused { + position: relative; +} + +.mytheme .v-grid-cell-focused:before { + content: ""; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + border: 2px solid #197de1; + display: none; + pointer-events: none; +} + +.ie8 .mytheme .v-grid-cell-focused:before, .ie9 .mytheme .v-grid-cell-focused:before, .ie10 .mytheme .v-grid-cell-focused:before { + content: url(data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==); +} + +.mytheme .v-grid:focus .v-grid-cell-focused:before { + display: block; +} + +.mytheme .v-grid.v-disabled:focus .v-grid-cell-focused:before { + display: none; +} + +.mytheme .v-grid-editor { + position: absolute; + z-index: 20; + overflow: hidden; + left: 0; + right: 0; + border: 1px solid #d4d4d4; + box-sizing: border-box; + -moz-box-sizing: border-box; + margin-top: -1px; + -webkit-box-shadow: 0 0 9px rgba(0, 0, 0, 0.2); + box-shadow: 0 0 9px rgba(0, 0, 0, 0.2); +} + +.mytheme .v-grid-editor.unbuffered .v-grid-editor-footer { + width: 100%; +} + +.mytheme .v-grid-editor-cells { + position: relative; + white-space: nowrap; +} + +.mytheme .v-grid-editor-cells.frozen { + z-index: 2; +} + +.mytheme .v-grid-editor-cells > div { + display: inline-block; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + vertical-align: middle; + background: white; +} + +.mytheme .v-grid-editor-cells > div:first-child { + border-left: none; +} + +.mytheme .v-grid-editor-cells > div > * { + vertical-align: middle; + display: inline-block; +} + +.mytheme .v-grid-editor-cells > div .v-filterselect { + padding-left: 0; +} + +.mytheme .v-grid-editor-cells > div input[type="text"], .mytheme .v-grid-editor-cells > div input[type="text"].v-filterselect-input, .mytheme .v-grid-editor-cells > div input[type="password"] { + padding-left: 18px; +} + +.mytheme .v-grid-editor-cells > div input[type="text"]:not(.v-filterselect-input), .mytheme .v-grid-editor-cells > div input[type="password"] { + padding-right: 9px; +} + +.mytheme .v-grid-editor-cells > div input[type="checkbox"] { + margin-left: 18px; +} + +.mytheme .v-grid-editor-cells > div .v-textfield, .mytheme .v-grid-editor-cells > div .v-datefield, .mytheme .v-grid-editor-cells > div .v-filterselect { + min-width: 100%; + max-width: 100%; + min-height: 100%; + max-height: 100%; +} + +.v-ie8 .mytheme .v-grid-editor-cells > div .v-datefield-button { + margin-left: -37px; +} + +.v-ie8 .mytheme .v-grid-editor-cells > div .v-filterselect-button { + margin-left: -25px; +} + +.mytheme .v-grid-editor-cells > div .v-select, .mytheme .v-grid-editor-cells > div .v-select-select { + min-width: 100%; + max-width: 100%; +} + +.mytheme .v-grid-editor-cells > div.not-editable.v-grid-cell { + float: none; +} + +.mytheme .v-grid-editor-cells .error::before { + position: absolute; + display: block; + height: 0; + width: 0; + content: ""; + border-top: 5px solid red; + border-right: 5px solid transparent; +} + +.mytheme .v-grid-editor-cells .error, .mytheme .v-grid-editor-cells .error > input { + background-color: #fee; +} + +.mytheme .v-grid-editor-footer { + display: table; + height: 37px; + border-top: 1px solid #d4d4d4; + margin-top: -1px; + background: white; + padding: 0 5px; +} + +.mytheme .v-grid-editor-footer + .v-grid-editor-cells > div { + border-bottom: none; + border-top: 1px solid #d4d4d4; +} + +.mytheme .v-grid-editor-footer:first-child { + border-top: none; + margin-top: 0; + border-bottom: 1px solid #d4d4d4; + margin-bottom: -1px; +} + +.mytheme .v-grid-editor-message, .mytheme .v-grid-editor-buttons { + display: table-cell; + white-space: nowrap; + vertical-align: middle; +} + +.mytheme .v-grid-editor-message { + width: 100%; + position: relative; +} + +.mytheme .v-grid-editor-message > div { + position: absolute; + width: 100%; + overflow: hidden; + text-overflow: ellipsis; + line-height: 37px; + top: 0; +} + +.mytheme .v-grid-editor-save { + margin-right: 4px; +} + +.mytheme .v-grid-spacer { + padding-left: 1px; +} + +.mytheme .v-grid-spacer > td { + display: block; + padding: 0; + background-color: white; + border-top: 1px solid #eeeeee; + border-bottom: 1px solid #d4d4d4; +} + +.mytheme .v-grid-spacer.stripe > td { + background-color: #f5f5f5; + border-top: 1px solid #e5e5e5; + border-bottom: 1px solid #d4d4d4; +} + +.mytheme .v-grid-spacer-deco-container { + border-top: 1px solid transparent; + position: relative; + top: 0; + z-index: 5; +} + +.mytheme .v-grid-spacer-deco { + top: 0; + left: 0; + width: 2px; + background-color: #197de1; + position: absolute; + height: 100%; + pointer-events: none; +} + +.ie8 .mytheme .v-grid-spacer-deco:before, .ie9 .mytheme .v-grid-spacer-deco:before, .ie10 .mytheme .v-grid-spacer-deco:before { + content: url(data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==); +} + +.mytheme .v-grid-cell > .v-progressbar { + width: 100%; +} + +.mytheme .v-grid { + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; + background-color: #fafafa; +} + +.mytheme .v-grid.v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-grid-header .v-grid-cell { + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.05); +} + +.mytheme .v-grid-header .v-grid-cell.dragged { + opacity: 0.5; + filter: alpha(opacity=50) ; + -webkit-transition: opacity 0.3s ease-in-out; + -moz-transition: opacity 0.3s ease-in-out; + transition: opacity 0.3s ease-in-out; +} + +.mytheme .v-grid-header .v-grid-cell.dragged-column-header { + margin-top: -19px; +} + +.mytheme .v-grid-footer .v-grid-cell { + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.05); +} + +.mytheme .v-grid-header-deco { + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); +} + +.mytheme .v-grid-footer-deco, .mytheme .v-grid-horizontal-scrollbar-deco { + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); +} + +.mytheme .v-grid-row-selected > .v-grid-cell { + background-color: #197de1; + background-image: -webkit-linear-gradient(top, #1b87e3 2%, #166ed5 98%); + background-image: linear-gradient(to bottom,#1b87e3 2%, #166ed5 98%); + color: #c8dbed; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.05); + border-color: #1d69b4; +} + +.mytheme .v-grid-row-selected > .v-grid-cell-focused:before { + border-color: #71b0ef; +} + +.mytheme .v-grid-editor { + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + border-color: #197de1; +} + +.mytheme .v-grid-editor-footer { + font-size: 14px; + padding: 0 6px; + background: #fafafa; + -webkit-animation: valo-grid-editor-footer-animate-in 200ms 120ms backwards; + -moz-animation: valo-grid-editor-footer-animate-in 200ms 120ms backwards; + animation: valo-grid-editor-footer-animate-in 200ms 120ms backwards; +} + +.mytheme .v-grid-editor-footer:first-child { + -webkit-animation: valo-grid-editor-footer-animate-in-alt 200ms 120ms backwards; + -moz-animation: valo-grid-editor-footer-animate-in-alt 200ms 120ms backwards; + animation: valo-grid-editor-footer-animate-in-alt 200ms 120ms backwards; +} + +.mytheme .v-grid-editor-cells { + z-index: 1; +} + +.mytheme .v-grid-editor-cells > div:before { + content: ""; + display: inline-block; + height: 100%; + vertical-align: middle; +} + +.mytheme .v-grid-editor-cells > div.not-editable.v-grid-cell { + float: none; +} + +.mytheme .v-grid-editor-cells > div .error::before { + border-top: 9px solid #ed473b; + border-right: 9px solid transparent; +} + +.mytheme .v-grid-editor-cells > div .error, .mytheme .v-grid-editor-cells > div .error > input { + background-color: #fffbfb; +} + +.mytheme .v-grid-editor-cells > div .v-textfield, .mytheme .v-grid-editor-cells > div .v-textfield-focus, .mytheme .v-grid-editor-cells > div .v-datefield, .mytheme .v-grid-editor-cells > div .v-datefield .v-textfield-focus, .mytheme .v-grid-editor-cells > div .v-filterselect-input, .mytheme .v-grid-editor-cells > div .v-filterselect-input:focus { + border: none; + border-radius: 0; + background: transparent; + -webkit-box-shadow: inset 0 1px 0 #f2f2f2; + box-shadow: inset 0 1px 0 #f2f2f2; +} + +.mytheme .v-grid-editor-cells > div input[type="text"].v-datefield-textfield { + padding-left: 44.4px; +} + +.v-ie8 .mytheme .v-grid-editor-cells > div .v-datefield-button { + margin-left: 0px; +} + +.v-ie8 .mytheme .v-grid-editor-cells > div .v-filterselect-button { + margin-left: 0px; +} + +.mytheme .v-grid-editor-cells > div .v-textfield-focus, .mytheme .v-grid-editor-cells > div .v-datefield .v-textfield-focus, .mytheme .v-grid-editor-cells > div .v-filterselect-input:focus { + position: relative; +} + +.mytheme .v-grid-editor-cells > div .v-select { + padding-left: 9px; + padding-right: 9px; +} + +.mytheme .v-grid-editor-cells > div .v-checkbox { + margin: 0 9px 0 18px; +} + +.mytheme .v-grid-editor-cells > div .v-checkbox > input[type="checkbox"] { + margin-left: 0; +} + +.mytheme .v-grid-editor-cells > div .v-checkbox > label { + white-space: nowrap; +} + +.mytheme .v-grid-editor-message > div:before { + display: inline-block; + color: #ed473b; + font-weight: 600; + width: 19px; + text-align: center; + content: "!"; +} + +.mytheme .v-grid-editor-save, .mytheme .v-grid-editor-cancel { + cursor: pointer; + color: #197de1; + text-decoration: underline; + font-weight: inherit; + -webkit-transition: color 140ms; + -moz-transition: color 140ms; + transition: color 140ms; + font-weight: 400; + text-decoration: none; + border: none; + background: transparent; + padding: 6px 6px; + margin: 0; + outline: none; +} + +.mytheme .v-grid-editor-save:hover, .mytheme .v-grid-editor-cancel:hover { + color: #4396ea; +} + +.mytheme .v-grid-editor-save.v-disabled, .mytheme .v-grid-editor-cancel.v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-grid-spacer { + margin-top: -1px; +} + +.mytheme .v-grid-sidebar.v-contextmenu.open .v-grid-sidebar-content { + margin: 0 0 2px; + padding: 4px 4px 2px; + overflow-y: auto; + overflow-x: hidden; +} + +.mytheme .v-grid-sidebar.v-contextmenu.closed { + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); +} + +.mytheme .v-grid-scroller::-webkit-scrollbar { + border: none; +} + +.mytheme .v-grid-scroller::-webkit-scrollbar-thumb { + border-radius: 10px; + border: 4px solid transparent; + background: rgba(0, 0, 0, 0.3); + -webkit-background-clip: content-box; + background-clip: content-box; +} + +.mytheme .v-grid-scroller-vertical::-webkit-scrollbar-thumb { + min-height: 30px; +} + +.mytheme .v-grid-scroller-horizontal::-webkit-scrollbar-thumb { + min-width: 30px; +} + +.mytheme .v-textfield { + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; + margin: 0; + font: inherit; + + font-weight: 400; + line-height: normal; + height: 37px; + border-radius: 4px; + padding: 4px 9px; + border: 1px solid #c5c5c5; + background: white; + color: #474747; + -webkit-box-shadow: inset 0 1px 0 #f7f7f7, 0 1px 0 rgba(255, 255, 255, 0.1); + box-shadow: inset 0 1px 0 #f7f7f7, 0 1px 0 rgba(255, 255, 255, 0.1); + -webkit-transition: box-shadow 180ms, border 180ms; + -moz-transition: box-shadow 180ms, border 180ms; + transition: box-shadow 180ms, border 180ms; + width: 185px; +} + +.v-ie8 .mytheme .v-textfield, .v-ie9 .mytheme .v-textfield { + line-height: 37px; + padding-top: 0; + padding-bottom: 0; +} + +.mytheme .v-textfield.v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-textfield:focus { + outline: none; + -webkit-transition: none; + -moz-transition: none; + transition: none; + border-color: #197de1; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 #f7f7f7, 0 1px 0 rgba(255, 255, 255, 0.1); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 #f7f7f7, 0 1px 0 rgba(255, 255, 255, 0.1); + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); +} + +.mytheme .v-textfield[class*="prompt"] { + color: #a3a3a3; +} + +.mytheme .v-textfield-readonly { + background: #fafafa; + color: #464646; + -webkit-box-shadow: none; + box-shadow: none; +} + +.mytheme .v-textfield-readonly:focus { + box-shadow: none; + border-color: #c5c5c5; +} + +.mytheme .v-textfield-error { + border-color: #ed473b !important; + background: #fffbfb; + color: #6c2621; +} + +.mytheme .v-textfield-borderless { + border: none; + border-radius: 0; + background: transparent; + -webkit-box-shadow: none; + box-shadow: none; + color: inherit; +} + +.mytheme .v-textfield-borderless:focus { + -webkit-box-shadow: none; + box-shadow: none; +} + +.mytheme .v-textfield-borderless[class*="prompt"] { + color: inherit; + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-textfield-tiny { + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; + margin: 0; + font: inherit; + + font-weight: 400; + line-height: normal; + height: 28px; + border-radius: 4px; + padding: 3px 7px; + + + -webkit-transition: box-shadow 180ms, border 180ms; + -moz-transition: box-shadow 180ms, border 180ms; + transition: box-shadow 180ms, border 180ms; + font-size: 12px; +} + +.v-ie8 .mytheme .v-textfield-tiny, .v-ie9 .mytheme .v-textfield-tiny { + line-height: 28px; + padding-top: 0; + padding-bottom: 0; +} + +.mytheme .v-textfield-compact, .mytheme .v-textfield-small { + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; + margin: 0; + font: inherit; + + font-weight: 400; + line-height: normal; + height: 31px; + border-radius: 4px; + padding: 3px 8px; + + + -webkit-transition: box-shadow 180ms, border 180ms; + -moz-transition: box-shadow 180ms, border 180ms; + transition: box-shadow 180ms, border 180ms; +} + +.v-ie8 .mytheme .v-textfield-compact, .v-ie9 .mytheme .v-textfield-compact, .v-ie8 .mytheme .v-textfield-small, .v-ie9 .mytheme .v-textfield-small { + line-height: 31px; + padding-top: 0; + padding-bottom: 0; +} + +.mytheme .v-textfield-small { + font-size: 14px; +} + +.mytheme .v-textfield-large { + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; + margin: 0; + font: inherit; + + font-weight: 400; + line-height: normal; + height: 44px; + border-radius: 4px; + padding: 5px 10px; + + + -webkit-transition: box-shadow 180ms, border 180ms; + -moz-transition: box-shadow 180ms, border 180ms; + transition: box-shadow 180ms, border 180ms; + font-size: 20px; +} + +.v-ie8 .mytheme .v-textfield-large, .v-ie9 .mytheme .v-textfield-large { + line-height: 44px; + padding-top: 0; + padding-bottom: 0; +} + +.mytheme .v-textfield-huge { + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; + margin: 0; + font: inherit; + + font-weight: 400; + line-height: normal; + height: 59px; + border-radius: 4px; + padding: 7px 12px; + + + -webkit-transition: box-shadow 180ms, border 180ms; + -moz-transition: box-shadow 180ms, border 180ms; + transition: box-shadow 180ms, border 180ms; + font-size: 26px; +} + +.v-ie8 .mytheme .v-textfield-huge, .v-ie9 .mytheme .v-textfield-huge { + line-height: 59px; + padding-top: 0; + padding-bottom: 0; +} + +.mytheme .v-slot-inline-icon { + position: relative; +} + +.mytheme .v-caption-inline-icon { + padding: 0; +} + +.mytheme .v-caption-inline-icon .v-captiontext { + font-size: 14px; + font-weight: 400; + padding-bottom: 0.3em; + padding-left: 1px; + margin: 0; +} + +.mytheme .v-caption-inline-icon .v-icon { + position: absolute; + z-index: 10; +} + +.mytheme .v-caption-inline-icon span.v-icon { + left: 1px; + bottom: 1px; + width: 37px; + line-height: 35px; + text-align: center; + font-size: 16px; +} + +.mytheme .v-caption-inline-icon img.v-icon { + left: 11px; + bottom: 11px; +} + +.mytheme .v-textfield-inline-icon { + padding-left: 37px; +} + +.mytheme .v-slot-inline-icon.v-slot-tiny { + position: relative; +} + +.mytheme .v-caption-inline-icon.v-caption-tiny { + padding: 0; +} + +.mytheme .v-caption-inline-icon.v-caption-tiny .v-captiontext { + font-size: 14px; + font-weight: 400; + padding-bottom: 0.3em; + padding-left: 1px; + margin: 0; +} + +.mytheme .v-caption-inline-icon.v-caption-tiny .v-icon { + position: absolute; + z-index: 10; +} + +.mytheme .v-caption-inline-icon.v-caption-tiny span.v-icon { + left: 1px; + bottom: 1px; + width: 28px; + line-height: 26px; + text-align: center; + font-size: 12px; +} + +.mytheme .v-caption-inline-icon.v-caption-tiny img.v-icon { + left: 6px; + bottom: 6px; +} + +.mytheme .v-textfield-inline-icon.v-textfield-tiny { + padding-left: 28px; +} + +.mytheme .v-slot-inline-icon.v-slot-compact { + position: relative; +} + +.mytheme .v-caption-inline-icon.v-caption-compact { + padding: 0; +} + +.mytheme .v-caption-inline-icon.v-caption-compact .v-captiontext { + font-size: 14px; + font-weight: 400; + padding-bottom: 0.3em; + padding-left: 1px; + margin: 0; +} + +.mytheme .v-caption-inline-icon.v-caption-compact .v-icon { + position: absolute; + z-index: 10; +} + +.mytheme .v-caption-inline-icon.v-caption-compact span.v-icon { + left: 1px; + bottom: 1px; + width: 31px; + line-height: 29px; + text-align: center; + font-size: 16px; +} + +.mytheme .v-caption-inline-icon.v-caption-compact img.v-icon { + left: 8px; + bottom: 8px; +} + +.mytheme .v-textfield-inline-icon.v-textfield-compact { + padding-left: 31px; +} + +.mytheme .v-slot-inline-icon.v-slot-small { + position: relative; +} + +.mytheme .v-caption-inline-icon.v-caption-small { + padding: 0; +} + +.mytheme .v-caption-inline-icon.v-caption-small .v-captiontext { + font-size: 14px; + font-weight: 400; + padding-bottom: 0.3em; + padding-left: 1px; + margin: 0; +} + +.mytheme .v-caption-inline-icon.v-caption-small .v-icon { + position: absolute; + z-index: 10; +} + +.mytheme .v-caption-inline-icon.v-caption-small span.v-icon { + left: 1px; + bottom: 1px; + width: 31px; + line-height: 29px; + text-align: center; + font-size: 14px; +} + +.mytheme .v-caption-inline-icon.v-caption-small img.v-icon { + left: 8px; + bottom: 8px; +} + +.mytheme .v-textfield-inline-icon.v-textfield-small { + padding-left: 31px; +} + +.mytheme .v-slot-inline-icon.v-slot-large { + position: relative; +} + +.mytheme .v-caption-inline-icon.v-caption-large { + padding: 0; +} + +.mytheme .v-caption-inline-icon.v-caption-large .v-captiontext { + font-size: 14px; + font-weight: 400; + padding-bottom: 0.3em; + padding-left: 1px; + margin: 0; +} + +.mytheme .v-caption-inline-icon.v-caption-large .v-icon { + position: absolute; + z-index: 10; +} + +.mytheme .v-caption-inline-icon.v-caption-large span.v-icon { + left: 1px; + bottom: 1px; + width: 44px; + line-height: 42px; + text-align: center; + font-size: 20px; +} + +.mytheme .v-caption-inline-icon.v-caption-large img.v-icon { + left: 14px; + bottom: 14px; +} + +.mytheme .v-textfield-inline-icon.v-textfield-large { + padding-left: 44px; +} + +.mytheme .v-slot-inline-icon.v-slot-huge { + position: relative; +} + +.mytheme .v-caption-inline-icon.v-caption-huge { + padding: 0; +} + +.mytheme .v-caption-inline-icon.v-caption-huge .v-captiontext { + font-size: 14px; + font-weight: 400; + padding-bottom: 0.3em; + padding-left: 1px; + margin: 0; +} + +.mytheme .v-caption-inline-icon.v-caption-huge .v-icon { + position: absolute; + z-index: 10; +} + +.mytheme .v-caption-inline-icon.v-caption-huge span.v-icon { + left: 1px; + bottom: 1px; + width: 59px; + line-height: 57px; + text-align: center; + font-size: 26px; +} + +.mytheme .v-caption-inline-icon.v-caption-huge img.v-icon { + left: 22px; + bottom: 22px; +} + +.mytheme .v-textfield-inline-icon.v-textfield-huge { + padding-left: 59px; +} + +.mytheme .v-textfield-align-right { + text-align: right; +} + +.mytheme .v-textfield-align-center { + text-align: center; +} + +.mytheme .v-textarea { + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; + margin: 0; + font: inherit; + + font-weight: 400; + line-height: normal; + height: 37px; + border-radius: 4px; + padding: 6px; + border: 1px solid #c5c5c5; + background: white; + color: #474747; + -webkit-box-shadow: inset 0 1px 0 #f7f7f7, 0 1px 0 rgba(255, 255, 255, 0.1); + box-shadow: inset 0 1px 0 #f7f7f7, 0 1px 0 rgba(255, 255, 255, 0.1); + -webkit-transition: box-shadow 180ms, border 180ms; + -moz-transition: box-shadow 180ms, border 180ms; + transition: box-shadow 180ms, border 180ms; + height: auto; + resize: none; + white-space: pre-wrap; + width: 185px; +} + +.v-ie8 .mytheme .v-textarea, .v-ie9 .mytheme .v-textarea { + line-height: 37px; + padding-top: 0; + padding-bottom: 0; +} + +.mytheme .v-textarea.v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-textarea:focus { + outline: none; + -webkit-transition: none; + -moz-transition: none; + transition: none; + border-color: #197de1; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 #f7f7f7, 0 1px 0 rgba(255, 255, 255, 0.1); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 #f7f7f7, 0 1px 0 rgba(255, 255, 255, 0.1); + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); +} + +.mytheme .v-textarea[class*="prompt"] { + color: #a3a3a3; +} + +.v-ie8 .mytheme .v-textarea, .v-ie9 .mytheme .v-textarea { + line-height: inherit; + padding-top: 4px; + padding-bottom: 4px; +} + +.mytheme .v-textarea-readonly { + background: #fafafa; + color: #464646; + -webkit-box-shadow: none; + box-shadow: none; +} + +.mytheme .v-textarea-readonly:focus { + box-shadow: none; + border-color: #c5c5c5; +} + +.mytheme .v-textarea-error { + border-color: #ed473b !important; + background: #fffbfb; + color: #6c2621; +} + +.mytheme .v-textarea-borderless { + border: none; + border-radius: 0; + background: transparent; + -webkit-box-shadow: none; + box-shadow: none; + color: inherit; +} + +.mytheme .v-textarea-borderless:focus { + -webkit-box-shadow: none; + box-shadow: none; +} + +.mytheme .v-textarea-borderless[class*="prompt"] { + color: inherit; + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-textarea-tiny { + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; + margin: 0; + font: inherit; + + font-weight: 400; + line-height: normal; + height: 28px; + border-radius: 4px; + padding: 6px; + + + + -webkit-transition: box-shadow 180ms, border 180ms; + -moz-transition: box-shadow 180ms, border 180ms; + transition: box-shadow 180ms, border 180ms; + height: auto; + resize: none; + white-space: pre-wrap; + font-size: 12px; +} + +.v-ie8 .mytheme .v-textarea-tiny, .v-ie9 .mytheme .v-textarea-tiny { + line-height: 28px; + padding-top: 0; + padding-bottom: 0; +} + +.v-ie8 .mytheme .v-textarea-tiny, .v-ie9 .mytheme .v-textarea-tiny { + line-height: inherit; + padding-top: 3px; + padding-bottom: 3px; +} + +.mytheme .v-textarea-small { + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; + margin: 0; + font: inherit; + + font-weight: 400; + line-height: normal; + height: 31px; + border-radius: 4px; + padding: 6px; + + + + -webkit-transition: box-shadow 180ms, border 180ms; + -moz-transition: box-shadow 180ms, border 180ms; + transition: box-shadow 180ms, border 180ms; + height: auto; + resize: none; + white-space: pre-wrap; + font-size: 14px; +} + +.v-ie8 .mytheme .v-textarea-small, .v-ie9 .mytheme .v-textarea-small { + line-height: 31px; + padding-top: 0; + padding-bottom: 0; +} + +.v-ie8 .mytheme .v-textarea-small, .v-ie9 .mytheme .v-textarea-small { + line-height: inherit; + padding-top: 3px; + padding-bottom: 3px; +} + +.mytheme .v-textarea-large { + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; + margin: 0; + font: inherit; + + font-weight: 400; + line-height: normal; + height: 44px; + border-radius: 4px; + padding: 6px; + + + + -webkit-transition: box-shadow 180ms, border 180ms; + -moz-transition: box-shadow 180ms, border 180ms; + transition: box-shadow 180ms, border 180ms; + height: auto; + resize: none; + white-space: pre-wrap; + font-size: 20px; +} + +.v-ie8 .mytheme .v-textarea-large, .v-ie9 .mytheme .v-textarea-large { + line-height: 44px; + padding-top: 0; + padding-bottom: 0; +} + +.v-ie8 .mytheme .v-textarea-large, .v-ie9 .mytheme .v-textarea-large { + line-height: inherit; + padding-top: 5px; + padding-bottom: 5px; +} + +.mytheme .v-textarea-huge { + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; + margin: 0; + font: inherit; + + font-weight: 400; + line-height: normal; + height: 59px; + border-radius: 4px; + padding: 6px; + + + + -webkit-transition: box-shadow 180ms, border 180ms; + -moz-transition: box-shadow 180ms, border 180ms; + transition: box-shadow 180ms, border 180ms; + height: auto; + resize: none; + white-space: pre-wrap; + font-size: 26px; +} + +.v-ie8 .mytheme .v-textarea-huge, .v-ie9 .mytheme .v-textarea-huge { + line-height: 59px; + padding-top: 0; + padding-bottom: 0; +} + +.v-ie8 .mytheme .v-textarea-huge, .v-ie9 .mytheme .v-textarea-huge { + line-height: inherit; + padding-top: 7px; + padding-bottom: 7px; +} + +.mytheme .v-textarea-align-right { + text-align: right; +} + +.mytheme .v-textarea-align-center { + text-align: center; +} + +.mytheme .v-datefield { + position: relative; + width: 185px; + height: 37px; + border-radius: 4px; +} + +.mytheme .v-datefield [class*="textfield"] { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; + margin: 0; + font: inherit; + + font-weight: 400; + line-height: normal; + height: 37px; + border-radius: 4px; + padding: 4px 9px; + border: 1px solid #c5c5c5; + background: white; + color: #474747; + -webkit-box-shadow: inset 0 1px 0 #f7f7f7, 0 1px 0 rgba(255, 255, 255, 0.1); + box-shadow: inset 0 1px 0 #f7f7f7, 0 1px 0 rgba(255, 255, 255, 0.1); + -webkit-transition: box-shadow 180ms, border 180ms; + -moz-transition: box-shadow 180ms, border 180ms; + transition: box-shadow 180ms, border 180ms; + padding-left: 44.4px; + width: 100%; + height: 100%; + border-radius: inherit; +} + +.v-ie8 .mytheme .v-datefield [class*="textfield"], .v-ie9 .mytheme .v-datefield [class*="textfield"] { + line-height: 37px; + padding-top: 0; + padding-bottom: 0; +} + +.mytheme .v-datefield [class*="textfield"].v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-datefield [class*="textfield"]:focus { + outline: none; + -webkit-transition: none; + -moz-transition: none; + transition: none; + border-color: #197de1; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 #f7f7f7, 0 1px 0 rgba(255, 255, 255, 0.1); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 #f7f7f7, 0 1px 0 rgba(255, 255, 255, 0.1); + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); +} + +.mytheme .v-datefield [class*="textfield"][class*="prompt"] { + color: #a3a3a3; +} + +.mytheme .v-datefield[class*="prompt"] > [class*="textfield"] { + color: #a3a3a3; +} + +.mytheme .v-datefield [class*="button"] { + -webkit-tap-highlight-color: transparent; + -webkit-touch-callout: none; + cursor: pointer; + -webkit-appearance: none; + background: transparent; + padding: 0; + position: absolute; + z-index: 10; + width: 37px; + line-height: 35px; + text-align: center; + font: inherit; + outline: none; + margin: 0; + top: 1px; + bottom: 1px; + left: 1px; + border: none; + border-right: 1px solid #e4e4e4; + color: #a3a3a3; + border-radius: 3px 0 0 3px; +} + +.mytheme .v-datefield [class*="button"]:hover { + color: #474747; +} + +.mytheme .v-datefield [class*="button"]:before { + font-family: ThemeIcons; + content: "\f073"; + -webkit-transition: color 140ms; + -moz-transition: color 140ms; + transition: color 140ms; +} + +.mytheme .v-datefield [class*="button"]:active:after { + content: ""; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + background-color: rgba(128, 128, 128, 0.2); + border-radius: inherit; +} + +.mytheme .v-datefield.v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-datefield.v-disabled [class*="button"] { + cursor: default; + pointer-events: none; +} + +.mytheme .v-datefield.v-disabled [class*="button"]:active:after { + display: none; +} + +.mytheme .v-datefield.v-readonly [class*="textfield"] { + background: #fafafa; + color: #464646; + -webkit-box-shadow: none; + box-shadow: none; +} + +.mytheme .v-datefield.v-readonly [class*="textfield"]:focus { + box-shadow: none; + border-color: #c5c5c5; +} + +.mytheme .v-datefield.v-readonly [class*="button"] { + cursor: default; + pointer-events: none; +} + +.mytheme .v-datefield.v-readonly [class*="button"]:active:after { + display: none; +} + +.mytheme .v-datefield-error .v-datefield-textfield { + border-color: #ed473b !important; + background: #fffbfb; + color: #6c2621; +} + +.mytheme .v-datefield-error .v-datefield-button { + color: #ed473b; + border-color: #ed473b; +} + +.mytheme .v-datefield-full { + width: 240px; +} + +.mytheme .v-datefield-day { + width: 185px; +} + +.mytheme .v-datefield-month { + width: 120px; +} + +.mytheme .v-datefield-year { + width: 104px; +} + +.mytheme .v-datefield-popup { + padding: 4px 4px; + border-radius: 4px; + background-color: white; + color: #474747; + -webkit-box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.1), 0 3px 5px 0 rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.09098); + box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.1), 0 3px 5px 0 rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.09098); + -webkit-backface-visibility: hidden; + -moz-backface-visibility: hidden; + -ms-backface-visibility: hidden; + backface-visibility: hidden; + margin-top: 5px !important; + margin-bottom: 5px !important; + margin-right: 5px !important; + cursor: default; + width: auto; +} + +.mytheme .v-datefield-popup[class*="animate-in"] { + -webkit-animation: valo-overlay-animate-in 120ms; + -moz-animation: valo-overlay-animate-in 120ms; + animation: valo-overlay-animate-in 120ms; +} + +.mytheme .v-datefield-popup[class*="animate-out"] { + -webkit-animation: valo-animate-out-fade 120ms; + -moz-animation: valo-animate-out-fade 120ms; + animation: valo-animate-out-fade 120ms; +} + +.mytheme .v-datefield-popup table { + border-collapse: collapse; + border-spacing: 0; + margin: 0 auto; +} + +.mytheme .v-datefield-popup td { + padding: 2px; +} + +.mytheme .v-datefield-popup .v-datefield-calendarpanel { + font-size: 16px; + text-align: center; +} + +.mytheme .v-datefield-popup .v-datefield-calendarpanel:focus { + outline: none; +} + +.mytheme .v-datefield-popup .v-datefield-calendarpanel-day { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + width: 30px; + height: 26px; + border: 1px solid transparent; + line-height: 26px; + text-align: center; + font-size: 14px; + background: #fafafa; + border-radius: 2px; + -webkit-transition: color 200ms; + -moz-transition: color 200ms; + transition: color 200ms; + display: inline-block; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + cursor: pointer; +} + +.mytheme .v-datefield-popup .v-datefield-calendarpanel-day:hover { + color: #197de1; +} + +.mytheme .v-datefield-popup .v-datefield-calendarpanel-day-offmonth { + color: #a0a0a0; + background: transparent; +} + +.mytheme .v-datefield-popup .v-datefield-calendarpanel-day-today { + color: #191919; + font-weight: 600; + border-color: #afafaf; +} + +.mytheme .v-datefield-popup .v-datefield-calendarpanel-day.v-datefield-calendarpanel-day-selected, .mytheme .v-datefield-popup .v-datefield-calendarpanel-day.v-datefield-calendarpanel-day-selected:hover { + color: #c8dbed; + background-color: #197de1; + background-image: -webkit-linear-gradient(top, #1b87e3 2%, #166ed5 98%); + background-image: linear-gradient(to bottom,#1b87e3 2%, #166ed5 98%); + border: none; + font-weight: 600; +} + +.mytheme .v-datefield-popup .v-datefield-calendarpanel-day.v-datefield-calendarpanel-day-focused { + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + position: relative; +} + +.v-ie8 .mytheme .v-datefield-popup .v-datefield-calendarpanel-day.v-datefield-calendarpanel-day-focused { + border-color: #197de1; +} + +.mytheme .v-datefield-popup .v-datefield-calendarpanel-day.v-datefield-calendarpanel-day-outside-range, .mytheme .v-datefield-popup .v-datefield-calendarpanel-day.v-datefield-calendarpanel-day-outside-range:hover { + color: #a0a0a0; + cursor: not-allowed; +} + +.mytheme .v-datefield-popup .v-datefield-calendarpanel-weekdays { + height: 26px; + color: rgba(133, 133, 133, 0.85); +} + +.mytheme .v-datefield-popup .v-datefield-calendarpanel-weekdays strong { + font: inherit; + font-size: 14px; +} + +.mytheme .v-datefield-popup .v-datefield-calendarpanel-header { + white-space: nowrap; +} + +.mytheme .v-datefield-popup td[class*="year"] button, .mytheme .v-datefield-popup td[class*="month"] button { + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + border: none; + background: transparent; + padding: 0; + margin: 0; + cursor: pointer; + color: transparent; + font-size: 0; + width: 19px; + height: 25px; + outline: none; + position: relative; + vertical-align: middle; +} + +.mytheme .v-datefield-popup td[class*="year"] button:before, .mytheme .v-datefield-popup td[class*="month"] button:before { + color: #a0a0a0; + font-size: 21px; + line-height: 24px; + -webkit-transition: color 200ms; + -moz-transition: color 200ms; + transition: color 200ms; +} + +.mytheme .v-datefield-popup td[class*="year"] button:hover:before, .mytheme .v-datefield-popup td[class*="month"] button:hover:before { + color: #197de1; +} + +.mytheme .v-datefield-popup td[class*="year"] button.outside-range, .mytheme .v-datefield-popup td[class*="month"] button.outside-range { + cursor: default; + opacity: 0.3; + filter: alpha(opacity=30.0) ; +} + +.mytheme .v-datefield-popup td[class*="year"] button.outside-range:hover:before, .mytheme .v-datefield-popup td[class*="month"] button.outside-range:hover:before { + color: #a0a0a0; +} + +.mytheme .v-datefield-popup .v-button-prevyear:before { + font-family: ThemeIcons; + content: "\f100"; +} + +.mytheme .v-datefield-popup .v-button-prevmonth:before { + font-family: ThemeIcons; + content: "\f104"; +} + +.mytheme .v-datefield-popup .v-button-nextyear:before { + font-family: ThemeIcons; + content: "\f101"; +} + +.mytheme .v-datefield-popup .v-button-nextmonth:before { + font-family: ThemeIcons; + content: "\f105"; +} + +.mytheme .v-datefield-popup td.v-datefield-calendarpanel-month { + width: 148px; + color: #197de1; +} + +.mytheme .v-datefield-popup .v-datefield-calendarpanel-year td.v-datefield-calendarpanel-month { + width: 74px; +} + +.mytheme .v-datefield-popup .v-datefield-calendarpanel-weeknumber, .mytheme .v-datefield-popup .v-datefield-calendarpanel-weekdays.v-datefield-calendarpanel-weeknumbers td:first-child { + width: 30px; + color: rgba(133, 133, 133, 0.85); + font-size: 14px; + display: inline-block; + text-align: left; +} + +.mytheme .v-datefield-popup .v-datefield-calendarpanel-weeknumber { + position: relative; +} + +.mytheme .v-datefield-popup .v-datefield-calendarpanel-weeknumbers .v-first:before { + content: ""; + position: absolute; + top: 38px; + bottom: 0; + left: 0; + width: 34px; + border-top: 1px solid #eaeaea; + border-right: 1px solid #eaeaea; + border-top-right-radius: 4px; + border-bottom-left-radius: 4px; + background: #fafafa; +} + +.mytheme .v-datefield-popup td.v-datefield-calendarpanel-time { + width: 100%; + font-size: 14px; +} + +.mytheme .v-datefield-popup td.v-datefield-calendarpanel-time .v-label { + display: inline; + margin: 0 0.1em; + font-weight: 400; +} + +.mytheme .v-datefield-calendarpanel { + font-size: 16px; + text-align: center; +} + +.mytheme .v-datefield-calendarpanel:focus { + outline: none; +} + +.mytheme .v-datefield-calendarpanel-day { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + width: 30px; + height: 26px; + border: 1px solid transparent; + line-height: 26px; + text-align: center; + font-size: 14px; + background: #fafafa; + border-radius: 2px; + -webkit-transition: color 200ms; + -moz-transition: color 200ms; + transition: color 200ms; + display: inline-block; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + cursor: pointer; +} + +.mytheme .v-datefield-calendarpanel-day:hover { + color: #197de1; +} + +.mytheme .v-datefield-calendarpanel-day-offmonth { + color: #a0a0a0; + background: transparent; +} + +.mytheme .v-datefield-calendarpanel-day-today { + color: #191919; + font-weight: 600; + border-color: #afafaf; +} + +.mytheme .v-datefield-calendarpanel-day.v-datefield-calendarpanel-day-selected, .mytheme .v-datefield-calendarpanel-day.v-datefield-calendarpanel-day-selected:hover { + color: #c8dbed; + background-color: #197de1; + background-image: -webkit-linear-gradient(top, #1b87e3 2%, #166ed5 98%); + background-image: linear-gradient(to bottom,#1b87e3 2%, #166ed5 98%); + border: none; + font-weight: 600; +} + +.mytheme .v-datefield-calendarpanel-day.v-datefield-calendarpanel-day-focused { + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + position: relative; +} + +.v-ie8 .mytheme .v-datefield-calendarpanel-day.v-datefield-calendarpanel-day-focused { + border-color: #197de1; +} + +.mytheme .v-datefield-calendarpanel-day.v-datefield-calendarpanel-day-outside-range, .mytheme .v-datefield-calendarpanel-day.v-datefield-calendarpanel-day-outside-range:hover { + color: #a0a0a0; + cursor: not-allowed; +} + +.mytheme .v-datefield-calendarpanel-weekdays { + height: 26px; + color: rgba(133, 133, 133, 0.85); +} + +.mytheme .v-datefield-calendarpanel-weekdays strong { + font: inherit; + font-size: 14px; +} + +.mytheme .v-datefield-calendarpanel-header { + white-space: nowrap; +} + +.mytheme td[class*="year"] button, .mytheme td[class*="month"] button { + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + border: none; + background: transparent; + padding: 0; + margin: 0; + cursor: pointer; + color: transparent; + font-size: 0; + width: 19px; + height: 25px; + outline: none; + position: relative; + vertical-align: middle; +} + +.mytheme td[class*="year"] button:before, .mytheme td[class*="month"] button:before { + color: #a0a0a0; + font-size: 21px; + line-height: 24px; + -webkit-transition: color 200ms; + -moz-transition: color 200ms; + transition: color 200ms; +} + +.mytheme td[class*="year"] button:hover:before, .mytheme td[class*="month"] button:hover:before { + color: #197de1; +} + +.mytheme td[class*="year"] button.outside-range, .mytheme td[class*="month"] button.outside-range { + cursor: default; + opacity: 0.3; + filter: alpha(opacity=30.0) ; +} + +.mytheme td[class*="year"] button.outside-range:hover:before, .mytheme td[class*="month"] button.outside-range:hover:before { + color: #a0a0a0; +} + +.mytheme .v-button-prevyear:before { + font-family: ThemeIcons; + content: "\f100"; +} + +.mytheme .v-button-prevmonth:before { + font-family: ThemeIcons; + content: "\f104"; +} + +.mytheme .v-button-nextyear:before { + font-family: ThemeIcons; + content: "\f101"; +} + +.mytheme .v-button-nextmonth:before { + font-family: ThemeIcons; + content: "\f105"; +} + +.mytheme td.v-datefield-calendarpanel-month { + width: 148px; + color: #197de1; +} + +.mytheme .v-datefield-calendarpanel-year td.v-datefield-calendarpanel-month { + width: 74px; +} + +.mytheme .v-datefield-calendarpanel-weeknumber, .mytheme .v-datefield-calendarpanel-weekdays.v-datefield-calendarpanel-weeknumbers td:first-child { + width: 30px; + color: rgba(133, 133, 133, 0.85); + font-size: 14px; + display: inline-block; + text-align: left; +} + +.mytheme .v-datefield-calendarpanel-weeknumber { + position: relative; +} + +.mytheme .v-datefield-calendarpanel-weeknumbers .v-first:before { + content: ""; + position: absolute; + top: 38px; + bottom: 0; + left: 0; + width: 34px; + border-top: 1px solid #eaeaea; + border-right: 1px solid #eaeaea; + border-top-right-radius: 4px; + border-bottom-left-radius: 4px; + background: #fafafa; +} + +.mytheme td.v-datefield-calendarpanel-time { + width: 100%; + font-size: 14px; +} + +.mytheme td.v-datefield-calendarpanel-time .v-label { + display: inline; + margin: 0 0.1em; + font-weight: 400; +} + +.mytheme .v-datefield-borderless .v-datefield-textfield { + border: none; + border-radius: 0; + background: transparent; + -webkit-box-shadow: none; + box-shadow: none; + color: inherit; +} + +.mytheme .v-datefield-borderless .v-datefield-textfield:focus { + -webkit-box-shadow: none; + box-shadow: none; +} + +.mytheme .v-datefield-borderless .v-datefield-textfield[class*="prompt"] { + color: inherit; + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-datefield-borderless .v-datefield-button { + border: none; + color: inherit; + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-datefield-align-right input { + text-align: right; +} + +.mytheme .v-datefield-align-center input { + text-align: center; +} + +.mytheme .v-datefield-tiny { + height: 28px; + border-radius: 4px; + font-size: 12px; +} + +.mytheme .v-datefield-tiny [class*="textfield"] { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; + margin: 0; + font: inherit; + + font-weight: 400; + line-height: normal; + height: 28px; + border-radius: 4px; + padding: 3px 7px; + + + + -webkit-transition: box-shadow 180ms, border 180ms; + -moz-transition: box-shadow 180ms, border 180ms; + transition: box-shadow 180ms, border 180ms; + padding-left: 33.6px; + width: 100%; + height: 100%; + border-radius: inherit; +} + +.v-ie8 .mytheme .v-datefield-tiny [class*="textfield"], .v-ie9 .mytheme .v-datefield-tiny [class*="textfield"] { + line-height: 28px; + padding-top: 0; + padding-bottom: 0; +} + +.mytheme .v-datefield-tiny [class*="button"] { + -webkit-tap-highlight-color: transparent; + -webkit-touch-callout: none; + cursor: pointer; + -webkit-appearance: none; + background: transparent; + padding: 0; + position: absolute; + z-index: 10; + width: 28px; + line-height: 28px; + text-align: center; + font: inherit; + outline: none; + margin: 0; + border-radius: 4px 0 0 4px; +} + +.mytheme .v-datefield-tiny [class*="button"]:before { + font-family: ThemeIcons; + content: "\f073"; + -webkit-transition: color 140ms; + -moz-transition: color 140ms; + transition: color 140ms; +} + +.mytheme .v-datefield-tiny [class*="button"]:active:after { + content: ""; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + border-radius: inherit; +} + +.mytheme .v-datefield-tiny.v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-datefield-tiny.v-disabled [class*="button"] { + cursor: default; + pointer-events: none; +} + +.mytheme .v-datefield-tiny.v-disabled [class*="button"]:active:after { + display: none; +} + +.mytheme .v-datefield-tiny.v-readonly [class*="textfield"] { + background: #fafafa; + color: #464646; + -webkit-box-shadow: none; + box-shadow: none; +} + +.mytheme .v-datefield-tiny.v-readonly [class*="textfield"]:focus { + box-shadow: none; + border-color: #c5c5c5; +} + +.mytheme .v-datefield-tiny.v-readonly [class*="button"] { + cursor: default; + pointer-events: none; +} + +.mytheme .v-datefield-tiny.v-readonly [class*="button"]:active:after { + display: none; +} + +.mytheme .v-datefield-compact, .mytheme .v-datefield-small { + height: 31px; + border-radius: 4px; +} + +.mytheme .v-datefield-compact [class*="textfield"], .mytheme .v-datefield-small [class*="textfield"] { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; + margin: 0; + font: inherit; + + font-weight: 400; + line-height: normal; + height: 31px; + border-radius: 4px; + padding: 3px 8px; + + + + -webkit-transition: box-shadow 180ms, border 180ms; + -moz-transition: box-shadow 180ms, border 180ms; + transition: box-shadow 180ms, border 180ms; + padding-left: 37.2px; + width: 100%; + height: 100%; + border-radius: inherit; +} + +.v-ie8 .mytheme .v-datefield-compact [class*="textfield"], .v-ie9 .mytheme .v-datefield-compact [class*="textfield"], .v-ie8 .mytheme .v-datefield-small [class*="textfield"], .v-ie9 .mytheme .v-datefield-small [class*="textfield"] { + line-height: 31px; + padding-top: 0; + padding-bottom: 0; +} + +.mytheme .v-datefield-compact [class*="button"], .mytheme .v-datefield-small [class*="button"] { + -webkit-tap-highlight-color: transparent; + -webkit-touch-callout: none; + cursor: pointer; + -webkit-appearance: none; + background: transparent; + padding: 0; + position: absolute; + z-index: 10; + width: 31px; + line-height: 31px; + text-align: center; + font: inherit; + outline: none; + margin: 0; + border-radius: 4px 0 0 4px; +} + +.mytheme .v-datefield-compact [class*="button"]:before, .mytheme .v-datefield-small [class*="button"]:before { + font-family: ThemeIcons; + content: "\f073"; + -webkit-transition: color 140ms; + -moz-transition: color 140ms; + transition: color 140ms; +} + +.mytheme .v-datefield-compact [class*="button"]:active:after, .mytheme .v-datefield-small [class*="button"]:active:after { + content: ""; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + border-radius: inherit; +} + +.mytheme .v-datefield-compact.v-disabled, .mytheme .v-datefield-small.v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-datefield-compact.v-disabled [class*="button"], .mytheme .v-datefield-small.v-disabled [class*="button"] { + cursor: default; + pointer-events: none; +} + +.mytheme .v-datefield-compact.v-disabled [class*="button"]:active:after, .mytheme .v-datefield-small.v-disabled [class*="button"]:active:after { + display: none; +} + +.mytheme .v-datefield-compact.v-readonly [class*="textfield"], .mytheme .v-datefield-small.v-readonly [class*="textfield"] { + background: #fafafa; + color: #464646; + -webkit-box-shadow: none; + box-shadow: none; +} + +.mytheme .v-datefield-compact.v-readonly [class*="textfield"]:focus, .mytheme .v-datefield-small.v-readonly [class*="textfield"]:focus { + box-shadow: none; + border-color: #c5c5c5; +} + +.mytheme .v-datefield-compact.v-readonly [class*="button"], .mytheme .v-datefield-small.v-readonly [class*="button"] { + cursor: default; + pointer-events: none; +} + +.mytheme .v-datefield-compact.v-readonly [class*="button"]:active:after, .mytheme .v-datefield-small.v-readonly [class*="button"]:active:after { + display: none; +} + +.mytheme .v-datefield-small { + font-size: 14px; +} + +.mytheme .v-datefield-large { + height: 44px; + border-radius: 4px; + font-size: 20px; +} + +.mytheme .v-datefield-large [class*="textfield"] { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; + margin: 0; + font: inherit; + + font-weight: 400; + line-height: normal; + height: 44px; + border-radius: 4px; + padding: 5px 10px; + + + + -webkit-transition: box-shadow 180ms, border 180ms; + -moz-transition: box-shadow 180ms, border 180ms; + transition: box-shadow 180ms, border 180ms; + padding-left: 52.8px; + width: 100%; + height: 100%; + border-radius: inherit; +} + +.v-ie8 .mytheme .v-datefield-large [class*="textfield"], .v-ie9 .mytheme .v-datefield-large [class*="textfield"] { + line-height: 44px; + padding-top: 0; + padding-bottom: 0; +} + +.mytheme .v-datefield-large [class*="button"] { + -webkit-tap-highlight-color: transparent; + -webkit-touch-callout: none; + cursor: pointer; + -webkit-appearance: none; + background: transparent; + padding: 0; + position: absolute; + z-index: 10; + width: 44px; + line-height: 44px; + text-align: center; + font: inherit; + outline: none; + margin: 0; + border-radius: 4px 0 0 4px; +} + +.mytheme .v-datefield-large [class*="button"]:before { + font-family: ThemeIcons; + content: "\f073"; + -webkit-transition: color 140ms; + -moz-transition: color 140ms; + transition: color 140ms; +} + +.mytheme .v-datefield-large [class*="button"]:active:after { + content: ""; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + border-radius: inherit; +} + +.mytheme .v-datefield-large.v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-datefield-large.v-disabled [class*="button"] { + cursor: default; + pointer-events: none; +} + +.mytheme .v-datefield-large.v-disabled [class*="button"]:active:after { + display: none; +} + +.mytheme .v-datefield-large.v-readonly [class*="textfield"] { + background: #fafafa; + color: #464646; + -webkit-box-shadow: none; + box-shadow: none; +} + +.mytheme .v-datefield-large.v-readonly [class*="textfield"]:focus { + box-shadow: none; + border-color: #c5c5c5; +} + +.mytheme .v-datefield-large.v-readonly [class*="button"] { + cursor: default; + pointer-events: none; +} + +.mytheme .v-datefield-large.v-readonly [class*="button"]:active:after { + display: none; +} + +.mytheme .v-datefield-huge { + height: 59px; + border-radius: 4px; + font-size: 26px; +} + +.mytheme .v-datefield-huge [class*="textfield"] { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; + margin: 0; + font: inherit; + + font-weight: 400; + line-height: normal; + height: 59px; + border-radius: 4px; + padding: 7px 12px; + + + + -webkit-transition: box-shadow 180ms, border 180ms; + -moz-transition: box-shadow 180ms, border 180ms; + transition: box-shadow 180ms, border 180ms; + padding-left: 70.8px; + width: 100%; + height: 100%; + border-radius: inherit; +} + +.v-ie8 .mytheme .v-datefield-huge [class*="textfield"], .v-ie9 .mytheme .v-datefield-huge [class*="textfield"] { + line-height: 59px; + padding-top: 0; + padding-bottom: 0; +} + +.mytheme .v-datefield-huge [class*="button"] { + -webkit-tap-highlight-color: transparent; + -webkit-touch-callout: none; + cursor: pointer; + -webkit-appearance: none; + background: transparent; + padding: 0; + position: absolute; + z-index: 10; + width: 59px; + line-height: 59px; + text-align: center; + font: inherit; + outline: none; + margin: 0; + border-radius: 4px 0 0 4px; +} + +.mytheme .v-datefield-huge [class*="button"]:before { + font-family: ThemeIcons; + content: "\f073"; + -webkit-transition: color 140ms; + -moz-transition: color 140ms; + transition: color 140ms; +} + +.mytheme .v-datefield-huge [class*="button"]:active:after { + content: ""; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + border-radius: inherit; +} + +.mytheme .v-datefield-huge.v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-datefield-huge.v-disabled [class*="button"] { + cursor: default; + pointer-events: none; +} + +.mytheme .v-datefield-huge.v-disabled [class*="button"]:active:after { + display: none; +} + +.mytheme .v-datefield-huge.v-readonly [class*="textfield"] { + background: #fafafa; + color: #464646; + -webkit-box-shadow: none; + box-shadow: none; +} + +.mytheme .v-datefield-huge.v-readonly [class*="textfield"]:focus { + box-shadow: none; + border-color: #c5c5c5; +} + +.mytheme .v-datefield-huge.v-readonly [class*="button"] { + cursor: default; + pointer-events: none; +} + +.mytheme .v-datefield-huge.v-readonly [class*="button"]:active:after { + display: none; +} + +.mytheme .v-inline-datefield-calendarpanel { + font-size: 16px; + text-align: center; +} + +.mytheme .v-inline-datefield-calendarpanel:focus { + outline: none; +} + +.mytheme .v-inline-datefield-calendarpanel-day { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + width: 30px; + height: 26px; + border: 1px solid transparent; + line-height: 26px; + text-align: center; + font-size: 14px; + background: #fafafa; + border-radius: 2px; + -webkit-transition: color 200ms; + -moz-transition: color 200ms; + transition: color 200ms; + display: inline-block; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + cursor: pointer; +} + +.mytheme .v-inline-datefield-calendarpanel-day:hover { + color: #197de1; +} + +.mytheme .v-inline-datefield-calendarpanel-day-offmonth { + color: #a0a0a0; + background: transparent; +} + +.mytheme .v-inline-datefield-calendarpanel-day-today { + color: #191919; + font-weight: 600; + border-color: #afafaf; +} + +.mytheme .v-inline-datefield-calendarpanel-day.v-inline-datefield-calendarpanel-day-selected, .mytheme .v-inline-datefield-calendarpanel-day.v-inline-datefield-calendarpanel-day-selected:hover { + color: #c8dbed; + background-color: #197de1; + background-image: -webkit-linear-gradient(top, #1b87e3 2%, #166ed5 98%); + background-image: linear-gradient(to bottom,#1b87e3 2%, #166ed5 98%); + border: none; + font-weight: 600; +} + +.mytheme .v-inline-datefield-calendarpanel-day.v-inline-datefield-calendarpanel-day-focused { + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + position: relative; +} + +.v-ie8 .mytheme .v-inline-datefield-calendarpanel-day.v-inline-datefield-calendarpanel-day-focused { + border-color: #197de1; +} + +.mytheme .v-inline-datefield-calendarpanel-day.v-inline-datefield-calendarpanel-day-outside-range, .mytheme .v-inline-datefield-calendarpanel-day.v-inline-datefield-calendarpanel-day-outside-range:hover { + color: #a0a0a0; + cursor: not-allowed; +} + +.mytheme .v-inline-datefield-calendarpanel-weekdays { + height: 26px; + color: rgba(133, 133, 133, 0.85); +} + +.mytheme .v-inline-datefield-calendarpanel-weekdays strong { + font: inherit; + font-size: 14px; +} + +.mytheme .v-inline-datefield-calendarpanel-header { + white-space: nowrap; +} + +.mytheme td[class*="year"] button, .mytheme td[class*="month"] button { + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + border: none; + background: transparent; + padding: 0; + margin: 0; + cursor: pointer; + color: transparent; + font-size: 0; + width: 19px; + height: 25px; + outline: none; + position: relative; + vertical-align: middle; +} + +.mytheme td[class*="year"] button:before, .mytheme td[class*="month"] button:before { + color: #a0a0a0; + font-size: 21px; + line-height: 24px; + -webkit-transition: color 200ms; + -moz-transition: color 200ms; + transition: color 200ms; +} + +.mytheme td[class*="year"] button:hover:before, .mytheme td[class*="month"] button:hover:before { + color: #197de1; +} + +.mytheme td[class*="year"] button.outside-range, .mytheme td[class*="month"] button.outside-range { + cursor: default; + opacity: 0.3; + filter: alpha(opacity=30.0) ; +} + +.mytheme td[class*="year"] button.outside-range:hover:before, .mytheme td[class*="month"] button.outside-range:hover:before { + color: #a0a0a0; +} + +.mytheme .v-button-prevyear:before { + font-family: ThemeIcons; + content: "\f100"; +} + +.mytheme .v-button-prevmonth:before { + font-family: ThemeIcons; + content: "\f104"; +} + +.mytheme .v-button-nextyear:before { + font-family: ThemeIcons; + content: "\f101"; +} + +.mytheme .v-button-nextmonth:before { + font-family: ThemeIcons; + content: "\f105"; +} + +.mytheme td.v-inline-datefield-calendarpanel-month { + width: 148px; + color: #197de1; +} + +.mytheme .v-inline-datefield-calendarpanel-year td.v-inline-datefield-calendarpanel-month { + width: 74px; +} + +.mytheme .v-inline-datefield-calendarpanel-weeknumber, .mytheme .v-inline-datefield-calendarpanel-weekdays.v-inline-datefield-calendarpanel-weeknumbers td:first-child { + width: 30px; + color: rgba(133, 133, 133, 0.85); + font-size: 14px; + display: inline-block; + text-align: left; +} + +.mytheme .v-inline-datefield-calendarpanel-weeknumber { + position: relative; +} + +.mytheme .v-inline-datefield-calendarpanel-weeknumbers .v-first:before { + content: ""; + position: absolute; + top: 38px; + bottom: 0; + left: 0; + width: 34px; + border-top: 1px solid #eaeaea; + border-right: 1px solid #eaeaea; + border-top-right-radius: 4px; + border-bottom-left-radius: 4px; + background: #fafafa; +} + +.mytheme td.v-inline-datefield-calendarpanel-time { + width: 100%; + font-size: 14px; +} + +.mytheme td.v-inline-datefield-calendarpanel-time .v-label { + display: inline; + margin: 0 0.1em; + font-weight: 400; +} + +.mytheme .v-inline-datefield-calendarpanel { + position: relative; + background: white; + padding: 6px; +} + +.mytheme .v-gridlayout-margin-top { + padding-top: 37px; +} + +.mytheme .v-gridlayout-margin-bottom { + padding-bottom: 37px; +} + +.mytheme .v-gridlayout-margin-left { + padding-left: 37px; +} + +.mytheme .v-gridlayout-margin-right { + padding-right: 37px; +} + +.mytheme .v-gridlayout-spacing-on { + padding-left: 12px; + padding-top: 12px; +} + +.mytheme .v-menubar { + position: relative; + text-align: center; + white-space: nowrap; + outline: none; + -webkit-tap-highlight-color: transparent; + -webkit-touch-callout: none; + cursor: pointer; + height: 37px; + padding: 0 16px; + color: #191919; + font-weight: 400; + + cursor: default; + border-radius: 4px; + border: 1px solid #c5c5c5; + border-top-color: #c5c5c5; + border-bottom-color: #bcbcbc; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + -webkit-box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.05); + padding: 0; + text-align: left; + line-height: 35px; +} + +.mytheme .v-menubar:after { + content: ""; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + border-radius: inherit; + -webkit-transition: box-shadow 180ms, border 180ms; + -moz-transition: box-shadow 180ms, border 180ms; + transition: box-shadow 180ms, border 180ms; +} + +.mytheme .v-menubar:focus:after { + -webkit-transition: none; + -moz-transition: none; + transition: none; +} + +.mytheme .v-menubar.v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-menubar.v-disabled:after { + display: none; +} + +.mytheme .v-menubar:after { + border: inherit; + top: -1px; + right: -1px; + bottom: -1px; + left: -1px; +} + +.mytheme .v-menubar:focus:after { + border-color: #197de1; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); +} + +.mytheme .v-menubar > .v-menubar-menuitem { + padding: 0 14px; +} + +.mytheme .v-menubar > .v-menubar-menuitem[class*="-icon-only"] { + width: 37px; +} + +.mytheme .v-menubar:active:after { + background: transparent; +} + +.mytheme .v-menubar > .v-menubar-menuitem { + position: relative; + z-index: 1; + display: inline-block; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + height: 37px; + padding: 0 15px; + color: inherit; + font-weight: 400; + + cursor: pointer; + border-radius: 0; + border: 1px solid #c5c5c5; + border-top-color: #c5c5c5; + border-bottom-color: #bcbcbc; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + -webkit-box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7; + box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7; + background: transparent; + -webkit-box-shadow: none; + box-shadow: none; + border-width: 0 1px 0 0; + border-color: inherit; + height: 100%; + line-height: inherit; + vertical-align: top; + text-align: center; +} + +.mytheme .v-menubar > .v-menubar-menuitem:first-child { + border-left-width: 0; + border-radius: 3px 0 0 3px; +} + +.mytheme .v-menubar > .v-menubar-menuitem:last-child { + border-radius: 0 3px 3px 0; + border-right-width: 0; +} + +.mytheme .v-menubar > .v-menubar-menuitem:first-child:last-child { + border-radius: 3px; +} + +.mytheme .v-menubar > .v-menubar-menuitem:before { + content: ""; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + border-radius: inherit; +} + +.mytheme .v-menubar > .v-menubar-menuitem:hover { + zoom: 1; +} + +.mytheme .v-menubar > .v-menubar-menuitem:hover:before { + background-color: rgba(186, 186, 186, 0.1); + border: none; +} + +.mytheme .v-menubar > .v-menubar-menuitem:active:before { + background-color: rgba(125, 125, 125, 0.2); +} + +.mytheme .v-menubar > .v-menubar-menuitem .v-icon { + margin: 0 4px 0 -4px; + cursor: inherit; +} + +.mytheme .v-menubar > .v-menubar-menuitem[class*="-icon-only"] { + width: 37px; + padding: 0; +} + +.mytheme .v-menubar > .v-menubar-menuitem[class*="-icon-only"] .v-icon { + margin: 0; +} + +.mytheme .v-menubar > .v-menubar-menuitem-checked { + -webkit-box-shadow: none; + box-shadow: none; + background-color: #ededed; + background-image: -webkit-linear-gradient(bottom, #ededed 2%, #e9e9e9 98%); + background-image: linear-gradient(to top,#ededed 2%, #e9e9e9 98%); + color: #181818; +} + +.mytheme .v-disabled > .v-menubar-menuitem, .mytheme .v-menubar > .v-menubar-menuitem-disabled { + cursor: default; +} + +.mytheme .v-disabled > .v-menubar-menuitem:before, .mytheme .v-menubar > .v-menubar-menuitem-disabled:before { + display: none; +} + +.mytheme .v-menubar-menuitem-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-menubar > .v-menubar-menuitem-selected { + color: #ecf2f8; + + + + border-radius: 0; + border: 1px solid #1362b1; + border-top-color: #156ab3; + border-bottom-color: #1156a8; + background-color: #197de1; + background-image: -webkit-linear-gradient(top, #1b87e3 2%, #166ed5 98%); + background-image: linear-gradient(to bottom,#1b87e3 2%, #166ed5 98%); + -webkit-box-shadow: inset 0 1px 0 #4d98e6, inset 0 -1px 0 #166bca; + box-shadow: inset 0 1px 0 #4d98e6, inset 0 -1px 0 #166bca; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.05); + border-top-width: 0; + border-left-width: 0; + border-bottom-width: 0; + z-index: 2; +} + +.mytheme .v-menubar > .v-menubar-menuitem-selected:hover:before { + background: none; +} + +.mytheme .v-menubar .v-menubar-submenu-indicator { + display: none; +} + +.mytheme .v-menubar .v-menubar-submenu-indicator + .v-menubar-menuitem-caption:after { + font-family: ThemeIcons; + content: "\f078"; + font-size: 0.7em; + vertical-align: 0.15em; + margin: 0 -0.2em 0 0.5em; + opacity: 0.5; +} + +.mytheme .v-menubar .v-menubar-submenu-indicator + .v-menubar-menuitem-caption:empty:after { + margin-left: -0.2em; +} + +.mytheme .v-menubar-popup { + padding: 4px 4px; + border-radius: 4px; + background-color: white; + color: #474747; + -webkit-box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.1), 0 3px 5px 0 rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.09098); + box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.1), 0 3px 5px 0 rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.09098); + -webkit-backface-visibility: hidden; + -moz-backface-visibility: hidden; + -ms-backface-visibility: hidden; + backface-visibility: hidden; + padding: 4px 4px; + margin: 5px 0 0 1px !important; +} + +.mytheme .v-menubar-popup[class*="animate-in"] { + -webkit-animation: valo-overlay-animate-in 120ms; + -moz-animation: valo-overlay-animate-in 120ms; + animation: valo-overlay-animate-in 120ms; +} + +.mytheme .v-menubar-popup[class*="animate-out"] { + -webkit-animation: valo-animate-out-fade 120ms; + -moz-animation: valo-animate-out-fade 120ms; + animation: valo-animate-out-fade 120ms; +} + +.mytheme .v-menubar-popup .v-menubar-submenu { + outline: none; +} + +.mytheme .v-menubar-popup .v-menubar-menuitem { + display: block; + cursor: pointer; + line-height: 27px; + padding: 0 20px 0 10px; + border-radius: 3px; + font-weight: 400; + white-space: nowrap; + position: relative; + padding-left: 32px; + padding-right: 37px; + position: relative; +} + +.mytheme .v-menubar-popup .v-menubar-menuitem:active:before { + content: ""; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + background: #0957a6; + opacity: 0.15; + filter: alpha(opacity=15.0) ; + pointer-events: none; + border-radius: inherit; +} + +.mytheme .v-menubar-popup .v-menubar-menuitem .v-icon { + max-height: 27px; + margin-right: 5px; + min-width: 1em; +} + +.mytheme .v-menubar-popup .v-menubar-submenu-indicator { + display: none; +} + +.mytheme .v-menubar-popup .v-menubar-submenu-indicator + .v-menubar-menuitem-caption:after { + position: absolute; + right: 10px; + font-family: ThemeIcons; + content: "\f054"; + line-height: 29px; +} + +.mytheme .v-menubar-popup .v-menubar-menuitem-selected { + background-color: #197de1; + background-image: -webkit-linear-gradient(top, #1b87e3 2%, #166ed5 98%); + background-image: linear-gradient(to bottom,#1b87e3 2%, #166ed5 98%); + color: #ecf2f8; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.05); +} + +.mytheme .v-menubar-popup .v-menubar-separator { + display: block; + margin: 4px 0; + height: 0; + overflow: hidden; + border-bottom: 1px solid #e4e4e4; +} + +.mytheme .v-menubar-popup [class*="checked"] .v-menubar-menuitem-caption:before { + content: "\f00c"; + font-family: ThemeIcons; + position: absolute; + left: 10px; +} + +.mytheme .v-menubar-popup [class*="unchecked"] .v-menubar-menuitem-caption:before { + content: ""; +} + +.mytheme .v-menubar-popup [class*="disabled"] { + cursor: default; +} + +.mytheme .v-menubar-small { + height: 31px; + padding: 0 14px; + + font-weight: 400; + + cursor: default; + border-radius: 4px; + padding: 0; + text-align: left; + line-height: 29px; + font-size: 14px; +} + +.mytheme .v-menubar-small:after { + border: inherit; + top: -1px; + right: -1px; + bottom: -1px; + left: -1px; +} + +.mytheme .v-menubar-small > .v-menubar-menuitem { + padding: 0 12px; +} + +.mytheme .v-menubar-small > .v-menubar-menuitem[class*="-icon-only"] { + width: 31px; +} + +.mytheme .v-menubar-borderless { + border: none; + border-radius: 0; + padding: 1px; + -webkit-box-shadow: none; + box-shadow: none; + text-shadow: none; + background: transparent; + color: inherit; +} + +.mytheme .v-menubar-borderless:focus:after { + display: none; +} + +.mytheme .v-menubar-borderless .v-menubar-menuitem { + -webkit-box-shadow: none; + box-shadow: none; + border: none; + margin-right: 1px; + border-radius: 4px; + color: #197de1; + padding: 0 12px; + -webkit-transition: color 140ms; + -moz-transition: color 140ms; + transition: color 140ms; +} + +.mytheme .v-menubar-borderless .v-menubar-menuitem:first-child, .mytheme .v-menubar-borderless .v-menubar-menuitem:last-child, .mytheme .v-menubar-borderless .v-menubar-menuitem:first-child:last-child { + border-radius: 4px; +} + +.mytheme .v-menubar-borderless .v-menubar-menuitem:before { + content: none; +} + +.mytheme .v-menubar-borderless .v-menubar-menuitem:hover { + color: #4396ea; +} + +.mytheme .v-menubar-borderless .v-menubar-menuitem:active { + color: inherit; +} + +.mytheme .v-menubar-borderless .v-menubar-menuitem-checked, .mytheme .v-menubar-borderless .v-menubar-menuitem-checked:first-child { + border: 1px solid #c5c5c5; + color: #197de1; +} + +.mytheme .v-menubar-borderless .v-menubar-menuitem-checked .v-menubar-menuitem-caption, .mytheme .v-menubar-borderless .v-menubar-menuitem-checked:first-child .v-menubar-menuitem-caption { + position: relative; + top: -1px; +} + +.mytheme .v-menubar-borderless .v-menubar-menuitem-selected { + color: #ecf2f8; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.05); +} + +.mytheme .v-menubar-borderless .v-menubar-menuitem-selected:hover { + color: #ecf2f8; +} + +.mytheme .v-menubar-borderless .v-menubar-menuitem-disabled, .mytheme .v-menubar-borderless .v-menubar-menuitem-disabled:hover { + color: inherit; +} + +.mytheme .v-radiobutton { + position: relative; + line-height: 19px; + white-space: nowrap; +} + +.mytheme .v-radiobutton.v-has-width label { + white-space: normal; +} + +:root .mytheme .v-radiobutton { + padding-left: 25px; +} + +:root .mytheme .v-radiobutton label { + -webkit-tap-highlight-color: transparent; + -webkit-touch-callout: none; + cursor: pointer; + display: inline-block; +} + +:root .mytheme .v-radiobutton > input { + position: absolute; + clip: rect(0, 0, 0, 0); + left: 0.2em; + top: 0.2em; + z-index: 0; + margin: 0; +} + +:root .mytheme .v-radiobutton > input:focus ~ label:before { + border-color: #197de1; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); +} + +:root .mytheme .v-radiobutton > input ~ label:before, :root .mytheme .v-radiobutton > input ~ label:after { + content: ""; + display: inline-block; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + width: 19px; + height: 19px; + position: absolute; + top: 0; + left: 0; + border-radius: 4px; + font-size: 13px; + text-align: center; +} + +:root .mytheme .v-radiobutton > input ~ label:before { + height: 18.5px; + padding: 0 9px; + color: #191919; + font-weight: 400; + + + border-radius: 4px; + border: 1px solid #c5c5c5; + border-top-color: #c5c5c5; + border-bottom-color: #bcbcbc; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + -webkit-box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.05); + padding: 0; + height: 19px; +} + +:root .mytheme .v-radiobutton > input ~ label:after { + content: "\f00c"; + font-family: ThemeIcons; + color: transparent; + -webkit-transition: color 100ms; + -moz-transition: color 100ms; + transition: color 100ms; +} + +:root .mytheme .v-radiobutton > input:active ~ label:after { + background-color: rgba(125, 125, 125, 0.2); +} + +:root .mytheme .v-radiobutton > input:checked ~ label:after { + color: #197de1; +} + +.mytheme .v-radiobutton > .v-icon, .mytheme .v-radiobutton > label .v-icon { + margin: 0 6px 0 3px; + min-width: 1em; + cursor: pointer; +} + +.mytheme .v-radiobutton.v-disabled > label, .mytheme .v-radiobutton.v-disabled > .v-icon { + cursor: default; + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-radiobutton.v-disabled > label > .v-icon { + cursor: default; +} + +:root .mytheme .v-radiobutton.v-disabled > input:active ~ label:after { + background: transparent; +} + +.mytheme .v-radiobutton.v-readonly > label, .mytheme .v-radiobutton.v-readonly > .v-icon { + cursor: default; +} + +.mytheme .v-radiobutton.v-readonly > label > .v-icon { + cursor: default; +} + +:root .mytheme .v-radiobutton.v-readonly > input:active ~ label:after { + background: transparent; +} + +:root .mytheme .v-radiobutton.v-readonly > input ~ label:after { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +:root .mytheme .v-radiobutton > input:checked ~ label:after { + width: 7px; + height: 7px; + top: 6px; + left: 6px; + background: #197de1; +} + +:root .mytheme .v-radiobutton > input ~ label:before, :root .mytheme .v-radiobutton > input ~ label:after { + border-radius: 50%; + content: ""; +} + +.mytheme .v-select-optiongroup .v-radiobutton, .mytheme .v-select-optiongroup .v-checkbox { + display: block; + margin: 9px 16px 0 0; +} + +.mytheme .v-select-optiongroup .v-radiobutton:first-child, .mytheme .v-select-optiongroup .v-checkbox:first-child { + margin-top: 6px; +} + +.mytheme .v-select-optiongroup .v-radiobutton:last-child, .mytheme .v-select-optiongroup .v-checkbox:last-child { + margin-bottom: 6px; +} + +.mytheme .v-select-optiongroup.v-has-width label { + white-space: normal; +} + +.mytheme .v-select-optiongroup-small { + font-size: 14px; +} + +.mytheme .v-select-optiongroup-small .v-checkbox { + position: relative; + line-height: 16px; + white-space: nowrap; +} + +.mytheme .v-select-optiongroup-small .v-checkbox.v-has-width label { + white-space: normal; +} + +:root .mytheme .v-select-optiongroup-small .v-checkbox { + padding-left: 21px; +} + +:root .mytheme .v-select-optiongroup-small .v-checkbox label { + -webkit-tap-highlight-color: transparent; + -webkit-touch-callout: none; + cursor: pointer; + display: inline-block; +} + +:root .mytheme .v-select-optiongroup-small .v-checkbox > input { + position: absolute; + clip: rect(0, 0, 0, 0); + left: 0.2em; + top: 0.2em; + z-index: 0; + margin: 0; +} + +:root .mytheme .v-select-optiongroup-small .v-checkbox > input:focus ~ label:before { + border-color: #197de1; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); +} + +:root .mytheme .v-select-optiongroup-small .v-checkbox > input ~ label:before, :root .mytheme .v-select-optiongroup-small .v-checkbox > input ~ label:after { + content: ""; + display: inline-block; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + width: 16px; + height: 16px; + position: absolute; + top: 0; + left: 0; + border-radius: 4px; + font-size: 11px; + text-align: center; +} + +:root .mytheme .v-select-optiongroup-small .v-checkbox > input ~ label:before { + height: 15.5px; + padding: 0 7px; + color: #191919; + font-weight: 400; + + + border-radius: 4px; + border: 1px solid #c5c5c5; + border-top-color: #c5c5c5; + border-bottom-color: #bcbcbc; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + -webkit-box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.05); + padding: 0; + height: 16px; +} + +:root .mytheme .v-select-optiongroup-small .v-checkbox > input ~ label:after { + content: "\f00c"; + font-family: ThemeIcons; + color: transparent; + -webkit-transition: color 100ms; + -moz-transition: color 100ms; + transition: color 100ms; +} + +:root .mytheme .v-select-optiongroup-small .v-checkbox > input:active ~ label:after { + background-color: rgba(125, 125, 125, 0.2); +} + +:root .mytheme .v-select-optiongroup-small .v-checkbox > input:checked ~ label:after { + color: #197de1; +} + +.mytheme .v-select-optiongroup-small .v-checkbox > .v-icon, .mytheme .v-select-optiongroup-small .v-checkbox > label .v-icon { + margin: 0 5px 0 3px; + min-width: 1em; + cursor: pointer; +} + +.mytheme .v-select-optiongroup-small .v-checkbox.v-disabled > label, .mytheme .v-select-optiongroup-small .v-checkbox.v-disabled > .v-icon { + cursor: default; + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-select-optiongroup-small .v-checkbox.v-disabled > label > .v-icon { + cursor: default; +} + +:root .mytheme .v-select-optiongroup-small .v-checkbox.v-disabled > input:active ~ label:after { + background: transparent; +} + +.mytheme .v-select-optiongroup-small .v-checkbox.v-readonly > label, .mytheme .v-select-optiongroup-small .v-checkbox.v-readonly > .v-icon { + cursor: default; +} + +.mytheme .v-select-optiongroup-small .v-checkbox.v-readonly > label > .v-icon { + cursor: default; +} + +:root .mytheme .v-select-optiongroup-small .v-checkbox.v-readonly > input:active ~ label:after { + background: transparent; +} + +:root .mytheme .v-select-optiongroup-small .v-checkbox.v-readonly > input ~ label:after { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-select-optiongroup-small .v-radiobutton { + position: relative; + line-height: 16px; + white-space: nowrap; +} + +.mytheme .v-select-optiongroup-small .v-radiobutton.v-has-width label { + white-space: normal; +} + +:root .mytheme .v-select-optiongroup-small .v-radiobutton { + padding-left: 21px; +} + +:root .mytheme .v-select-optiongroup-small .v-radiobutton label { + -webkit-tap-highlight-color: transparent; + -webkit-touch-callout: none; + cursor: pointer; + display: inline-block; +} + +:root .mytheme .v-select-optiongroup-small .v-radiobutton > input { + position: absolute; + clip: rect(0, 0, 0, 0); + left: 0.2em; + top: 0.2em; + z-index: 0; + margin: 0; +} + +:root .mytheme .v-select-optiongroup-small .v-radiobutton > input:focus ~ label:before { + border-color: #197de1; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); +} + +:root .mytheme .v-select-optiongroup-small .v-radiobutton > input ~ label:before, :root .mytheme .v-select-optiongroup-small .v-radiobutton > input ~ label:after { + content: ""; + display: inline-block; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + width: 16px; + height: 16px; + position: absolute; + top: 0; + left: 0; + border-radius: 4px; + font-size: 11px; + text-align: center; +} + +:root .mytheme .v-select-optiongroup-small .v-radiobutton > input ~ label:before { + height: 15.5px; + padding: 0 7px; + color: #191919; + font-weight: 400; + + + border-radius: 4px; + border: 1px solid #c5c5c5; + border-top-color: #c5c5c5; + border-bottom-color: #bcbcbc; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + -webkit-box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.05); + padding: 0; + height: 16px; +} + +:root .mytheme .v-select-optiongroup-small .v-radiobutton > input ~ label:after { + content: "\f00c"; + font-family: ThemeIcons; + color: transparent; + -webkit-transition: color 100ms; + -moz-transition: color 100ms; + transition: color 100ms; +} + +:root .mytheme .v-select-optiongroup-small .v-radiobutton > input:active ~ label:after { + background-color: rgba(125, 125, 125, 0.2); +} + +:root .mytheme .v-select-optiongroup-small .v-radiobutton > input:checked ~ label:after { + color: #197de1; +} + +.mytheme .v-select-optiongroup-small .v-radiobutton > .v-icon, .mytheme .v-select-optiongroup-small .v-radiobutton > label .v-icon { + margin: 0 5px 0 3px; + min-width: 1em; + cursor: pointer; +} + +.mytheme .v-select-optiongroup-small .v-radiobutton.v-disabled > label, .mytheme .v-select-optiongroup-small .v-radiobutton.v-disabled > .v-icon { + cursor: default; + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-select-optiongroup-small .v-radiobutton.v-disabled > label > .v-icon { + cursor: default; +} + +:root .mytheme .v-select-optiongroup-small .v-radiobutton.v-disabled > input:active ~ label:after { + background: transparent; +} + +.mytheme .v-select-optiongroup-small .v-radiobutton.v-readonly > label, .mytheme .v-select-optiongroup-small .v-radiobutton.v-readonly > .v-icon { + cursor: default; +} + +.mytheme .v-select-optiongroup-small .v-radiobutton.v-readonly > label > .v-icon { + cursor: default; +} + +:root .mytheme .v-select-optiongroup-small .v-radiobutton.v-readonly > input:active ~ label:after { + background: transparent; +} + +:root .mytheme .v-select-optiongroup-small .v-radiobutton.v-readonly > input ~ label:after { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +:root .mytheme .v-select-optiongroup-small .v-radiobutton > input:checked ~ label:after { + width: 6px; + height: 6px; + top: 5px; + left: 5px; + background: #197de1; +} + +:root .mytheme .v-select-optiongroup-small .v-radiobutton > input ~ label:before, :root .mytheme .v-select-optiongroup-small .v-radiobutton > input ~ label:after { + border-radius: 50%; + content: ""; +} + +.mytheme .v-select-optiongroup-small .v-radiobutton, .mytheme .v-select-optiongroup-small .v-checkbox { + display: block; + margin: 8px 16px 0 0; +} + +.mytheme .v-select-optiongroup-small .v-radiobutton:first-child, .mytheme .v-select-optiongroup-small .v-checkbox:first-child { + margin-top: 5px; +} + +.mytheme .v-select-optiongroup-small .v-radiobutton:last-child, .mytheme .v-select-optiongroup-small .v-checkbox:last-child { + margin-bottom: 5px; +} + +.mytheme .v-select-optiongroup-small.v-has-width label { + white-space: normal; +} + +.mytheme .v-select-optiongroup-large { + font-size: 20px; +} + +.mytheme .v-select-optiongroup-large .v-checkbox { + position: relative; + line-height: 22px; + white-space: nowrap; +} + +.mytheme .v-select-optiongroup-large .v-checkbox.v-has-width label { + white-space: normal; +} + +:root .mytheme .v-select-optiongroup-large .v-checkbox { + padding-left: 29px; +} + +:root .mytheme .v-select-optiongroup-large .v-checkbox label { + -webkit-tap-highlight-color: transparent; + -webkit-touch-callout: none; + cursor: pointer; + display: inline-block; +} + +:root .mytheme .v-select-optiongroup-large .v-checkbox > input { + position: absolute; + clip: rect(0, 0, 0, 0); + left: 0.2em; + top: 0.2em; + z-index: 0; + margin: 0; +} + +:root .mytheme .v-select-optiongroup-large .v-checkbox > input:focus ~ label:before { + border-color: #197de1; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); +} + +:root .mytheme .v-select-optiongroup-large .v-checkbox > input ~ label:before, :root .mytheme .v-select-optiongroup-large .v-checkbox > input ~ label:after { + content: ""; + display: inline-block; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + width: 22px; + height: 22px; + position: absolute; + top: 0; + left: 0; + border-radius: 4px; + font-size: 15px; + text-align: center; +} + +:root .mytheme .v-select-optiongroup-large .v-checkbox > input ~ label:before { + height: 22px; + padding: 0 10px; + color: #191919; + font-weight: 400; + + + border-radius: 4px; + border: 1px solid #c5c5c5; + border-top-color: #c5c5c5; + border-bottom-color: #bcbcbc; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + -webkit-box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.05); + padding: 0; + height: 22px; +} + +:root .mytheme .v-select-optiongroup-large .v-checkbox > input ~ label:after { + content: "\f00c"; + font-family: ThemeIcons; + color: transparent; + -webkit-transition: color 100ms; + -moz-transition: color 100ms; + transition: color 100ms; +} + +:root .mytheme .v-select-optiongroup-large .v-checkbox > input:active ~ label:after { + background-color: rgba(125, 125, 125, 0.2); +} + +:root .mytheme .v-select-optiongroup-large .v-checkbox > input:checked ~ label:after { + color: #197de1; +} + +.mytheme .v-select-optiongroup-large .v-checkbox > .v-icon, .mytheme .v-select-optiongroup-large .v-checkbox > label .v-icon { + margin: 0 7px 0 4px; + min-width: 1em; + cursor: pointer; +} + +.mytheme .v-select-optiongroup-large .v-checkbox.v-disabled > label, .mytheme .v-select-optiongroup-large .v-checkbox.v-disabled > .v-icon { + cursor: default; + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-select-optiongroup-large .v-checkbox.v-disabled > label > .v-icon { + cursor: default; +} + +:root .mytheme .v-select-optiongroup-large .v-checkbox.v-disabled > input:active ~ label:after { + background: transparent; +} + +.mytheme .v-select-optiongroup-large .v-checkbox.v-readonly > label, .mytheme .v-select-optiongroup-large .v-checkbox.v-readonly > .v-icon { + cursor: default; +} + +.mytheme .v-select-optiongroup-large .v-checkbox.v-readonly > label > .v-icon { + cursor: default; +} + +:root .mytheme .v-select-optiongroup-large .v-checkbox.v-readonly > input:active ~ label:after { + background: transparent; +} + +:root .mytheme .v-select-optiongroup-large .v-checkbox.v-readonly > input ~ label:after { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-select-optiongroup-large .v-radiobutton { + position: relative; + line-height: 22px; + white-space: nowrap; +} + +.mytheme .v-select-optiongroup-large .v-radiobutton.v-has-width label { + white-space: normal; +} + +:root .mytheme .v-select-optiongroup-large .v-radiobutton { + padding-left: 29px; +} + +:root .mytheme .v-select-optiongroup-large .v-radiobutton label { + -webkit-tap-highlight-color: transparent; + -webkit-touch-callout: none; + cursor: pointer; + display: inline-block; +} + +:root .mytheme .v-select-optiongroup-large .v-radiobutton > input { + position: absolute; + clip: rect(0, 0, 0, 0); + left: 0.2em; + top: 0.2em; + z-index: 0; + margin: 0; +} + +:root .mytheme .v-select-optiongroup-large .v-radiobutton > input:focus ~ label:before { + border-color: #197de1; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5), inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); +} + +:root .mytheme .v-select-optiongroup-large .v-radiobutton > input ~ label:before, :root .mytheme .v-select-optiongroup-large .v-radiobutton > input ~ label:after { + content: ""; + display: inline-block; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + width: 22px; + height: 22px; + position: absolute; + top: 0; + left: 0; + border-radius: 4px; + font-size: 15px; + text-align: center; +} + +:root .mytheme .v-select-optiongroup-large .v-radiobutton > input ~ label:before { + height: 22px; + padding: 0 10px; + color: #191919; + font-weight: 400; + + + border-radius: 4px; + border: 1px solid #c5c5c5; + border-top-color: #c5c5c5; + border-bottom-color: #bcbcbc; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + -webkit-box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.05); + padding: 0; + height: 22px; +} + +:root .mytheme .v-select-optiongroup-large .v-radiobutton > input ~ label:after { + content: "\f00c"; + font-family: ThemeIcons; + color: transparent; + -webkit-transition: color 100ms; + -moz-transition: color 100ms; + transition: color 100ms; +} + +:root .mytheme .v-select-optiongroup-large .v-radiobutton > input:active ~ label:after { + background-color: rgba(125, 125, 125, 0.2); +} + +:root .mytheme .v-select-optiongroup-large .v-radiobutton > input:checked ~ label:after { + color: #197de1; +} + +.mytheme .v-select-optiongroup-large .v-radiobutton > .v-icon, .mytheme .v-select-optiongroup-large .v-radiobutton > label .v-icon { + margin: 0 7px 0 4px; + min-width: 1em; + cursor: pointer; +} + +.mytheme .v-select-optiongroup-large .v-radiobutton.v-disabled > label, .mytheme .v-select-optiongroup-large .v-radiobutton.v-disabled > .v-icon { + cursor: default; + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-select-optiongroup-large .v-radiobutton.v-disabled > label > .v-icon { + cursor: default; +} + +:root .mytheme .v-select-optiongroup-large .v-radiobutton.v-disabled > input:active ~ label:after { + background: transparent; +} + +.mytheme .v-select-optiongroup-large .v-radiobutton.v-readonly > label, .mytheme .v-select-optiongroup-large .v-radiobutton.v-readonly > .v-icon { + cursor: default; +} + +.mytheme .v-select-optiongroup-large .v-radiobutton.v-readonly > label > .v-icon { + cursor: default; +} + +:root .mytheme .v-select-optiongroup-large .v-radiobutton.v-readonly > input:active ~ label:after { + background: transparent; +} + +:root .mytheme .v-select-optiongroup-large .v-radiobutton.v-readonly > input ~ label:after { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +:root .mytheme .v-select-optiongroup-large .v-radiobutton > input:checked ~ label:after { + width: 8px; + height: 8px; + top: 7px; + left: 7px; + background: #197de1; +} + +:root .mytheme .v-select-optiongroup-large .v-radiobutton > input ~ label:before, :root .mytheme .v-select-optiongroup-large .v-radiobutton > input ~ label:after { + border-radius: 50%; + content: ""; +} + +.mytheme .v-select-optiongroup-large .v-radiobutton, .mytheme .v-select-optiongroup-large .v-checkbox { + display: block; + margin: 11px 16px 0 0; +} + +.mytheme .v-select-optiongroup-large .v-radiobutton:first-child, .mytheme .v-select-optiongroup-large .v-checkbox:first-child { + margin-top: 7px; +} + +.mytheme .v-select-optiongroup-large .v-radiobutton:last-child, .mytheme .v-select-optiongroup-large .v-checkbox:last-child { + margin-bottom: 7px; +} + +.mytheme .v-select-optiongroup-large.v-has-width label { + white-space: normal; +} + +.mytheme .v-select-optiongroup-horizontal { + white-space: nowrap; +} + +.mytheme .v-select-optiongroup-horizontal .v-radiobutton, .mytheme .v-select-optiongroup-horizontal .v-checkbox { + display: inline-block; +} + +.mytheme .v-select-optiongroup-horizontal.v-has-width { + white-space: normal; +} + +.mytheme .v-select-optiongroup-horizontal.v-has-width label { + white-space: nowrap; +} + +.mytheme .v-link { + cursor: pointer; + color: #197de1; + text-decoration: underline; + font-weight: inherit; + -webkit-transition: color 140ms; + -moz-transition: color 140ms; + transition: color 140ms; +} + +.mytheme .v-link:hover { + color: #4396ea; +} + +.mytheme .v-link.v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-link a { + cursor: inherit; + color: inherit; + text-decoration: inherit; + -webkit-transition: inherit; + -moz-transition: inherit; + transition: inherit; +} + +.mytheme .v-link .v-icon { + cursor: inherit; +} + +.mytheme .v-link-small { + font-size: 14px; +} + +.mytheme .v-link-large { + font-size: 20px; +} + +.mytheme .v-window { + padding: 4px 4px; + border-radius: 4px; + background-color: white; + color: #474747; + -webkit-box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.1), 0 3px 5px 0 rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.09098); + box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.1), 0 3px 5px 0 rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.09098); + -webkit-backface-visibility: hidden; + -moz-backface-visibility: hidden; + -ms-backface-visibility: hidden; + backface-visibility: hidden; + -webkit-box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1), 0 16px 80px -6px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.09098); + box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1), 0 16px 80px -6px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.09098); + padding: 0; + min-width: 148px !important; + min-height: 37px !important; + white-space: nowrap; + overflow: hidden !important; + -webkit-transition: width 200ms, height 200ms, top 200ms, left 200ms; + -moz-transition: width 200ms, height 200ms, top 200ms, left 200ms; + transition: width 200ms, height 200ms, top 200ms, left 200ms; +} + +.mytheme .v-window[class*="animate-in"] { + -webkit-animation: valo-animate-in-fade 140ms; + -moz-animation: valo-animate-in-fade 140ms; + animation: valo-animate-in-fade 140ms; +} + +.mytheme .v-window[class*="animate-out"] { + -webkit-animation: valo-animate-out-scale-down-fade 100ms; + -moz-animation: valo-animate-out-scale-down-fade 100ms; + animation: valo-animate-out-scale-down-fade 100ms; +} + +.mytheme .v-window.v-window-animate-in { + -webkit-transition: none; + -moz-transition: none; + transition: none; +} + +.mytheme .v-window-modalitycurtain { + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: 0; + background-color: #222; + background-image: -webkit-radial-gradient(50% 50%, circle, #222, #0e0e0e); + background-image: radial-gradient( circle at 50% 50%, #222, #0e0e0e); + opacity: 0.72; + filter: alpha(opacity=72) ; + -webkit-animation: valo-animate-in-fade 400ms 100ms backwards; + -moz-animation: valo-animate-in-fade 400ms 100ms backwards; + animation: valo-animate-in-fade 400ms 100ms backwards; +} + +.v-op12 .mytheme .v-window-modalitycurtain { + -webkit-animation: none; + -moz-animation: none; + animation: none; +} + +.mytheme .v-window-draggingCurtain { + position: fixed !important; +} + +.mytheme .v-window-resizingCurtain + .v-window, .mytheme .v-window-draggingCurtain + .v-window { + -webkit-transition: none; + -moz-transition: none; + transition: none; +} + +.mytheme .v-window-outerheader { + cursor: move; + position: absolute; + z-index: 2; + top: 0; + left: 0; + right: 0; + -webkit-transform: translatez(0); + -moz-transform: translatez(0); + -ms-transform: translatez(0); + -o-transform: translatez(0); + transform: translatez(0); +} + +.mytheme .v-window-outerheader:after { + content: ""; + position: absolute; + bottom: -1px; + right: 0; + left: 0; + height: 0; + border-top: 1px solid #dfdfdf; + border-color: rgba(197, 197, 197, 0.5); +} + +.mytheme .v-window-header { + line-height: 36px; + padding-left: 12px; + margin-right: 74px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + color: #7e7e7e; +} + +.mytheme .v-window-restorebox-disabled ~ .v-window-closebox ~ .v-window-header, .mytheme .v-window-maximizebox-disabled ~ .v-window-closebox ~ .v-window-header { + margin-right: 37px; +} + +.mytheme .v-window-restorebox-disabled ~ .v-window-closebox-disabled ~ .v-window-header, .mytheme .v-window-maximizebox-disabled ~ .v-window-closebox-disabled ~ .v-window-header { + margin-right: 12px; +} + +.mytheme .v-window-closebox, .mytheme .v-window-maximizebox, .mytheme .v-window-restorebox { + position: absolute; + z-index: 3; + top: 0; + right: 0; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + width: 33px; + height: 36px; + background-color: white; + line-height: 34px; + text-align: center; + cursor: pointer; + font-size: 21px; + color: #999999; + -webkit-transition: color 140ms; + -moz-transition: color 140ms; + transition: color 140ms; +} + +.mytheme .v-window-closebox:focus, .mytheme .v-window-maximizebox:focus, .mytheme .v-window-restorebox:focus { + outline: none; +} + +.mytheme .v-window-closebox:hover, .mytheme .v-window-maximizebox:hover, .mytheme .v-window-restorebox:hover { + opacity: 1; + filter: none ; + color: #197de1; +} + +.mytheme .v-window-closebox:active, .mytheme .v-window-maximizebox:active, .mytheme .v-window-restorebox:active { + color: inherit; +} + +.mytheme .v-window-closebox { + padding-right: 4px; + border-radius: 0 4px 0 4px; +} + +.mytheme .v-window-closebox:before { + content: "\00d7"; +} + +.mytheme .v-window-maximizebox, .mytheme .v-window-restorebox { + right: 33px; + padding-left: 4px; + border-radius: 0 0 0 4px; +} + +.mytheme .v-window-maximizebox + .v-window-closebox, .mytheme .v-window-restorebox + .v-window-closebox { + border-bottom-left-radius: 0; +} + +.mytheme .v-window-closebox-disabled, .mytheme .v-window-resizebox-disabled, .mytheme .v-window-restorebox-disabled, .mytheme .v-window-maximizebox-disabled { + display: none; +} + +.mytheme .v-window-closebox-disabled + .v-window-closebox, .mytheme .v-window-resizebox-disabled + .v-window-closebox, .mytheme .v-window-restorebox-disabled + .v-window-closebox, .mytheme .v-window-maximizebox-disabled + .v-window-closebox { + width: 37px; + padding-right: 0; + border-bottom-left-radius: 4px; +} + +.mytheme .v-window-maximizebox:before { + content: "+"; +} + +.mytheme .v-window-restorebox:before { + content: "\2013"; +} + +.mytheme .v-window > .popupContent, .mytheme .v-window-wrap, .mytheme .v-window-contents, .mytheme .v-window-contents > .v-scrollable { + height: 100%; +} + +.mytheme .v-window-contents { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + border-radius: 4px; + margin-top: 0 !important; +} + +.mytheme .v-window-contents > .v-scrollable { + position: relative; +} + +.mytheme .v-window-contents > .v-scrollable > .v-margin-top { + padding-top: 12px; +} + +.mytheme .v-window-contents > .v-scrollable > .v-margin-right { + padding-right: 12px; +} + +.mytheme .v-window-contents > .v-scrollable > .v-margin-bottom { + padding-bottom: 12px; +} + +.mytheme .v-window-contents > .v-scrollable > .v-margin-left { + padding-left: 12px; +} + +.mytheme .v-window-contents > .v-scrollable > .v-formlayout [class*="margin-top"] > tbody > [class*="firstrow"] > td { + padding-top: 12px; +} + +.mytheme .v-window-contents > .v-scrollable > .v-formlayout [class*="margin-bottom"] > tbody > [class*="lastrow"] > td { + padding-bottom: 12px; +} + +.mytheme .v-window-contents > .v-scrollable > .v-formlayout [class*="margin-left"] > tbody > [class*="row"] > [class*="captioncell"] { + padding-left: 12px; +} + +.mytheme .v-window-contents > .v-scrollable > .v-formlayout [class*="margin-left"] > tbody > [class*="row"] > [class*="contentcell"] > .v-label-h2, .mytheme .v-window-contents > .v-scrollable > .v-formlayout [class*="margin-left"] > tbody > [class*="row"] > [class*="contentcell"] > .v-label-h3, .mytheme .v-window-contents > .v-scrollable > .v-formlayout [class*="margin-left"] > tbody > [class*="row"] > [class*="contentcell"] > .v-label-h4 { + left: 12px; +} + +.mytheme .v-window-contents > .v-scrollable > .v-formlayout [class*="margin-right"] > tbody > [class*="row"] > [class*="contentcell"] { + padding-right: 12px; +} + +.mytheme .v-window-contents > .v-scrollable > .v-formlayout [class*="margin-right"] > tbody > [class*="row"] > [class*="contentcell"] > .v-label-h2, .mytheme .v-window-contents > .v-scrollable > .v-formlayout [class*="margin-right"] > tbody > [class*="row"] > [class*="contentcell"] > .v-label-h3, .mytheme .v-window-contents > .v-scrollable > .v-formlayout [class*="margin-right"] > tbody > [class*="row"] > [class*="contentcell"] > .v-label-h4 { + right: 12px; +} + +.mytheme .v-window-contents > .v-scrollable:focus { + outline: none; +} + +.mytheme .v-window-contents > .v-scrollable:before { + content: ""; + position: absolute; + z-index: 2; + top: 0; + height: 0; + border-top: 1px solid white; + left: 0; + right: 0; +} + +.mytheme .v-window-contents > .v-scrollable .v-panel-captionwrap:after { + border-color: #dfdfdf; +} + +.mytheme .v-window-contents > .v-scrollable .v-panel-content:before { + border-color: white; +} + +.mytheme .v-window-footer { + height: 0; +} + +.mytheme .v-window-resizebox { + position: absolute; + z-index: 1000; + right: 0; + bottom: 0; + width: 19px; + height: 19px; + cursor: nwse-resize; +} + +.v-ie8 .mytheme .v-window-resizebox { + background: #000; + filter: alpha(opacity=0.1); +} + +.v-ie8 .mytheme .v-window-resizebox, .v-ie9 .mytheme .v-window-resizebox { + cursor: se-resize; +} + +.mytheme .v-window-modalitycurtain:active ~ .v-window { + -webkit-animation: none; + -moz-animation: none; + animation: none; +} + +.mytheme .v-window-top-toolbar > .v-widget, .mytheme .v-window-bottom-toolbar > .v-widget { + vertical-align: top; +} + +.mytheme .v-window-top-toolbar .v-label, .mytheme .v-window-bottom-toolbar .v-label { + line-height: 36px; +} + +.mytheme .v-window-top-toolbar .v-spacing, .mytheme .v-window-bottom-toolbar .v-spacing { + width: 6px; +} + +.mytheme .v-window-top-toolbar.v-layout { + padding: 7px 12px; + position: relative; + z-index: 2; + border-top: 1px solid #dfdfdf; + border-bottom: 1px solid #dfdfdf; + background-color: #fafafa; +} + +.mytheme .v-window-top-toolbar.v-menubar { + margin: 12px 12px 6px; +} + +.mytheme .v-window-top-toolbar.v-menubar-borderless { + padding-left: 6px; + padding-right: 6px; + margin: 5px 0; +} + +.mytheme .v-window-bottom-toolbar.v-layout { + padding: 7px 12px; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #f0f0f0 0, #fafafa 4px); + background-image: linear-gradient(to bottom,#f0f0f0 0, #fafafa 4px); + border-top: 1px solid #dfdfdf; + border-radius: 0 0 4px 4px; +} + +.mytheme .v-margin-left.v-margin-right.v-margin-top .v-window-top-toolbar.v-layout { + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + margin: -12px -12px 0; +} + +.mytheme .v-margin-left.v-margin-right.v-margin-top .v-window-top-toolbar.v-menubar { + margin: 0; +} + +.mytheme .v-margin-left.v-margin-right.v-margin-top .v-window-top-toolbar.v-menubar-borderless { + margin: -6px -6px 0; + padding: 0; +} + +.mytheme .v-margin-left.v-margin-right.v-margin-bottom .v-window-bottom-toolbar.v-layout { + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + margin: 0 -12px -12px; +} + +.mytheme .v-tree { + position: relative; + white-space: nowrap; +} + +.mytheme .v-tree:focus { + outline: none; +} + +.mytheme .v-tree-node:before { + content: ""; + position: absolute; + display: inline-block; + z-index: 3; + width: 1.9em; + height: 28px; + cursor: pointer; + background: red; + opacity: 0; +} + +.v-ie8 .mytheme .v-tree-node:before { + position: static; + margin-left: -1.9em; + vertical-align: top; + content: "\f0da"; + font-family: ThemeIcons; + text-align: center; + background: transparent; +} + +.v-ie8 .mytheme .v-tree-node { + padding-left: 1.9em; +} + +.mytheme .v-tree-node-caption { + height: 28px; + line-height: 27px; + overflow: hidden; + white-space: nowrap; + vertical-align: top; +} + +.mytheme .v-tree-node-caption > div { + display: inline-block; + width: 100%; + position: relative; + z-index: 2; +} + +.mytheme .v-tree-node-caption > div:before { + content: "\f0da"; + font-family: ThemeIcons; + display: inline-block; + width: 0.5em; + text-align: center; + margin: 0 0.6em 0 0.8em; + -webkit-transition: all 100ms; + -moz-transition: all 100ms; + transition: all 100ms; +} + +.v-ie8 .mytheme .v-tree-node-caption > div:before { + display: none; +} + +.mytheme .v-tree-node-caption span { + padding-right: 28px; + cursor: pointer; + display: inline-block; + width: 100%; +} + +.v-ie .mytheme .v-tree-node-caption span { + width: auto; +} + +.mytheme .v-tree-node-caption .v-icon { + padding-right: 0; + width: auto; + min-width: 1em; +} + +.mytheme .v-tree-node-caption:after { + content: ""; + display: block; + vertical-align: top; + position: absolute; + z-index: 1; + left: 0; + margin-top: -28px; + width: 100%; + height: 28px; + border-radius: 4px; + opacity: 0; + -webkit-transition: opacity 120ms; + -moz-transition: opacity 120ms; + transition: opacity 120ms; +} + +.v-ie8 .mytheme .v-tree-node-caption:after { + content: none; +} + +.v-ie8 .mytheme .v-tree-node-caption { + display: inline-block; +} + +.mytheme .v-tree-node-expanded > .v-tree-node-caption > div:before { + -webkit-transform: rotate(90deg); + -moz-transform: rotate(90deg); + -ms-transform: rotate(90deg); + -o-transform: rotate(90deg); + transform: rotate(90deg); + content: "\f0da"; + font-family: ThemeIcons; +} + +.v-ie8 .mytheme .v-tree-node-expanded:before { + content: "\f0d7"; + font-family: ThemeIcons; +} + +.mytheme .v-tree-node-leaf:before, .mytheme .v-tree-node-leaf > .v-tree-node-caption > div:before { + visibility: hidden; +} + +.mytheme .v-tree-node-focused:after { + opacity: 1; + border: 1px solid #197de1; +} + +.v-ie8 .mytheme .v-tree-node-focused { + outline: 1px dotted #197de1; +} + +.mytheme .v-tree-node-selected { + color: #ecf2f8; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.05); +} + +.mytheme .v-tree-node-selected:after { + opacity: 1; + background-color: #197de1; + background-image: -webkit-linear-gradient(top, #1b87e3 2%, #166ed5 98%); + background-image: linear-gradient(to bottom,#1b87e3 2%, #166ed5 98%); + border: none; +} + +.v-ie8 .mytheme .v-tree-node-selected { + background-color: #197de1; + background-image: -webkit-linear-gradient(top, #1b87e3 2%, #166ed5 98%); + background-image: linear-gradient(to bottom,#1b87e3 2%, #166ed5 98%); +} + +.mytheme .v-tree-node-children { + padding-left: 19px; +} + +.v-ie8 .mytheme .v-tree-node-children { + padding-left: 0; +} + +.mytheme .v-tree-node-drag-top:before, .mytheme .v-tree-node-drag-bottom:after, .mytheme .v-tree-node-drag-bottom.v-tree-node-dragfolder.v-tree-node-expanded > .v-tree-node-children:before { + content: "\2022"; + display: block; + position: absolute; + height: 2px; + width: 100%; + background: #197de1; + font-size: 32px; + line-height: 2px; + color: #197de1; + text-indent: -4px; + text-shadow: 0 0 1px #fafafa, 0 0 1px #fafafa; + opacity: 1; + visibility: visible; +} + +.mytheme .v-tree-node-drag-bottom.v-tree-node-dragfolder.v-tree-node-expanded:after { + content: none; +} + +.mytheme .v-tree-node-caption-drag-center { + -webkit-box-shadow: 0 0 0 2px #197de1; + box-shadow: 0 0 0 2px #197de1; + position: relative; + border-radius: 4px; +} + +.v-ie8 .mytheme .v-tree-node-caption-drag-center { + outline: 2px solid #197de1; +} + +.v-ff .mytheme .v-tree-node-drag-top:before, .v-ff .mytheme .v-tree-node-drag-bottom:after { + line-height: 1px; +} + +.v-ie8 .mytheme .v-tree-node-drag-top:before, .v-ie8 .mytheme .v-tree-node-drag-bottom:after { + line-height: 0; +} + +.mytheme .v-table { + position: relative; + background: #fafafa; + color: #464646; + overflow: hidden; +} + +.mytheme .v-table-header table, .mytheme .v-table-footer table, .mytheme .v-table-table { + -webkit-box-shadow: 0 0 0 1px #d4d4d4; + box-shadow: 0 0 0 1px #d4d4d4; +} + +.v-ie8 .mytheme .v-table-header table, .v-ie8 .mytheme .v-table-footer table, .v-ie8 .mytheme .v-table-table { + outline: 1px solid #d4d4d4; +} + +.mytheme .v-table-header-wrap, .mytheme .v-table-footer-wrap, .mytheme .v-table-header-drag { + border: 1px solid #d4d4d4; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + white-space: nowrap; + font-size: 14px; + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.05); +} + +.mytheme .v-table-header-wrap { + position: relative; + border-bottom: none; +} + +.mytheme .v-table-footer-wrap { + border-top: none; +} + +.mytheme .v-table-footer td { + border-left: 1px solid #d4d4d4; +} + +.mytheme .v-table-footer-container, .mytheme .v-table-caption-container { + overflow: hidden; + line-height: 1; + min-height: 37px; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +.v-ie8 .mytheme .v-table-footer-container, .v-ie8 .mytheme .v-table-caption-container { + min-height: 14px; +} + +.mytheme .v-table-footer-container { + padding: 11px 12px 12px; + float: right; +} + +.mytheme [class^="v-table-header-cell"] { + position: relative; +} + +.mytheme .v-table-caption-container, .mytheme .v-table-header-drag { + padding: 12px 12px 11px; + border-left: 1px solid #d4d4d4; +} + +.mytheme .v-table-caption-container-align-right { + padding-right: 4px; +} + +.mytheme .v-table-resizer { + height: 37px; + width: 8px; + cursor: e-resize; + cursor: col-resize; + position: relative; + right: -4px; + z-index: 1; + margin-left: -8px; +} + +.mytheme .v-table-cell-content { + border-left: 1px solid #d4d4d4; + overflow: hidden; + height: 37px; + vertical-align: middle; +} + +.mytheme .v-table-cell-content:first-child { + border-left: none; + padding-left: 1px; +} + +.mytheme .v-table-header td:first-child .v-table-caption-container, .mytheme .v-table-footer td:first-child { + border-left-color: transparent; +} + +.mytheme .v-table-cell-wrapper { + line-height: 1; + padding: 0 12px; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + margin-right: 0 !important; +} + +.mytheme .v-table-cell-wrapper > .v-widget { + margin: 3px -6px; +} + +.mytheme .v-table-cell-wrapper > .v-widget.v-label, .mytheme .v-table-cell-wrapper > .v-widget.v-checkbox, .mytheme .v-table-cell-wrapper > .v-widget.v-select-optiongroup { + margin: 0; +} + +.mytheme .v-table-cell-wrapper > .v-widget.v-progressbar { + margin-left: 0; + margin-right: 0; +} + +.mytheme .v-table-body { + border: 1px solid #d4d4d4; + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; +} + +.mytheme .v-table-table { + background-color: white; + white-space: nowrap; +} + +.mytheme .v-table-table td { + border-top: 1px solid #d4d4d4; +} + +.mytheme .v-table-table tr:first-child > td { + border-top: none; +} + +.mytheme .v-table-row { + background-color: white; + cursor: pointer; +} + +.mytheme .v-table-row-odd { + background-color: #f5f5f5; + cursor: pointer; +} + +.mytheme .v-table-body-noselection .v-table-row, .mytheme .v-table-body-noselection .v-table-row-odd { + cursor: default; +} + +.mytheme .v-table [class*="-row"].v-selected { + background-color: #197de1; + background-image: -webkit-linear-gradient(top, #1b87e3 2%, #166ed5 98%); + background-image: linear-gradient(to bottom,#1b87e3 2%, #166ed5 98%); + background-origin: border-box; + color: #ecf2f8; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.05); +} + +.mytheme .v-table [class*="-row"].v-selected + .v-selected { + background: #166ed5; +} + +.mytheme .v-table [class*="-row"].v-selected + .v-selected td { + border-top-color: #166ed5; +} + +.mytheme .v-table [class*="-row"].v-selected .v-table-cell-content { + border-color: transparent; + border-left-color: #1d69b4; +} + +.mytheme .v-table [class*="-row"].v-selected .v-table-cell-content:first-child { + border-left-color: transparent; +} + +.mytheme .v-table-header-cell-asc .v-table-sort-indicator, .mytheme .v-table-header-cell-desc .v-table-sort-indicator { + background: transparent; + width: 19px; + height: 37px; + line-height: 37px; + margin-left: -19px; +} + +.mytheme .v-table-header-cell-asc .v-table-sort-indicator:before, .mytheme .v-table-header-cell-desc .v-table-sort-indicator:before { + font-style: normal; + font-weight: normal; + display: inline-block; +} + +.mytheme .v-table-header-cell-asc .v-table-sort-indicator:before { + content: "\f0de"; + font-family: ThemeIcons; +} + +.mytheme .v-table-header-cell-desc .v-table-sort-indicator:before { + content: "\f0dd"; + font-family: ThemeIcons; +} + +.mytheme [class*="rowheader"] span.v-icon { + min-width: 1em; +} + +.mytheme .v-table-focus { + outline: 1px solid #197de1; + outline-offset: -1px; +} + +.mytheme .v-drag-element.v-table-focus, .mytheme .v-drag-element .v-table-focus { + outline: none; +} + +.mytheme .v-table-header-drag { + position: absolute; + opacity: 0.9; + filter: alpha(opacity=90) ; + margin-top: -19px; + z-index: 30000; + line-height: 1; +} + +.mytheme .v-table-focus-slot-right { + border-right: 3px solid #197de1; + right: -2px; + margin-left: -11px !important; +} + +.mytheme .v-table-focus-slot-left { + float: left; + border-left: 3px solid #197de1; + left: -1px; + right: auto; + margin-left: 0 !important; + margin-right: -11px; +} + +.mytheme .v-table-column-selector { + height: 37px; + padding: 0 16px; + color: #191919; + font-weight: 400; + + + border-radius: 4px; + border: 1px solid #c5c5c5; + border-top-color: #c5c5c5; + border-bottom-color: #bcbcbc; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + -webkit-box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7; + box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7; + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.05); + position: absolute; + z-index: 2; + top: 0; + right: 0; + width: 19px; + height: 19px; + line-height: 19px; + padding: 0; + border-top-width: 0; + border-right-width: 0; + border-radius: 0 0 0 4px; + cursor: pointer; + text-align: center; + opacity: 0; + filter: alpha(opacity=0) ; + -webkit-transition: opacity 200ms 2s; + -moz-transition: opacity 200ms 2s; + transition: opacity 200ms 2s; +} + +.mytheme .v-table-column-selector:after { + border: inherit; + top: -1px; + right: -1px; + bottom: -1px; + left: -1px; +} + +.mytheme .v-table-column-selector:hover:after { + background-color: rgba(186, 186, 186, 0.1); +} + +.mytheme .v-table-column-selector:focus:after { + border-color: #197de1; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); +} + +.mytheme .v-table-column-selector:active:after { + background-color: rgba(125, 125, 125, 0.2); +} + +.mytheme .v-table-column-selector:after { + content: ""; + position: absolute; + border: none; + top: 0; + right: 0; + bottom: 0; + left: 0; +} + +.mytheme .v-table-column-selector:active:after { + background-color: rgba(125, 125, 125, 0.2); +} + +.mytheme .v-table-column-selector:before { + font-family: ThemeIcons; + content: "\f013"; +} + +.mytheme .v-table-header-wrap:hover .v-table-column-selector { + opacity: 1; + filter: none ; + -webkit-transition-delay: 200ms; + -moz-transition-delay: 200ms; + transition-delay: 200ms; +} + +.mytheme .v-on:before, .mytheme .v-off:before { + content: "\f00c"; + font-family: ThemeIcons; + font-size: 0.9em; + margin-right: 6px; +} + +.mytheme .v-on div, .mytheme .v-off div { + display: inline; +} + +.mytheme .v-on.v-disabled, .mytheme .v-off.v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-off:before { + visibility: hidden; +} + +.mytheme tbody.v-drag-element { + display: block; + overflow: visible; + -webkit-box-shadow: none; + box-shadow: none; + background: transparent; + opacity: 1; + filter: none ; +} + +.mytheme tbody.v-drag-element tr { + display: block; + + + -webkit-box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2); + box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2); + border-radius: 4px; + overflow: hidden; + opacity: 0.5; + filter: alpha(opacity=50) ; + background: white; +} + +.mytheme .v-table-body { + position: relative; + z-index: 1; +} + +.mytheme .v-table-scrollposition { + position: absolute; + top: 50%; + width: 100%; + height: 37px; + line-height: 37px; + margin: -19px 0 0 !important; + text-align: center; +} + +.mytheme .v-table-drag { + overflow: visible; +} + +.mytheme .v-table-drag .v-table-body { + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + border-color: #197de1; +} + +.v-ie8 .mytheme .v-table-drag .v-table-body { + border-color: #197de1; +} + +.mytheme .v-table-drag .v-table-body .v-table-focus { + outline: none; +} + +.mytheme .v-table-row-drag-middle .v-table-cell-content { + background-color: #d1e5f9; + color: #214060; +} + +.mytheme .v-table-row-drag-bottom td.v-table-cell-content { + border-bottom: 2px solid #197de1; + height: 35px; +} + +.mytheme .v-table-row-drag-bottom .v-table-cell-wrapper { + margin-bottom: -2px; +} + +.mytheme .v-table-row-drag-top td.v-table-cell-content { + border-top: 2px solid #197de1; + height: 36px; +} + +.mytheme .v-table-row-drag-top .v-table-cell-wrapper { + margin-top: -1px; +} + +.mytheme .v-table-no-stripes .v-table-row, .mytheme .v-table-no-stripes .v-table-row-odd { + background: transparent; +} + +.mytheme .v-table-no-vertical-lines .v-table-cell-content { + border-left: none; + padding-left: 1px; +} + +.mytheme .v-table-no-vertical-lines.v-treetable .v-table-cell-content { + padding-left: 13px; +} + +.mytheme .v-table-no-horizontal-lines .v-table-cell-content { + border-top: none; + border-bottom: none; +} + +.mytheme .v-table-no-horizontal-lines .v-table-row-drag-top .v-table-cell-content, .mytheme .v-table-no-horizontal-lines .v-table-row-drag-bottom .v-table-cell-content { + height: 36px; +} + +.mytheme .v-table-no-header .v-table-header-wrap { + display: none; +} + +.mytheme .v-table-borderless .v-table-header-wrap, .mytheme .v-table-borderless .v-table-footer-wrap, .mytheme .v-table-borderless .v-table-header-drag, .mytheme .v-table-borderless .v-table-body { + border: none; +} + +.mytheme .v-table-borderless .v-table-header-wrap { + border-bottom: 1px solid #d9d9d9; +} + +.mytheme .v-table-borderless .v-table-footer-wrap { + border-top: 1px solid #d9d9d9; +} + +.mytheme .v-table-compact .v-table-header-wrap, .mytheme .v-table-compact .v-table-footer-wrap, .mytheme .v-table-compact .v-table-header-drag, .mytheme .v-table-small .v-table-header-wrap, .mytheme .v-table-small .v-table-footer-wrap, .mytheme .v-table-small .v-table-header-drag { + font-size: 14px; +} + +.mytheme .v-table-compact .v-table-footer-container, .mytheme .v-table-small .v-table-footer-container { + padding: 8px 7px 9px; +} + +.mytheme .v-table-compact .v-table-caption-container, .mytheme .v-table-compact .v-table-header-drag, .mytheme .v-table-small .v-table-caption-container, .mytheme .v-table-small .v-table-header-drag { + padding-top: 9px; + padding-bottom: 8px; + padding-left: 6px; + padding-right: 6px; +} + +.mytheme .v-table-compact .v-table-caption-container-align-right, .mytheme .v-table-small .v-table-caption-container-align-right { + padding-right: 0; +} + +.mytheme .v-table-compact .v-table-resizer, .mytheme .v-table-small .v-table-resizer { + height: 31px; +} + +.mytheme .v-table-compact .v-table-cell-content, .mytheme .v-table-small .v-table-cell-content { + height: 31px; +} + +.mytheme .v-table-compact .v-table-cell-wrapper, .mytheme .v-table-small .v-table-cell-wrapper { + padding-left: 6px; + padding-right: 6px; +} + +.mytheme .v-table-compact .v-table-cell-wrapper > .v-widget, .mytheme .v-table-small .v-table-cell-wrapper > .v-widget { + margin: 2px -3px; +} + +.mytheme .v-table-compact .v-table-cell-wrapper > .v-widget.v-label, .mytheme .v-table-compact .v-table-cell-wrapper > .v-widget.v-checkbox, .mytheme .v-table-compact .v-table-cell-wrapper > .v-widget.v-select-optiongroup, .mytheme .v-table-small .v-table-cell-wrapper > .v-widget.v-label, .mytheme .v-table-small .v-table-cell-wrapper > .v-widget.v-checkbox, .mytheme .v-table-small .v-table-cell-wrapper > .v-widget.v-select-optiongroup { + margin: 0; +} + +.mytheme .v-table-compact .v-table-cell-wrapper > .v-widget.v-progressbar, .mytheme .v-table-small .v-table-cell-wrapper > .v-widget.v-progressbar { + margin-left: 0; + margin-right: 0; +} + +.mytheme .v-table-compact .v-table-header-cell-asc .v-table-sort-indicator, .mytheme .v-table-compact .v-table-header-cell-desc .v-table-sort-indicator, .mytheme .v-table-small .v-table-header-cell-asc .v-table-sort-indicator, .mytheme .v-table-small .v-table-header-cell-desc .v-table-sort-indicator { + height: 31px; + line-height: 31px; +} + +.mytheme .v-table-compact .v-table-header-drag, .mytheme .v-table-small .v-table-header-drag { + margin-top: -16px; +} + +.mytheme .v-table-compact.v-treetable .v-table-cell-wrapper, .mytheme .v-table-small.v-treetable .v-table-cell-wrapper { + padding-left: 0; + padding-right: 0; + min-height: 16px; +} + +.mytheme .v-table-compact.v-treetable .v-table-cell-content, .mytheme .v-table-small.v-treetable .v-table-cell-content { + padding-left: 6px; + padding-right: 6px; +} + +.mytheme .v-table-compact.v-treetable .v-table-cell-content:first-child, .mytheme .v-table-small.v-treetable .v-table-cell-content:first-child { + padding-left: 7px; +} + +.mytheme .v-table-compact.v-treetable .v-table-footer-container, .mytheme .v-table-small.v-treetable .v-table-footer-container { + padding-left: 6px; + padding-right: 6px; +} + +.mytheme .v-table-compact .v-table-row-drag-top .v-table-cell-content, .mytheme .v-table-compact .v-table-row-drag-bottom .v-table-cell-content, .mytheme .v-table-small .v-table-row-drag-top .v-table-cell-content, .mytheme .v-table-small .v-table-row-drag-bottom .v-table-cell-content { + height: 30px; +} + +.mytheme .v-table-small { + font-size: 14px; +} + +.mytheme .v-table-small.v-treetable .v-table-cell-wrapper { + min-height: 14px; +} + +.mytheme .v-treetable [class*="caption-container"], .mytheme .v-treetable [class*="footer-container"], .mytheme .v-treetable [class*="cell-wrapper"] { + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + padding-left: 0; + padding-right: 0; +} + +.mytheme .v-treetable [class*="caption-container"], .mytheme .v-treetable [class*="footer-container"] { + min-height: 14px; +} + +.mytheme .v-treetable [class*="cell-wrapper"] { + min-height: 16px; +} + +.mytheme .v-treetable [class*="caption-container"] { + padding-left: 12px; +} + +.mytheme .v-treetable [class*="caption-container-align-right"] { + padding-left: 20px; +} + +.mytheme .v-treetable [class*="footer-container"] { + padding-right: 12px; +} + +.mytheme .v-treetable [class*="cell-content"] { + padding-left: 12px; + padding-right: 12px; +} + +.mytheme .v-treetable [class*="cell-content"]:first-child { + padding-left: 13px; +} + +.mytheme .v-treetable-treespacer { + display: inline-block; + position: absolute; + width: 19px !important; + margin-left: -25px; + text-align: center; + cursor: pointer; +} + +.mytheme .v-treetable-node-closed:before { + content: "\f0da"; + font-family: ThemeIcons; +} + +.mytheme .v-treetable-node-open:before { + content: "\f0d7"; + font-family: ThemeIcons; +} + +.mytheme .v-splitpanel-horizontal > div > .v-splitpanel-hsplitter { + width: 1px; +} + +.mytheme .v-splitpanel-horizontal > div > .v-splitpanel-hsplitter:after { + left: -6px; + right: -6px; +} + +.mytheme .v-splitpanel-horizontal > div > .v-splitpanel-hsplitter div:before { + height: 37px; + padding: 0 16px; + color: #191919; + font-weight: 400; + + + border-radius: 4px; + border: 1px solid #c5c5c5; + border-top-color: #c5c5c5; + border-bottom-color: #bcbcbc; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + -webkit-box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, none; + box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, none; + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.05); + height: auto; + padding: 0; + border-radius: 0; + background-color: #fafafa; + background-image: -webkit-linear-gradient(left, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to right,#fafafa 2%, #efefef 98%); +} + +.mytheme .v-splitpanel-horizontal > div > .v-splitpanel-hsplitter div:before:after { + border: inherit; + top: -1px; + right: -1px; + bottom: -1px; + left: -1px; +} + +.mytheme .v-splitpanel-horizontal > div > .v-splitpanel-hsplitter div:before:hover:after { + background-color: rgba(186, 186, 186, 0.1); +} + +.mytheme .v-splitpanel-horizontal > div > .v-splitpanel-hsplitter div:before:focus:after { + border-color: #197de1; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); +} + +.mytheme .v-splitpanel-horizontal > div > .v-splitpanel-hsplitter div:before:active:after { + background-color: rgba(125, 125, 125, 0.2); +} + +.mytheme .v-splitpanel-horizontal > div > .v-splitpanel-second-container { + margin-left: 1px; +} + +.mytheme .v-splitpanel-vertical > div > .v-splitpanel-vsplitter { + height: 1px; +} + +.mytheme .v-splitpanel-vertical > div > .v-splitpanel-vsplitter:after { + top: -6px; + bottom: -6px; +} + +.mytheme .v-splitpanel-vertical > div > .v-splitpanel-vsplitter div:before { + height: 37px; + padding: 0 16px; + color: #191919; + font-weight: 400; + + + border-radius: 4px; + border: 1px solid #c5c5c5; + border-top-color: #c5c5c5; + border-bottom-color: #bcbcbc; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + -webkit-box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, none; + box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, none; + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.05); + height: auto; + padding: 0; + border-radius: 0; +} + +.mytheme .v-splitpanel-vertical > div > .v-splitpanel-vsplitter div:before:after { + border: inherit; + top: -1px; + right: -1px; + bottom: -1px; + left: -1px; +} + +.mytheme .v-splitpanel-vertical > div > .v-splitpanel-vsplitter div:before:hover:after { + background-color: rgba(186, 186, 186, 0.1); +} + +.mytheme .v-splitpanel-vertical > div > .v-splitpanel-vsplitter div:before:focus:after { + border-color: #197de1; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); +} + +.mytheme .v-splitpanel-vertical > div > .v-splitpanel-vsplitter div:before:active:after { + background-color: rgba(125, 125, 125, 0.2); +} + +.mytheme .v-splitpanel-horizontal.large > div > .v-splitpanel-hsplitter { + width: 12px; +} + +.mytheme .v-splitpanel-horizontal.large > div > .v-splitpanel-hsplitter:after { + left: 0px; + right: 0px; +} + +.mytheme .v-splitpanel-horizontal.large > div > .v-splitpanel-hsplitter div:before { + height: 37px; + padding: 0 16px; + color: #191919; + font-weight: 400; + + + border-radius: 4px; + border: 1px solid #c5c5c5; + border-top-color: #c5c5c5; + border-bottom-color: #bcbcbc; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + -webkit-box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, none; + box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, none; + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.05); + height: auto; + padding: 0; + border-radius: 0; + background-color: #fafafa; + background-image: -webkit-linear-gradient(left, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to right,#fafafa 2%, #efefef 98%); +} + +.mytheme .v-splitpanel-horizontal.large > div > .v-splitpanel-hsplitter div:before:after { + border: inherit; + top: -1px; + right: -1px; + bottom: -1px; + left: -1px; +} + +.mytheme .v-splitpanel-horizontal.large > div > .v-splitpanel-hsplitter div:before:hover:after { + background-color: rgba(186, 186, 186, 0.1); +} + +.mytheme .v-splitpanel-horizontal.large > div > .v-splitpanel-hsplitter div:before:focus:after { + border-color: #197de1; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); +} + +.mytheme .v-splitpanel-horizontal.large > div > .v-splitpanel-hsplitter div:before:active:after { + background-color: rgba(125, 125, 125, 0.2); +} + +.mytheme .v-splitpanel-horizontal.large > div > .v-splitpanel-hsplitter div:after { + content: ""; + border: 1px solid #dadada; + border-top-color: #bababa; + border-left-color: #bababa; + position: absolute; + top: 50%; + left: 50%; + width: 0; + height: 37px; + margin-left: -1px; + margin-top: -19px; +} + +.mytheme .v-splitpanel-horizontal.large > div > .v-splitpanel-second-container { + margin-left: 12px; +} + +.mytheme .v-splitpanel-vertical.large > div > .v-splitpanel-vsplitter { + height: 12px; +} + +.mytheme .v-splitpanel-vertical.large > div > .v-splitpanel-vsplitter:after { + top: 0px; + bottom: 0px; +} + +.mytheme .v-splitpanel-vertical.large > div > .v-splitpanel-vsplitter div:before { + height: 37px; + padding: 0 16px; + color: #191919; + font-weight: 400; + + + border-radius: 4px; + border: 1px solid #c5c5c5; + border-top-color: #c5c5c5; + border-bottom-color: #bcbcbc; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + -webkit-box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, none; + box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, none; + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.05); + height: auto; + padding: 0; + border-radius: 0; +} + +.mytheme .v-splitpanel-vertical.large > div > .v-splitpanel-vsplitter div:before:after { + border: inherit; + top: -1px; + right: -1px; + bottom: -1px; + left: -1px; +} + +.mytheme .v-splitpanel-vertical.large > div > .v-splitpanel-vsplitter div:before:hover:after { + background-color: rgba(186, 186, 186, 0.1); +} + +.mytheme .v-splitpanel-vertical.large > div > .v-splitpanel-vsplitter div:before:focus:after { + border-color: #197de1; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); +} + +.mytheme .v-splitpanel-vertical.large > div > .v-splitpanel-vsplitter div:before:active:after { + background-color: rgba(125, 125, 125, 0.2); +} + +.mytheme .v-splitpanel-vertical.large > div > .v-splitpanel-vsplitter div:after { + content: ""; + border: 1px solid #dadada; + border-top-color: #bababa; + border-left-color: #bababa; + position: absolute; + top: 50%; + left: 50%; + width: 37px; + height: 0; + margin-left: -19px; + margin-top: -1px; +} + +.mytheme .v-progressbar-wrapper { + border-radius: 4px; + height: 9px; + background-color: #d4d4d4; + background-image: -webkit-linear-gradient(bottom, #d7d7d7 2%, #c7c7c7 98%); + background-image: linear-gradient(to top,#d7d7d7 2%, #c7c7c7 98%); + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + min-width: 74px; +} + +.mytheme .v-progressbar-indicator { + border-radius: 4px; + height: inherit; + background-color: #197de1; + background-image: -webkit-linear-gradient(top, #1b87e3 2%, #166ed5 98%); + background-image: linear-gradient(to bottom,#1b87e3 2%, #166ed5 98%); + + + border: 1px solid #1362b1; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + max-width: 100%; + min-width: 8px; + -webkit-transition: width 160ms; + -moz-transition: width 160ms; + transition: width 160ms; +} + +.mytheme .v-progressbar-point .v-progressbar-indicator { + background: transparent; + -webkit-box-shadow: none; + box-shadow: none; + border: none; + text-align: right; + overflow: hidden; +} + +.mytheme .v-progressbar-point .v-progressbar-indicator:before { + content: ""; + display: inline-block; + border-radius: 4px; + height: inherit; + background-color: #197de1; + background-image: -webkit-linear-gradient(top, #1b87e3 2%, #166ed5 98%); + background-image: linear-gradient(to bottom,#1b87e3 2%, #166ed5 98%); + + + border: 1px solid #1362b1; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + max-width: 100%; + width: 9px; + vertical-align: top; +} + +.mytheme .v-progressbar-indeterminate { + height: 24px !important; + width: 24px !important; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + border: 2px solid rgba(25, 125, 225, 0.2); + border-top-color: #197de1; + border-right-color: #197de1; + border-radius: 100%; + -webkit-animation: v-rotate-360 500ms infinite linear; + -moz-animation: v-rotate-360 500ms infinite linear; + animation: v-rotate-360 500ms infinite linear; + pointer-events: none; +} + +.v-ie8 .mytheme .v-progressbar-indeterminate, .v-ie9 .mytheme .v-progressbar-indeterminate { + border: none; + border-radius: 4px; + background: #fff url(../valo/shared/img/spinner.gif) no-repeat 50% 50%; + background-size: 80%; +} + +.v-ie8 .mytheme .v-progressbar-indeterminate { + min-width: 30px; + min-height: 30px; +} + +.mytheme .v-progressbar-indeterminate .v-progressbar-wrapper { + display: none; +} + +.mytheme .v-slider { + position: relative; +} + +.mytheme .v-slider:focus { + outline: none; +} + +.mytheme .v-slider:focus .v-slider-handle:after { + opacity: 1; +} + +.v-ie8 .mytheme .v-slider:focus .v-slider-handle:after { + visibility: visible; +} + +.mytheme .v-slider.v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-slider-base { + border-radius: 4px; + height: 9px; + background-color: #d4d4d4; + background-image: -webkit-linear-gradient(bottom, #d7d7d7 2%, #c7c7c7 98%); + background-image: linear-gradient(to top,#d7d7d7 2%, #c7c7c7 98%); + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + min-width: 74px; + height: 6px; + margin: 16px 11px; + white-space: nowrap; + overflow: hidden; + +} + +.mytheme .v-slider-base:before { + content: ""; + position: absolute; + top: 16px; + bottom: 16px; + left: 11px; + width: 8px; + border-radius: 4px; + border-left: 1px solid #1362b1; +} + +.mytheme .v-slider-base:after { + border-radius: 4px; + height: inherit; + background-color: #197de1; + background-image: -webkit-linear-gradient(top, #1b87e3 2%, #166ed5 98%); + background-image: linear-gradient(to bottom,#1b87e3 2%, #166ed5 98%); + + + border: 1px solid #1362b1; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + max-width: 100%; + content: ""; + display: inline-block; + margin-left: -100%; + width: 100%; + vertical-align: top; +} + +.v-ie8 .mytheme .v-slider-base:after { + position: relative; + left: -11px; +} + +.mytheme .v-has-width > .v-slider-base { + min-width: 0; +} + +.mytheme .v-slider-handle { + margin-top: -16px; + width: 0.1px; + display: inline-block; + vertical-align: top; +} + +.mytheme .v-slider-handle:before { + height: 37px; + padding: 0 16px; + color: #191919; + font-weight: 400; + + + border-radius: 4px; + border: 1px solid #c5c5c5; + border-top-color: #c5c5c5; + border-bottom-color: #bcbcbc; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + -webkit-box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7, 0 2px 3px rgba(0, 0, 0, 0.05); + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.05); +} + +.mytheme .v-slider-handle:before:after { + border: inherit; + top: -1px; + right: -1px; + bottom: -1px; + left: -1px; +} + +.mytheme .v-slider-handle:before:hover:after { + background-color: rgba(186, 186, 186, 0.1); +} + +.mytheme .v-slider-handle:before:focus:after { + border-color: #197de1; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); +} + +.mytheme .v-slider-handle:before:active:after { + background-color: rgba(125, 125, 125, 0.2); +} + +.mytheme .v-slider-handle:after { + border: 1px solid #c5c5c5; + border-color: #197de1; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + opacity: 0; + -webkit-transition: opacity 200ms; + -moz-transition: opacity 200ms; + transition: opacity 200ms; +} + +.v-ie8 .mytheme .v-slider-handle:after { + visibility: hidden; +} + +.mytheme .v-slider-handle:before, .mytheme .v-slider-handle:after { + content: ""; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + padding: 0; + width: 22px; + height: 22px; + border-radius: 11px; + position: absolute; + z-index: 1; + margin-top: 8px; + margin-left: -11px; +} + +.mytheme .v-slider-feedback { + background-color: #323232; + background-color: rgba(50, 50, 50, 0.9); + -webkit-box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2); + box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2); + color: white; + padding: 5px 9px; + border-radius: 3px; + max-width: 35em; + overflow: hidden !important; + font-size: 14px; +} + +.mytheme .v-slider-vertical { + padding: 11px 0; + height: 96px; +} + +.mytheme .v-slider-vertical .v-slider-base { + background-color: #d4d4d4; + background-image: -webkit-linear-gradient(right, #d7d7d7 2%, #c7c7c7 98%); + background-image: linear-gradient(to left,#d7d7d7 2%, #c7c7c7 98%); + width: 6px; + height: 100% !important; + min-width: 0; + margin: 0 16px; +} + +.mytheme .v-slider-vertical .v-slider-base:before { + top: auto; + bottom: 11px; + left: 16px; + right: 16px; + width: auto; + height: 8px; + border-left: none; + border-bottom: 1px solid #1362b1; +} + +.mytheme .v-slider-vertical .v-slider-base:after { + height: 101%; + margin-left: 0; + background-color: #197de1; + background-image: -webkit-linear-gradient(left, #1b87e3 2%, #166ed5 98%); + background-image: linear-gradient(to right,#1b87e3 2%, #166ed5 98%); +} + +.v-ie8 .mytheme .v-slider-vertical .v-slider-base:after { + top: 11px; + left: 0; + height: 130%; +} + +.mytheme .v-slider-vertical .v-slider-handle { + width: 0; + height: 0.1px; + width: 37px; + display: block; +} + +.mytheme .v-slider-vertical .v-slider-handle:before, .mytheme .v-slider-vertical .v-slider-handle:after { + width: 22px; + height: 22px; + margin-top: -11px; + margin-left: -8px; +} + +.mytheme .v-slider-no-indicator .v-slider-base:before, .mytheme .v-slider-no-indicator .v-slider-base:after { + display: none; +} + +.mytheme .v-tabsheet:not(.v-has-width) { + width: auto !important; +} + +.mytheme .v-tabsheet-spacertd { + display: none !important; +} + +.mytheme .v-tabsheet-tabcontainer { + position: relative; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +.mytheme .v-tabsheet-tabcontainer:before { + content: ""; + position: absolute; + height: 0; + border-top: 1px solid #dfdfdf; + bottom: 0; + left: 0; + right: 0; +} + +.mytheme .v-tabsheet-tabcontainer .v-tabsheet-tabs { + position: relative; +} + +.mytheme .v-tabsheet-tabitemcell { + vertical-align: bottom; +} + +.mytheme .v-tabsheet-tabitemcell .v-tabsheet-tabitem { + line-height: 0; + overflow: hidden; +} + +.mytheme .v-tabsheet-tabitemcell .v-caption { + margin-left: 19px; + padding: 0 4px; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + cursor: pointer; + text-align: center; + line-height: 37px; + font-size: 15px; + font-weight: 300; + color: #696969; + width: auto !important; + overflow: hidden; + text-overflow: ellipsis; + border-bottom: 2px solid transparent; + position: relative; + -webkit-transition: border-bottom 200ms, color 200ms; + -moz-transition: border-bottom 200ms, color 200ms; + transition: border-bottom 200ms, color 200ms; +} + +.mytheme .v-tabsheet-tabitemcell .v-caption .v-captiontext { + display: inline; +} + +.mytheme .v-tabsheet-tabitemcell .v-caption .v-icon + .v-captiontext { + margin-left: 9px; +} + +.mytheme .v-tabsheet-tabitemcell .v-caption:hover { + color: #197de1; +} + +.mytheme .v-tabsheet-tabitemcell .v-caption.v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; + cursor: default; + color: inherit !important; +} + +.mytheme .v-tabsheet-tabitemcell:first-child .v-caption, .mytheme .v-tabsheet-tabitemcell[aria-hidden="true"] + td .v-caption { + margin-left: 0; +} + +.mytheme .v-tabsheet-tabitemcell:focus { + outline: none; +} + +.mytheme .v-tabsheet-tabitemcell:focus .v-caption { + color: #197de1; +} + +.mytheme .v-tabsheet-tabitemcell .v-tabsheet-tabitem-selected .v-caption.v-caption { + border-bottom-color: #197de1; + color: #197de1; +} + +.mytheme .v-tabsheet-tabitemcell .v-caption-closable { + padding-right: 22px; +} + +.mytheme .v-tabsheet-tabitemcell.icons-on-top .v-caption-closable { + padding-right: 4px; +} + +.mytheme .v-tabsheet-tabitemcell .v-tabsheet-caption-close { + position: absolute; + right: 0; + top: 50%; + margin: -8px 0 0; + font-size: 18px; + line-height: 18px; + width: 18px; + text-align: center; + border-radius: 2px; + color: #969696; +} + +.mytheme .v-tabsheet-tabitemcell .v-tabsheet-caption-close:hover { + background: rgba(0, 0, 0, 0.03); + color: #197de1; +} + +.mytheme .v-tabsheet-tabitemcell .v-tabsheet-caption-close:active { + background: #197de1; + color: #c8dbed; +} + +.mytheme .v-tabsheet-scroller { + position: absolute; + top: 0; + right: 0; + bottom: 0; + padding-left: 19px; + background-color: transparent; + background-image: -webkit-linear-gradient(right, #fafafa 70%, rgba(250, 250, 250, 0) 100%); + background-image: linear-gradient(to left,#fafafa 70%, rgba(250, 250, 250, 0) 100%); + pointer-events: none; +} + +.mytheme .v-tabsheet-scroller:after { + content: ""; + height: 1px; + position: absolute; + bottom: 0; + left: 0; + right: 0; + display: block; + background-color: transparent; + background-image: -webkit-linear-gradient(right, #dfdfdf 70%, rgba(223, 223, 223, 0) 100%); + background-image: linear-gradient(to left,#dfdfdf 70%, rgba(223, 223, 223, 0) 100%); +} + +.v-ie8 .mytheme .v-tabsheet-scroller, .v-ie9 .mytheme .v-tabsheet-scroller { + background-color: #fafafa; +} + +.v-ie8 .mytheme .v-tabsheet-scroller:after, .v-ie9 .mytheme .v-tabsheet-scroller:after { + background-color: #dfdfdf; +} + +.mytheme .v-tabsheet-scroller button { + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + border: none; + background: transparent; + font: inherit; + color: inherit; + height: 100%; + margin: 0; + padding: 0 9px; + outline: none; + cursor: pointer; + pointer-events: auto; + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-tabsheet-scroller button:hover { + opacity: 1; + filter: none ; + color: #197de1; +} + +.mytheme .v-tabsheet-scroller button:active { + opacity: 0.7; + filter: alpha(opacity=70) ; + color: #197de1; +} + +.mytheme .v-tabsheet-scroller button::-moz-focus-inner { + padding: 0; + border: 0; +} + +.mytheme .v-tabsheet-scroller [class*="Next"] { + padding-left: 5px; +} + +.mytheme .v-tabsheet-scroller [class*="Next"]:before { + font-family: ThemeIcons; + content: "\f054"; +} + +.mytheme .v-tabsheet-scroller [class*="Prev"] { + padding-right: 5px; +} + +.mytheme .v-tabsheet-scroller [class*="Prev"]:before { + font-family: ThemeIcons; + content: "\f053"; +} + +.mytheme .v-tabsheet-scroller [class*="disabled"] { + cursor: default; + color: inherit !important; + opacity: 0.1 !important; + filter: alpha(opacity=10) !important; +} + +.mytheme .v-tabsheet-tabsheetpanel > .v-scrollable > .v-widget { + -webkit-animation: valo-animate-in-fade 300ms backwards; + -moz-animation: valo-animate-in-fade 300ms backwards; + animation: valo-animate-in-fade 300ms backwards; +} + +.mytheme .v-tabsheet-deco { + height: 20px !important; + width: 20px !important; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + border: 2px solid rgba(25, 125, 225, 0.2); + border-top-color: #197de1; + border-right-color: #197de1; + border-radius: 100%; + -webkit-animation: v-rotate-360 500ms infinite linear; + -moz-animation: v-rotate-360 500ms infinite linear; + animation: v-rotate-360 500ms infinite linear; + pointer-events: none; + display: none; + position: absolute; + z-index: 1; + bottom: 50%; + margin-bottom: -29px; + left: 50%; + margin-left: -10px; +} + +.v-ie8 .mytheme .v-tabsheet-deco, .v-ie9 .mytheme .v-tabsheet-deco { + border: none; + border-radius: 4px; + background: #fff url(../valo/shared/img/spinner.gif) no-repeat 50% 50%; + background-size: 80%; +} + +.v-ie8 .mytheme .v-tabsheet-deco { + min-width: 30px; + min-height: 30px; +} + +.mytheme .v-tabsheet-loading .v-tabsheet-deco { + display: block; +} + +.mytheme .v-tabsheet-equal-width-tabs > .v-tabsheet-tabcontainer table, .mytheme .v-tabsheet-equal-width-tabs > .v-tabsheet-tabcontainer tbody, .mytheme .v-tabsheet-equal-width-tabs > .v-tabsheet-tabcontainer tr { + width: 100%; +} + +.mytheme .v-tabsheet-equal-width-tabs > .v-tabsheet-tabcontainer tr { + display: table; + table-layout: fixed; +} + +.mytheme .v-tabsheet-equal-width-tabs > .v-tabsheet-tabcontainer td { + display: table-cell; +} + +.mytheme .v-tabsheet-equal-width-tabs > .v-tabsheet-tabcontainer .v-caption { + margin: 0; + display: block; +} + +.mytheme .v-tabsheet-framed > .v-tabsheet-tabcontainer .v-caption { + margin-left: 4px; + padding: 0 12px; + background-color: #fafafa; + border: 1px solid transparent; + line-height: 36px; + border-radius: 4px 4px 0 0; + font-weight: 400; + -webkit-transition: background-color 160ms; + -moz-transition: background-color 160ms; + transition: background-color 160ms; +} + +.mytheme .v-tabsheet-framed > .v-tabsheet-tabcontainer .v-caption:hover { + background-color: #f2f2f2; + border-bottom-color: #dfdfdf; +} + +.mytheme .v-tabsheet-framed > .v-tabsheet-tabcontainer .v-caption.v-disabled:hover { + background-color: #fafafa; +} + +.mytheme .v-tabsheet-framed > .v-tabsheet-tabcontainer .v-caption-closable { + padding-right: 30px; +} + +.mytheme .v-tabsheet-framed > .v-tabsheet-tabcontainer .v-tabsheet-caption-close { + top: 4px; + right: 4px; + margin-top: 0; +} + +.mytheme .v-tabsheet-framed > .v-tabsheet-tabcontainer td:first-child .v-caption, .mytheme .v-tabsheet-framed > .v-tabsheet-tabcontainer [aria-hidden="true"] + td .v-caption { + margin-left: 0; +} + +.mytheme .v-tabsheet-framed > .v-tabsheet-tabcontainer .v-tabsheet-tabitem .v-caption { + border-color: #dfdfdf; +} + +.mytheme .v-tabsheet-framed > .v-tabsheet-tabcontainer .v-tabsheet-tabitem-selected .v-caption { + background: white; + border-color: #dfdfdf; + border-bottom: none; + padding-bottom: 1px; +} + +.mytheme .v-tabsheet-framed > .v-tabsheet-content { + border: 1px solid #dfdfdf; + border-top: none; +} + +.mytheme .v-tabsheet-framed > .v-tabsheet-content > div { + background: white; +} + +.mytheme .v-tabsheet-framed.padded-tabbar > .v-tabsheet-tabcontainer { + border: 1px solid #dfdfdf; + border-bottom: none; + background: #fafafa; + padding-top: 6px; +} + +.mytheme .v-tabsheet-framed.icons-on-top > .v-tabsheet-tabcontainer .v-tabsheet-tabitem-selected .v-caption { + padding-bottom: 7px; +} + +.mytheme .v-tabsheet-centered-tabs > .v-tabsheet-tabcontainer { + text-align: center; +} + +.mytheme .v-tabsheet-right-aligned-tabs > .v-tabsheet-tabcontainer { + text-align: right; +} + +.mytheme .v-tabsheet-padded-tabbar > .v-tabsheet-tabcontainer .v-tabsheet-tabs { + padding: 0 9px; +} + +.mytheme .v-tabsheet-icons-on-top > .v-tabsheet-tabcontainer .v-caption { + padding-top: 6px; + padding-bottom: 6px; + line-height: 1.2; +} + +.mytheme .v-tabsheet-icons-on-top > .v-tabsheet-tabcontainer .v-icon { + display: block; +} + +.mytheme .v-tabsheet-icons-on-top > .v-tabsheet-tabcontainer .v-icon + .v-captiontext.v-captiontext { + margin-left: 0; +} + +.mytheme .v-tabsheet-icons-on-top > .v-tabsheet-tabcontainer .v-caption-closable { + padding-right: 12px; +} + +.mytheme .v-tabsheet-icons-on-top > .v-tabsheet-tabcontainer .v-tabsheet-caption-close { + top: 4px; + margin-top: 0; +} + +.mytheme .v-tabsheet-compact-tabbar > .v-tabsheet-tabcontainer-compact-tabbar .v-caption { + line-height: 1.8; +} + +.mytheme .v-tabsheet-only-selected-closable > .v-tabsheet-tabcontainer .v-tabsheet-caption-close { + visibility: hidden; +} + +.mytheme .v-tabsheet-only-selected-closable > .v-tabsheet-tabcontainer .v-tabsheet-tabitem-selected .v-tabsheet-caption-close { + visibility: visible; +} + +.mytheme .v-colorpicker-popup.v-window { + min-width: 220px !important; +} + +.mytheme .v-colorpicker-popup .v-tabsheet-tabs { + padding: 0 9px; +} + +.mytheme .v-colorpicker-popup [class$="sliders"] { + padding: 12px; +} + +.mytheme .v-colorpicker-popup [class$="sliders"] .v-widget { + width: 100% !important; + vertical-align: middle; +} + +.mytheme .v-colorpicker-popup [class$="sliders"] .v-has-caption { + white-space: nowrap; + padding-left: 48px; +} + +.mytheme .v-colorpicker-popup [class$="sliders"] .v-caption { + display: inline-block; + margin-left: -48px; + width: 48px; +} + +.mytheme .v-colorpicker-popup [class$="sliders"] .v-slot-hue-slider + .v-slot .v-has-caption { + padding-left: 80px; +} + +.mytheme .v-colorpicker-popup [class$="sliders"] .v-slot-hue-slider + .v-slot .v-caption { + margin-left: -80px; + width: 80px; +} + +.mytheme .v-colorpicker-popup .v-slider-red .v-slider-base:after { + background: red; + border: none; + -webkit-box-shadow: none; + box-shadow: none; +} + +.mytheme .v-colorpicker-popup .v-slider-green .v-slider-base:after { + background: green; + border: none; + -webkit-box-shadow: none; + box-shadow: none; +} + +.mytheme .v-colorpicker-popup .v-slider-blue .v-slider-base:after { + background: blue; + border: none; + -webkit-box-shadow: none; + box-shadow: none; +} + +.mytheme .v-colorpicker-popup .v-margin-bottom { + padding-bottom: 0; +} + +.mytheme .v-colorpicker-popup .resize-button { + width: 100% !important; + height: auto !important; + text-align: center; + outline: none; +} + +.mytheme .v-colorpicker-popup .resize-button:before { + font-family: ThemeIcons; + content: "\f141"; +} + +.mytheme .v-colorpicker-popup .resize-button-caption { + display: none; +} + +.mytheme .v-colorpicker-popup .v-horizontallayout { + height: auto !important; + padding: 9px 0; + background-color: #fafafa; + border-top: 1px solid #ededed; +} + +.mytheme .v-colorpicker-popup .v-horizontallayout .v-expand { + overflow: visible; +} + +.mytheme .v-colorpicker-popup .v-horizontallayout .v-button { + width: 80% !important; +} + +.mytheme .v-colorpicker-preview { + width: 100% !important; + height: auto !important; + padding: 9px; +} + +.mytheme .v-colorpicker-preview-textfield { + height: auto !important; + text-align: center; + border: none; +} + +.mytheme .v-colorpicker { + width: auto; +} + +.mytheme .v-colorpicker-button-color { + position: absolute; + top: 6px; + right: 6px; + bottom: 6px; + left: 6px; + border-radius: 3px; + border: 1px solid rgba(0, 0, 0, 0.5); + max-width: 23px; +} + +.mytheme .v-colorpicker-button-color + .v-button-caption:not(:empty) { + margin-left: 19px; +} + +.v-ie8 .mytheme .v-colorpicker-button-color { + position: relative; + top: auto; + right: auto; + bottom: auto; + left: auto; + width: 16px; + height: 16px; + display: inline-block; + vertical-align: middle; + margin: 0 -8px; +} + +.v-ie8 .mytheme .v-colorpicker-button-color + .v-button-caption { + margin-left: 19px; +} + +.mytheme .v-panel { + background: white; + color: #474747; + border-radius: 4px; + border: 1px solid #d5d5d5; + -webkit-box-shadow: 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: 0 2px 3px rgba(0, 0, 0, 0.05); + overflow: visible !important; +} + +.mytheme .v-panel-caption { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + padding: 0 12px; + line-height: 36px; + border-bottom: 1px solid #d5d5d5; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #f6f6f6 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #f6f6f6 98%); + color: #464646; + font-weight: 400; + font-size: 14px; + -webkit-box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #eeeeee; + box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #eeeeee; + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.05); + border-radius: 3px 3px 0 0; +} + +.mytheme .v-panel-content { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + width: 100%; + height: 100%; +} + +.mytheme .v-panel-content > .v-margin-top { + padding-top: 12px; +} + +.mytheme .v-panel-content > .v-margin-right { + padding-right: 12px; +} + +.mytheme .v-panel-content > .v-margin-bottom { + padding-bottom: 12px; +} + +.mytheme .v-panel-content > .v-margin-left { + padding-left: 12px; +} + +.mytheme .v-panel-borderless { + background: transparent; + color: inherit; + border: none; + border-radius: 0; + -webkit-box-shadow: none; + box-shadow: none; +} + +.mytheme .v-panel-borderless > div > [class*="-caption"] { + background: transparent; + -webkit-box-shadow: none; + box-shadow: none; + color: inherit; + padding: 0; + margin: 0 12px; + border-bottom: none; +} + +.mytheme .v-panel-well { + background: #f5f5f5; + color: #454545; + -webkit-box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.05), inset 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.05), inset 0 2px 3px rgba(0, 0, 0, 0.05); + border-radius: 4px; + border: 1px solid #c5c5c5; +} + +.mytheme .v-panel-well > div > [class*="-caption"] { + background: transparent; + -webkit-box-shadow: none; + box-shadow: none; +} + +.mytheme .v-panel-scroll-divider > [class*="-captionwrap"] { + position: relative; + z-index: 2; +} + +.mytheme .v-panel-scroll-divider > [class*="-captionwrap"]:after { + content: ""; + position: absolute; + bottom: -1px; + right: 0; + left: 0; + height: 0; + border-top: 1px solid #dfdfdf; + border-color: rgba(197, 197, 197, 0.5); +} + +.mytheme .v-panel-scroll-divider > [class*="-content"]:before { + content: ""; + position: absolute; + z-index: 2; + top: 0; + height: 0; + border-top: 1px solid #fafafa; + left: 0; + right: 0; +} + +.mytheme .v-panel-caption.v-horizontallayout { + height: auto !important; + line-height: 0; +} + +.mytheme .v-panel-caption.v-horizontallayout .v-slot { + vertical-align: middle; +} + +.mytheme .v-panel-caption.v-horizontallayout .v-label { + line-height: 37px; +} + +.mytheme .v-accordion { + background: white; + color: #474747; + border-radius: 4px; + border: 1px solid #d5d5d5; + -webkit-box-shadow: 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: 0 2px 3px rgba(0, 0, 0, 0.05); + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #f4f4f4 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #f4f4f4 98%); + overflow: hidden; +} + +.mytheme .v-accordion-item { + position: relative; +} + +.mytheme .v-accordion-item:first-child { + border-top-left-radius: 3px; + border-top-right-radius: 3px; +} + +.mytheme .v-accordion-item:last-child { + border-bottom-left-radius: 3px; + border-bottom-right-radius: 3px; +} + +.mytheme .v-accordion-item:last-child [class*="item-content"] { + border-radius: inherit; +} + +.mytheme .v-accordion-item[class*="item-open"]:last-child > div > .v-caption { + border-radius: 0; +} + +.mytheme .v-accordion-item:not([class*="item-open"]):last-child > div > .v-caption { + border-bottom: none; + margin-bottom: 0; +} + +.mytheme .v-accordion-item[class*="item-open"] + [class*="item"] { + border-top: 1px solid #d9d9d9; +} + +.mytheme .v-accordion-item-caption { + border-radius: inherit; +} + +.mytheme .v-accordion-item-caption > .v-caption { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + padding: 0 12px; + line-height: 36px; + border-bottom: 1px solid #d5d5d5; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #f6f6f6 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #f6f6f6 98%); + color: #464646; + font-weight: 400; + font-size: 14px; + -webkit-box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #eeeeee; + box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #eeeeee; + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.05); + display: block; + background: transparent; + border-bottom-color: #c9c9c9; + border-radius: inherit; + cursor: pointer; + position: relative; +} + +.mytheme .v-accordion-item-caption > .v-caption:hover:before, .mytheme .v-accordion-item-caption > .v-caption:active:before { + content: ""; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + border-radius: inherit; +} + +.mytheme .v-accordion-item-caption > .v-caption:hover:before { + background-color: rgba(186, 186, 186, 0.1); + border: none; +} + +.mytheme .v-accordion-item-caption > .v-caption:active:before { + background-color: rgba(125, 125, 125, 0.2); +} + +.mytheme .v-accordion-item-content { + -webkit-box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.05); + background-color: white; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +.mytheme .v-accordion-item-content > .v-margin-top { + padding-top: 12px; +} + +.mytheme .v-accordion-item-content > .v-margin-right { + padding-right: 12px; +} + +.mytheme .v-accordion-item-content > .v-margin-bottom { + padding-bottom: 12px; +} + +.mytheme .v-accordion-item-content > .v-margin-left { + padding-left: 12px; +} + +.mytheme .v-accordion-borderless { + border: none; + border-radius: 0; + -webkit-box-shadow: none; + box-shadow: none; +} + +.mytheme .v-accordion-borderless > .v-accordion-item, .mytheme .v-accordion-borderless > .v-accordion-item > div > .v-caption, .mytheme .v-accordion-borderless > .v-accordion-item > .v-accordion-item-content { + border-radius: 0; +} + +.mytheme .v-select-twincol { + white-space: normal; +} + +.mytheme .v-select-twincol select { + border: 1px solid #c5c5c5; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + color: #464646; +} + +.mytheme .v-select-twincol select:focus { + outline: none; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); +} + +.mytheme .v-select-twincol .v-textfield, .mytheme .v-select-twincol .v-nativebutton { + width: auto !important; + margin-top: 9px; +} + +.mytheme .v-select-twincol .v-nativebutton { + margin-left: 9px; +} + +.mytheme .v-select-twincol-caption-left, .mytheme .v-select-twincol-caption-right { + font-size: 14px; + font-weight: 400; + padding-bottom: 0.3em; + padding-left: 1px; +} + +.mytheme .v-select-twincol-buttons { + white-space: nowrap; + display: inline-block; + vertical-align: top; + position: relative; + min-width: 3.5em; +} + +.mytheme .v-select-twincol-buttons .v-button { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + display: inline-block; + vertical-align: top; + text-align: left; + white-space: normal; + position: absolute; + left: 9px; + right: 9px; + top: 36px; + padding: 0; + text-align: center; +} + +.mytheme .v-select-twincol-buttons .v-button:first-child { + top: 0; +} + +.mytheme .v-select-twincol-buttons .v-button-caption { + display: none; +} + +.mytheme .v-select-twincol-buttons .v-button:focus { + z-index: 1; +} + +.mytheme .v-select-twincol-buttons .v-button:first-child { + border-radius: 4px 4px 0 0; +} + +.mytheme .v-select-twincol-buttons .v-button:last-child { + border-radius: 0 0 4px 4px; +} + +.mytheme .v-select-twincol-buttons .v-button-wrap:before { + font-family: ThemeIcons; + content: "\f053"; +} + +.mytheme .v-select-twincol-buttons .v-button:first-child .v-button-wrap:before { + font-family: ThemeIcons; + content: "\f054"; +} + +.mytheme .v-select-twincol-error .v-select-twincol-options, .mytheme .v-select-twincol-error .v-select-twincol-selections { + border-color: #ed473b !important; + background: #fffbfb; + color: #6c2621; +} + +.mytheme .v-select select { + border: 1px solid #c5c5c5; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + color: #464646; +} + +.mytheme .v-select select:focus { + outline: none; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); +} + +.mytheme .v-select-select { + display: block; +} + +.mytheme .v-select-select + .v-textfield { + width: auto !important; + margin-top: 9px; +} + +.mytheme .v-select-select + .v-textfield + .v-nativebutton { + margin-top: 9px; + margin-left: 9px; +} + +.mytheme .v-select-error .v-select-select { + border-color: #ed473b !important; + background: #fffbfb; + color: #6c2621; +} + +.mytheme .v-calendar-header-day { + font-weight: 400; + text-align: center; + padding: 7px 0; +} + +.mytheme .v-calendar-header-week .v-calendar-back, .mytheme .v-calendar-header-week .v-calendar-next { + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + background: transparent; + border: none; + padding: 0; + margin: 0; + cursor: pointer; + outline: none; + color: inherit; + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-calendar-header-week .v-calendar-back:focus, .mytheme .v-calendar-header-week .v-calendar-next:focus { + outline: none; +} + +.mytheme .v-calendar-header-week .v-calendar-back:hover, .mytheme .v-calendar-header-week .v-calendar-next:hover { + opacity: 1; + filter: none ; +} + +.mytheme .v-calendar-header-week .v-calendar-back:active, .mytheme .v-calendar-header-week .v-calendar-next:active { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-calendar-header-week .v-calendar-back:before { + font-family: ThemeIcons; + content: "\f053"; +} + +.mytheme .v-calendar-header-week .v-calendar-next:before { + font-family: ThemeIcons; + content: "\f054"; +} + +.mytheme .v-calendar-month { + outline: none; + overflow: hidden; +} + +.mytheme .v-calendar-month td { + vertical-align: top; +} + +.mytheme .v-calendar-week-number { + cursor: pointer; + width: 20px; + text-align: center; + font-size: 0.8em; + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-calendar-week-number:hover { + opacity: 1; + filter: none ; +} + +.mytheme .v-calendar-month-day { + outline: none; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + line-height: 1.2; +} + +.mytheme .v-calendar-bottom-spacer, .mytheme .v-calendar-spacer, .mytheme .v-calendar-bottom-spacer-empty { + height: 19px; + margin-bottom: 3px; +} + +.mytheme .v-calendar-bottom-spacer { + font-size: 0.8em; + padding: 0 5px; + cursor: pointer; +} + +.mytheme .v-calendar-bottom-spacer:hover { + color: #197de1; +} + +.mytheme .v-calendar-day-number { + line-height: 25px; + font-size: 16px; + text-align: right; + margin: 0 5px; + white-space: nowrap; + border-top: 1px solid #f2f2f2; + cursor: pointer; +} + +.mytheme .v-calendar-day-number:hover { + color: #197de1; +} + +.mytheme .v-calendar-month-day-today { + background: #eef3f8; +} + +.mytheme .v-calendar-month-day-today .v-calendar-day-number { + font-weight: 400; + color: #197de1; + border-top: 2px solid #197de1; + line-height: 24px; + margin: 0; + padding: 0 5px; +} + +.mytheme .v-calendar-month-day-selected { + background-color: #e3edf7; +} + +.mytheme .v-calendar-month-day-dragemphasis { + background-color: #a8a8a8; +} + +.mytheme .v-calendar-month-day-scrollable { + overflow-y: scroll; +} + +.mytheme .v-calendar-weekly-longevents { + margin-left: 50px; + border-bottom: 3px solid #e0e0e0; +} + +.mytheme .v-calendar-weekly-longevents .v-calendar-event-all-day { + height: 22px; + line-height: 1.6; + margin-bottom: 3px; +} + +.mytheme .v-calendar-header-week td { + vertical-align: middle !important; +} + +.mytheme .v-calendar-header-week .v-calendar-header-day { + cursor: pointer; +} + +.mytheme .v-calendar-times { + width: 50px; + font-size: 0.77em; + line-height: 1; + white-space: nowrap; +} + +.mytheme .v-calendar-time { + text-align: right; + padding-right: 9px; + margin-top: -6px; + padding-bottom: 6px; +} + +.mytheme .v-calendar-day-times, .mytheme .v-calendar-day-times-today { + outline: none; + border-right: 1px solid transparent; +} + +.mytheme .v-calendar-day-times:focus, .mytheme .v-calendar-day-times-today:focus { + outline: none; +} + +.mytheme .v-calendar .v-datecellslot, .mytheme .v-calendar .v-datecellslot-even { + border-top: 1px solid #dfdfdf; +} + +.mytheme .v-calendar .v-datecellslot:first-child, .mytheme .v-calendar .v-datecellslot-even:first-child { + border-top-color: transparent; +} + +.mytheme .v-calendar .v-datecellslot { + border-top-style: dotted; +} + +.mytheme .v-calendar .v-datecellslot, .mytheme .v-calendar .v-datecellslot-even { + margin-right: 5px; +} + +.mytheme .v-calendar-current-time { + background: #197de1; + line-height: 1px; + pointer-events: none; + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-calendar-current-time:before { + content: "\2022"; + color: #197de1; + font-size: 22px; + margin-left: -0.07em; +} + +.mytheme .v-calendar .v-daterange { + position: relative; +} + +.mytheme .v-calendar .v-daterange:before { + content: ""; + position: absolute; + top: 0; + right: 0; + bottom: -1px; + left: 0; + background: #197de1; + opacity: 0.5; + filter: alpha(opacity=50) ; + border-radius: 4px 4px 0 0; +} + +.mytheme .v-calendar .v-daterange + .v-daterange { + border-color: transparent; +} + +.mytheme .v-calendar .v-daterange + .v-daterange:before { + border-radius: 0; +} + +.mytheme .v-calendar-event { + font-size: 0.85em; + overflow: hidden; + cursor: pointer; + outline: none; + border-radius: 4px; +} + +.mytheme .v-calendar-event:focus { + outline: none; +} + +.mytheme .v-calendar-event-month { + padding: 0 5px; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + margin-bottom: 3px; + white-space: nowrap; + text-overflow: ellipsis; + height: 19px; + line-height: 19px; +} + +.mytheme .v-calendar-event-month .v-calendar-event-time { + float: right; + font-size: 0.9em; + line-height: 19px; + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-calendar-event-month:before { + content: "\25cf"; + margin-right: 0.2em; +} + +.mytheme .v-calendar-event-all-day { + padding: 0 5px; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + height: 19px; + line-height: 19px; + border-radius: 0; + margin-left: -1px; + white-space: nowrap; +} + +.mytheme .v-calendar-event-all-day:before { + content: ""; +} + +.mytheme .v-calendar-event-start { + overflow: visible; + margin-left: 0; +} + +.mytheme .v-calendar-event-start.v-calendar-event-continued-to, .mytheme .v-calendar-event-start.v-calendar-event-end { + overflow: hidden; + text-overflow: ellipsis; +} + +.mytheme .v-calendar-event-start { + border-top-left-radius: 4px; + border-bottom-left-radius: 4px; + margin-left: 5px; +} + +.mytheme .v-calendar-event-end { + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; + margin-right: 5px; +} + +.mytheme .v-calendar-event-caption { + font-weight: 500; + line-height: 1.2; + padding: 5px 0; + position: absolute; + overflow: hidden; + right: 9px; + left: 5px; + bottom: 0; + top: 0; +} + +.mytheme .v-calendar-event-caption span { + font-weight: 300; + white-space: nowrap; +} + +.mytheme .v-calendar-week-wrapper .v-calendar-event { + overflow: visible; +} + +.mytheme .v-calendar-week-wrapper .v-calendar-event-content { + margin-top: -1px; + border-radius: 5px; + border: 1px solid #fafafa; + padding-top: 3px; + margin-right: 5px; +} + +.mytheme .v-calendar-event-month:before { + color: #00ace0; +} + +.mytheme .v-calendar-event-all-day { + background-color: #c8eaf4; + background-color: rgba(200, 234, 244, 0.8); + color: #00ace0; +} + +.mytheme .v-calendar-week-wrapper .v-calendar-event { + color: #00ace0; +} + +.mytheme .v-calendar-week-wrapper .v-calendar-event .v-calendar-event-content { + background-color: #c8eaf4; + background-color: rgba(200, 234, 244, 0.8); +} + +.mytheme .v-calendar-event-month[class*="color2"]:before { + color: #2d9f19; +} + +.mytheme .v-calendar-event-all-day[class*="color2"] { + background-color: #d1e7cd; + background-color: rgba(209, 231, 205, 0.8); + color: #2d9f19; +} + +.mytheme .v-calendar-week-wrapper .v-calendar-event[class*="color2"] { + color: #2d9f19; +} + +.mytheme .v-calendar-week-wrapper .v-calendar-event[class*="color2"] .v-calendar-event-content { + background-color: #d1e7cd; + background-color: rgba(209, 231, 205, 0.8); +} + +.mytheme .v-calendar-event-month[class*="color3"]:before { + color: #d18100; +} + +.mytheme .v-calendar-event-all-day[class*="color3"] { + background-color: #f1e1c8; + background-color: rgba(241, 225, 200, 0.8); + color: #d18100; +} + +.mytheme .v-calendar-week-wrapper .v-calendar-event[class*="color3"] { + color: #d18100; +} + +.mytheme .v-calendar-week-wrapper .v-calendar-event[class*="color3"] .v-calendar-event-content { + background-color: #f1e1c8; + background-color: rgba(241, 225, 200, 0.8); +} + +.mytheme .v-calendar-event-month[class*="color4"]:before { + color: #ce3812; +} + +.mytheme .v-calendar-event-all-day[class*="color4"] { + background-color: #f1d3cb; + background-color: rgba(241, 211, 203, 0.8); + color: #ce3812; +} + +.mytheme .v-calendar-week-wrapper .v-calendar-event[class*="color4"] { + color: #ce3812; +} + +.mytheme .v-calendar-week-wrapper .v-calendar-event[class*="color4"] .v-calendar-event-content { + background-color: #f1d3cb; + background-color: rgba(241, 211, 203, 0.8); +} + +.mytheme .v-calendar-event-month[class*="color5"]:before { + color: #2d55cd; +} + +.mytheme .v-calendar-event-all-day[class*="color5"] { + background-color: #d1d9f1; + background-color: rgba(209, 217, 241, 0.8); + color: #2d55cd; +} + +.mytheme .v-calendar-week-wrapper .v-calendar-event[class*="color5"] { + color: #2d55cd; +} + +.mytheme .v-calendar-week-wrapper .v-calendar-event[class*="color5"] .v-calendar-event-content { + background-color: #d1d9f1; + background-color: rgba(209, 217, 241, 0.8); +} + +.mytheme .v-calendar.v-disabled * { + cursor: default; +} + +.mytheme .v-label { + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; +} + +.mytheme .v-label.v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-label-undef-w { + white-space: nowrap; +} + +.mytheme h1, .mytheme .v-label-h1, .mytheme h2, .mytheme .v-label-h2, .mytheme h3, .mytheme .v-label-h3 { + line-height: 1.1; + font-weight: 200; + color: #141414; +} + +.mytheme h1, .mytheme .v-label-h1 { + font-size: 2.4em; + margin-top: 1.4em; + margin-bottom: 1em; + + letter-spacing: -0.03em; +} + +.mytheme h2, .mytheme .v-label-h2 { + font-size: 1.6em; + + margin-top: 1.6em; + margin-bottom: 0.77em; + letter-spacing: -0.02em; +} + +.mytheme h3, .mytheme .v-label-h3 { + font-size: 1.2em; + + margin-top: 1.8em; + margin-bottom: 0.77em; + letter-spacing: 0; +} + +.mytheme h4, .mytheme .v-label-h4 { + line-height: 1.1; + font-weight: 500; + font-size: 14px; + color: #414141; + text-transform: uppercase; + letter-spacing: 0; + margin-top: 2.4em; + margin-bottom: 0.8em; +} + +.mytheme .v-csslayout > h1:first-child, .mytheme .v-csslayout > h2:first-child, .mytheme .v-csslayout > h3:first-child, .mytheme .v-csslayout > h4 > .v-label-h1:first-child, .mytheme .v-csslayout > .v-label-h2:first-child, .mytheme .v-csslayout > .v-label-h3:first-child, .mytheme .v-csslayout > .v-label-h4:first-child { + margin-top: 16px; +} + +.mytheme .v-verticallayout > .v-slot:first-child h1, .mytheme .v-verticallayout > .v-slot:first-child .v-label-h1, .mytheme .v-verticallayout > .v-slot:first-child h2, .mytheme .v-verticallayout > .v-slot:first-child .v-label-h2, .mytheme .v-verticallayout > .v-slot:first-child h3, .mytheme .v-verticallayout > .v-slot:first-child .v-label-h3, .mytheme .v-verticallayout > .v-slot:first-child h4, .mytheme .v-verticallayout > .v-slot:first-child .v-label-h4, .mytheme .v-verticallayout > div > .v-slot:first-child h1, .mytheme .v-verticallayout > div > .v-slot:first-child .v-label-h1, .mytheme .v-verticallayout > div > .v-slot:first-child h2, .mytheme .v-verticallayout > div > .v-slot:first-child .v-label-h2, .mytheme .v-verticallayout > div > .v-slot:first-child h3, .mytheme .v-verticallayout > div > .v-slot:first-child .v-label-h3, .mytheme .v-verticallayout > div > .v-slot:first-child h4, .mytheme .v-verticallayout > div > .v-slot:first-child .v-label-h4 { + margin-top: 16px; +} + +.mytheme .v-verticallayout > .v-slot:first-child .v-formlayout-contentcell h1, .mytheme .v-verticallayout > .v-slot:first-child .v-formlayout-contentcell .v-label-h1, .mytheme .v-verticallayout > .v-slot:first-child .v-formlayout-contentcell h2, .mytheme .v-verticallayout > .v-slot:first-child .v-formlayout-contentcell .v-label-h2, .mytheme .v-verticallayout > .v-slot:first-child .v-formlayout-contentcell h3, .mytheme .v-verticallayout > .v-slot:first-child .v-formlayout-contentcell .v-label-h3, .mytheme .v-verticallayout > .v-slot:first-child .v-formlayout-contentcell h4, .mytheme .v-verticallayout > .v-slot:first-child .v-formlayout-contentcell .v-label-h4, .mytheme .v-verticallayout > div > .v-slot:first-child .v-formlayout-contentcell h1, .mytheme .v-verticallayout > div > .v-slot:first-child .v-formlayout-contentcell .v-label-h1, .mytheme .v-verticallayout > div > .v-slot:first-child .v-formlayout-contentcell h2, .mytheme .v-verticallayout > div > .v-slot:first-child .v-formlayout-contentcell .v-label-h2, .mytheme .v-verticallayout > div > .v-slot:first-child .v-formlayout-contentcell h3, .mytheme .v-verticallayout > div > .v-slot:first-child .v-formlayout-contentcell .v-label-h3, .mytheme .v-verticallayout > div > .v-slot:first-child .v-formlayout-contentcell h4, .mytheme .v-verticallayout > div > .v-slot:first-child .v-formlayout-contentcell .v-label-h4 { + margin-top: -0.5em; +} + +.mytheme h1.no-margin, .mytheme .v-label-h1.no-margin, .mytheme h2.no-margin, .mytheme .v-label-h2.no-margin, .mytheme h3.no-margin, .mytheme .v-label-h3.no-margin, .mytheme h4.no-margin, .mytheme .v-label-h4.no-margin { + margin: 0 !important; +} + +.mytheme .v-label-colored { + color: #197de1; +} + +.mytheme .v-label-large { + font-size: 20px; +} + +.mytheme .v-label-small { + font-size: 14px; +} + +.mytheme .v-label-tiny { + font-size: 12px; +} + +.mytheme .v-label-huge { + font-size: 26px; +} + +.mytheme .v-label-bold { + font-weight: 500; +} + +.mytheme .v-label-light { + font-weight: 200; + color: #7d7d7d; +} + +.mytheme .v-label-align-right { + text-align: right; +} + +.mytheme .v-label-align-center { + text-align: center; +} + +.mytheme .v-label-spinner { + height: 24px !important; + width: 24px !important; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + border: 2px solid rgba(25, 125, 225, 0.2); + border-top-color: #197de1; + border-right-color: #197de1; + border-radius: 100%; + -webkit-animation: v-rotate-360 500ms infinite linear; + -moz-animation: v-rotate-360 500ms infinite linear; + animation: v-rotate-360 500ms infinite linear; + pointer-events: none; +} + +.v-ie8 .mytheme .v-label-spinner, .v-ie9 .mytheme .v-label-spinner { + border: none; + border-radius: 4px; + background: #fff url(../valo/shared/img/spinner.gif) no-repeat 50% 50%; + background-size: 80%; +} + +.v-ie8 .mytheme .v-label-spinner { + min-width: 30px; + min-height: 30px; +} + +.mytheme .v-label-success, .mytheme .v-label-failure { + background: white; + color: #474747; + border: 2px solid #2c9720; + border-radius: 4px; + padding: 7px 19px 7px 37px; + font-weight: 400; + font-size: 15px; +} + +.mytheme .v-label-success:before, .mytheme .v-label-failure:before { + font-family: ThemeIcons; + content: "\f00c"; + margin-right: 0.5em; + margin-left: -19px; + color: #2c9720; +} + +.mytheme .v-label-failure { + border-color: #ed473b; +} + +.mytheme .v-label-failure:before { + content: "\f05e"; + color: #ed473b; +} + +.mytheme [draggable=true] { + -khtml-user-drag: element; + -webkit-user-drag: element; +} + +.mytheme .v-ddwrapper { + position: relative; +} + +.mytheme .v-ddwrapper-over:before, .mytheme .v-ddwrapper-over:after { + content: ""; + position: absolute; + z-index: 10; + top: -1px; + right: -1px; + bottom: -1px; + left: -1px; + border: 0 solid #197de1; +} + +.mytheme .v-ddwrapper-over-top:before { + border-top-width: 2px; +} + +.mytheme .v-ddwrapper-over-right:before { + border-right-width: 2px; +} + +.mytheme .v-ddwrapper-over-bottom:before { + border-bottom-width: 2px; +} + +.mytheme .v-ddwrapper-over-left:before { + border-left-width: 2px; +} + +.mytheme .no-vertical-drag-hints .v-ddwrapper-over-top:before, .mytheme .no-vertical-drag-hints.v-ddwrapper-over-top:before { + border-top-width: 0; +} + +.mytheme .no-vertical-drag-hints .v-ddwrapper-over-top:after, .mytheme .no-vertical-drag-hints.v-ddwrapper-over-top:after { + border-width: 2px; + border-radius: 4px; + opacity: 0.3; + filter: alpha(opacity=30.0) ; + background: #8abef2; +} + +.mytheme .no-vertical-drag-hints .v-ddwrapper-over-bottom:before, .mytheme .no-vertical-drag-hints.v-ddwrapper-over-bottom:before { + border-bottom-width: 0; +} + +.mytheme .no-vertical-drag-hints .v-ddwrapper-over-bottom:after, .mytheme .no-vertical-drag-hints.v-ddwrapper-over-bottom:after { + border-width: 2px; + border-radius: 4px; + opacity: 0.3; + filter: alpha(opacity=30.0) ; + background: #8abef2; +} + +.mytheme .no-horizontal-drag-hints.v-ddwrapper-over-left:before, .mytheme .no-horizontal-drag-hints .v-ddwrapper-over-left:before { + border-left-width: 0; +} + +.mytheme .no-horizontal-drag-hints.v-ddwrapper-over-left:after, .mytheme .no-horizontal-drag-hints .v-ddwrapper-over-left:after { + border-width: 2px; + border-radius: 4px; + opacity: 0.3; + filter: alpha(opacity=30.0) ; + background: #8abef2; +} + +.mytheme .no-horizontal-drag-hints.v-ddwrapper-over-right:before, .mytheme .no-horizontal-drag-hints .v-ddwrapper-over-right:before { + border-right-width: 0; +} + +.mytheme .no-horizontal-drag-hints.v-ddwrapper-over-right:after, .mytheme .no-horizontal-drag-hints .v-ddwrapper-over-right:after { + border-width: 2px; + border-radius: 4px; + opacity: 0.3; + filter: alpha(opacity=30.0) ; + background: #8abef2; +} + +.mytheme .v-ddwrapper-over-middle:after, .mytheme .v-ddwrapper-over-center:after { + border-width: 2px; + border-radius: 4px; + opacity: 0.3; + filter: alpha(opacity=30.0) ; + background: #8abef2; +} + +.mytheme .no-box-drag-hints.v-ddwrapper:after, .mytheme .no-box-drag-hints .v-ddwrapper:after { + display: none !important; + content: none; +} + +.mytheme .v-nativebutton { + -webkit-touch-callout: none; +} + +.mytheme .v-select select { + border: 1px solid #c5c5c5; + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + color: #464646; +} + +.mytheme .v-select select:focus { + outline: none; + -webkit-box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); + box-shadow: 0 0 0 2px rgba(25, 125, 225, 0.5); +} + +.mytheme .v-select-select { + display: block; +} + +.mytheme .v-select-select + .v-textfield { + width: auto !important; + margin-top: 9px; +} + +.mytheme .v-select-select + .v-textfield + .v-nativebutton { + margin-top: 9px; + margin-left: 9px; +} + +.mytheme .v-select-error .v-select-select { + border-color: #ed473b !important; + background: #fffbfb; + color: #6c2621; +} + +.mytheme .v-popupview { + cursor: pointer; + color: #197de1; + text-decoration: underline; + font-weight: inherit; + -webkit-transition: color 140ms; + -moz-transition: color 140ms; + transition: color 140ms; +} + +.mytheme .v-popupview:hover { + color: #4396ea; +} + +.mytheme .v-popupview.v-disabled { + opacity: 0.5; + filter: alpha(opacity=50) ; +} + +.mytheme .v-popupview-popup { + padding: 4px 4px; + border-radius: 4px; + background-color: white; + color: #474747; + -webkit-box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.1), 0 3px 5px 0 rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.09098); + box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.1), 0 3px 5px 0 rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.09098); + -webkit-backface-visibility: hidden; + -moz-backface-visibility: hidden; + -ms-backface-visibility: hidden; + backface-visibility: hidden; +} + +.mytheme .v-popupview-popup[class*="animate-in"] { + -webkit-animation: v-popupview-animate-in 120ms; + -moz-animation: v-popupview-animate-in 120ms; + animation: v-popupview-animate-in 120ms; +} + +.mytheme .v-popupview-popup[class*="animate-out"] { + -webkit-animation: valo-animate-out-fade 120ms; + -moz-animation: valo-animate-out-fade 120ms; + animation: valo-animate-out-fade 120ms; +} + +.mytheme .v-popupview-popup .popupContent > .v-margin-top { + padding-top: 12px; +} + +.mytheme .v-popupview-popup .popupContent > .v-margin-right { + padding-right: 12px; +} + +.mytheme .v-popupview-popup .popupContent > .v-margin-bottom { + padding-bottom: 12px; +} + +.mytheme .v-popupview-popup .popupContent > .v-margin-left { + padding-left: 12px; +} + +.mytheme .v-popupview-loading { + margin: 12px 12px; + height: 24px !important; + width: 24px !important; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + border: 2px solid rgba(25, 125, 225, 0.2); + border-top-color: #197de1; + border-right-color: #197de1; + border-radius: 100%; + -webkit-animation: v-rotate-360 500ms infinite linear; + -moz-animation: v-rotate-360 500ms infinite linear; + animation: v-rotate-360 500ms infinite linear; + pointer-events: none; +} + +.v-ie8 .mytheme .v-popupview-loading, .v-ie9 .mytheme .v-popupview-loading { + border: none; + border-radius: 4px; + background: #fff url(../valo/shared/img/spinner.gif) no-repeat 50% 50%; + background-size: 80%; +} + +.v-ie8 .mytheme .v-popupview-loading { + min-width: 30px; + min-height: 30px; +} + +.mytheme .v-richtextarea { + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + -o-appearance: none; + appearance: none; + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; + margin: 0; + font: inherit; + + font-weight: 400; + line-height: normal; + height: 37px; + border-radius: 4px; + padding: 0; + border: 1px solid #c5c5c5; + background: white; + color: #474747; + -webkit-box-shadow: inset 0 1px 0 #f7f7f7, 0 1px 0 rgba(255, 255, 255, 0.1); + box-shadow: inset 0 1px 0 #f7f7f7, 0 1px 0 rgba(255, 255, 255, 0.1); + -webkit-transition: box-shadow 180ms, border 180ms; + -moz-transition: box-shadow 180ms, border 180ms; + transition: box-shadow 180ms, border 180ms; + height: auto; + overflow: hidden; +} + +.v-ie8 .mytheme .v-richtextarea, .v-ie9 .mytheme .v-richtextarea { + line-height: 37px; + padding-top: 0; + padding-bottom: 0; +} + +.mytheme .v-richtextarea[class*="prompt"] { + color: #a3a3a3; +} + +.mytheme .v-richtextarea .gwt-RichTextToolbar { + background-color: #fafafa; + background-image: -webkit-linear-gradient(top, #fafafa 2%, #efefef 98%); + background-image: linear-gradient(to bottom,#fafafa 2%, #efefef 98%); + -webkit-box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7; + box-shadow: inset 0 1px 0 white, inset 0 -1px 0 #e7e7e7; + border-bottom: 1px solid #c5c5c5; + color: #464646; +} + +.mytheme .v-richtextarea .gwt-ToggleButton, .mytheme .v-richtextarea .gwt-PushButton { + display: inline-block; + line-height: 37px; + width: 37px; + text-align: center; + outline: none; +} + +.mytheme .v-richtextarea .gwt-ToggleButton:hover, .mytheme .v-richtextarea .gwt-PushButton:hover { + color: black; +} + +.mytheme .v-richtextarea .gwt-ToggleButton-down, .mytheme .v-richtextarea .gwt-ToggleButton-down-hovering { + background-color: #e0e0e0; + background-image: -webkit-linear-gradient(bottom, #e0e0e0 2%, #dcdcdc 98%); + background-image: linear-gradient(to top,#e0e0e0 2%, #dcdcdc 98%); +} + +.mytheme .v-richtextarea .gwt-RichTextToolbar-top img { + display: none; +} + +.mytheme .v-richtextarea .gwt-RichTextToolbar-top div:before { + font-family: ThemeIcons; +} + +.mytheme .v-richtextarea .gwt-RichTextToolbar-top div[title="Toggle Bold"]:before { + content: "\f032"; +} + +.mytheme .v-richtextarea .gwt-RichTextToolbar-top div[title="Toggle Italic"]:before { + content: "\f033"; +} + +.mytheme .v-richtextarea .gwt-RichTextToolbar-top div[title="Toggle Underline"]:before { + content: "\f0cd"; +} + +.mytheme .v-richtextarea .gwt-RichTextToolbar-top div[title="Toggle Subscript"]:before { + content: "\f12c"; +} + +.mytheme .v-richtextarea .gwt-RichTextToolbar-top div[title="Toggle Superscript"]:before { + content: "\f12b"; +} + +.mytheme .v-richtextarea .gwt-RichTextToolbar-top div[title="Left Justify"]:before { + content: "\f036"; +} + +.mytheme .v-richtextarea .gwt-RichTextToolbar-top div[title="Center"]:before { + content: "\f037"; +} + +.mytheme .v-richtextarea .gwt-RichTextToolbar-top div[title="Right Justify"]:before { + content: "\f038"; +} + +.mytheme .v-richtextarea .gwt-RichTextToolbar-top div[title="Toggle Strikethrough"]:before { + content: "\f0cc"; +} + +.mytheme .v-richtextarea .gwt-RichTextToolbar-top div[title="Indent Right"]:before { + content: "\f03c"; +} + +.mytheme .v-richtextarea .gwt-RichTextToolbar-top div[title="Indent Left"]:before { + content: "\f03b"; +} + +.mytheme .v-richtextarea .gwt-RichTextToolbar-top div[title="Insert Horizontal Rule"]:before { + content: "\2014"; +} + +.mytheme .v-richtextarea .gwt-RichTextToolbar-top div[title="Insert Ordered List"]:before { + content: "\f0cb"; +} + +.mytheme .v-richtextarea .gwt-RichTextToolbar-top div[title="Insert Unordered List"]:before { + content: "\f0ca"; +} + +.mytheme .v-richtextarea .gwt-RichTextToolbar-top div[title="Insert Image"]:before { + content: "\f03e"; +} + +.mytheme .v-richtextarea .gwt-RichTextToolbar-top div[title="Create Link"]:before { + content: "\f0c1"; +} + +.mytheme .v-richtextarea .gwt-RichTextToolbar-top div[title="Remove Link"]:before { + content: "\f127"; +} + +.mytheme .v-richtextarea .gwt-RichTextToolbar-top div[title="Remove Formatting"]:before { + content: "\f12d"; +} + +.mytheme .v-richtextarea .gwt-RichTextToolbar-bottom { + font-size: 13px; + padding: 0 9px 9px 0; +} + +.mytheme .v-richtextarea .gwt-RichTextToolbar-bottom select { + margin: 9px 0 0 9px; +} + +.mytheme .v-richtextarea .gwt-RichTextArea { + background: #fff; + border: none; + display: block; +} + +.mytheme .v-richtextarea-readonly { + padding: 5px 7px; + background: transparent; +} + +.mytheme .v-upload .v-button { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + display: inline-block; + vertical-align: top; + text-align: left; + white-space: normal; +} + +.mytheme .v-upload-immediate .v-button { + width: 100%; +} + +.mytheme .v-upload-immediate input[type="file"] { + opacity: 0; + filter: alpha(opacity=0) ; + z-index: -1; + position: absolute; + right: 0; + height: 37px; + text-align: right; + border: none; + background: transparent; +} + +.mytheme .v-Notification.v-position-top { + top: 12px; +} + +.mytheme .v-Notification.v-position-right { + right: 12px; +} + +.mytheme .v-Notification.v-position-bottom { + bottom: 12px; +} + +.mytheme .v-Notification.v-position-left { + left: 12px; +} + +.mytheme .v-Notification.v-position-assistive { + top: -9999px; + left: -9999px; +} + +.mytheme .v-Notification-animate-in { + -webkit-animation: valo-animate-in-fade 180ms 10ms backwards; + -moz-animation: valo-animate-in-fade 180ms 10ms backwards; + animation: valo-animate-in-fade 180ms 10ms backwards; +} + +.mytheme .v-Notification-animate-in.v-position-top { + -webkit-animation: valo-animate-in-slide-down 400ms 10ms backwards; + -moz-animation: valo-animate-in-slide-down 400ms 10ms backwards; + animation: valo-animate-in-slide-down 400ms 10ms backwards; +} + +.mytheme .v-Notification-animate-in.v-position-bottom { + -webkit-animation: valo-animate-in-slide-up 400ms 10ms backwards; + -moz-animation: valo-animate-in-slide-up 400ms 10ms backwards; + animation: valo-animate-in-slide-up 400ms 10ms backwards; +} + +.mytheme .v-Notification-animate-out { + -webkit-animation: valo-animate-out-fade 150ms; + -moz-animation: valo-animate-out-fade 150ms; + animation: valo-animate-out-fade 150ms; +} + +.mytheme .v-Notification-animate-out.v-position-top, .mytheme .v-Notification-animate-out.v-position-bottom { + -webkit-animation: valo-animate-out-slide-down-fade 200ms; + -moz-animation: valo-animate-out-slide-down-fade 200ms; + animation: valo-animate-out-slide-down-fade 200ms; +} + +.mytheme .v-Notification { + border-radius: 4px; + text-align: center; + position: fixed !important; + -webkit-backface-visibility: hidden; + -moz-backface-visibility: hidden; + -ms-backface-visibility: hidden; + backface-visibility: hidden; + background: white; + -webkit-box-shadow: 0px 5px 15px 0px rgba(0, 0, 0, 0.15); + box-shadow: 0px 5px 15px 0px rgba(0, 0, 0, 0.15); + padding: 19px 22px; +} + +.mytheme .v-Notification .v-Notification-caption { + color: #197de1; + font-size: 19px; + line-height: 1; +} + +.mytheme .v-Notification .v-Notification-description { + line-height: 1.4; +} + +.mytheme .v-Notification-caption { + margin: 0; + display: inline-block; + text-align: left; + font-weight: inherit; + line-height: inherit; + white-space: nowrap; + letter-spacing: 0; +} + +.mytheme .v-Notification-description, .mytheme .v-Notification-details { + margin: 0; + display: inline-block; + vertical-align: middle; + max-width: 30em; + text-align: left; + max-height: 20em; + overflow: auto; +} + +.mytheme .v-Notification-caption ~ .v-Notification-description, .mytheme .v-Notification-caption ~ .v-Notification-details { + margin-left: 24px; +} + +.mytheme .v-icon + .v-Notification-caption { + margin-left: 16px; +} + +.mytheme .v-Notification-system { + left: 0 !important; + right: 0; + max-width: 100%; + margin: 0 !important; + border-radius: 0; + -webkit-box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); + box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); + padding: 12px 15px; + background-color: #444; + background-color: rgba(68, 68, 68, 0.9); + font-weight: 400; + line-height: 22px; +} + +.mytheme .v-Notification-system .v-Notification-description, .mytheme .v-Notification-system .v-Notification-details { + max-width: 50em; +} + +.mytheme .v-Notification-system.v-position-top { + top: 0; +} + +.mytheme .v-Notification-system.v-position-top[class*="animate-in"] { + -webkit-animation: valo-animate-in-slide-down 300ms 10ms backwards; + -moz-animation: valo-animate-in-slide-down 300ms 10ms backwards; + animation: valo-animate-in-slide-down 300ms 10ms backwards; +} + +.mytheme .v-Notification-system.v-position-top[class*="animate-out"] { + -webkit-animation: valo-animate-out-slide-up 200ms; + -moz-animation: valo-animate-out-slide-up 200ms; + animation: valo-animate-out-slide-up 200ms; +} + +.mytheme .v-Notification-system.v-position-bottom { + bottom: 0; +} + +.mytheme .v-Notification-system.v-position-bottom[class*="animate-in"] { + -webkit-animation: valo-animate-in-slide-up 300ms 10ms backwards; + -moz-animation: valo-animate-in-slide-up 300ms 10ms backwards; + animation: valo-animate-in-slide-up 300ms 10ms backwards; +} + +.mytheme .v-Notification-system.v-position-bottom[class*="animate-out"] { + -webkit-animation: valo-animate-out-slide-down 200ms; + -moz-animation: valo-animate-out-slide-down 200ms; + animation: valo-animate-out-slide-down 200ms; +} + +.mytheme .v-Notification-system .v-Notification-caption { + color: #fff; + vertical-align: middle; +} + +.mytheme .v-Notification-system .v-Notification-description, .mytheme .v-Notification-system .v-Notification-details { + color: #e6e6e6; +} + +.mytheme .v-Notification-system u { + text-decoration: none; +} + +.mytheme .v-Notification.tray { + text-align: left; +} + +.mytheme .v-Notification.tray .v-Notification-caption + .v-Notification-description { + display: block; + margin: 0.5em 0 0; +} + +.mytheme .v-Notification.warning { + background: #FFF3D2; +} + +.mytheme .v-Notification.warning .v-Notification-caption { + color: #AC7C00; +} + +.mytheme .v-Notification.warning .v-Notification-description { + color: #9D874D; +} + +.mytheme .v-Notification.error { + background: #ed473b; + font-weight: 400; + -webkit-box-shadow: 0px 5px 15px 0px rgba(0, 0, 0, 0.25); + box-shadow: 0px 5px 15px 0px rgba(0, 0, 0, 0.25); +} + +.mytheme .v-Notification.error .v-Notification-caption { + color: white; +} + +.mytheme .v-Notification.error .v-Notification-description { + color: #f4e0df; +} + +.mytheme .v-Notification.dark { + background-color: #444; + background-color: rgba(68, 68, 68, 0.9); + font-weight: 400; + line-height: 22px; +} + +.mytheme .v-Notification.dark .v-Notification-caption { + color: #fff; + vertical-align: middle; +} + +.mytheme .v-Notification.dark .v-Notification-description, .mytheme .v-Notification.dark .v-Notification-details { + color: #e6e6e6; +} + +.mytheme .v-Notification.bar { + left: 0 !important; + right: 0; + max-width: 100%; + margin: 0 !important; + border-radius: 0; + -webkit-box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); + box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.25); + padding: 12px 15px; +} + +.mytheme .v-Notification.bar .v-Notification-description, .mytheme .v-Notification.bar .v-Notification-details { + max-width: 50em; +} + +.mytheme .v-Notification.bar.v-position-top { + top: 0; +} + +.mytheme .v-Notification.bar.v-position-top[class*="animate-in"] { + -webkit-animation: valo-animate-in-slide-down 300ms 10ms backwards; + -moz-animation: valo-animate-in-slide-down 300ms 10ms backwards; + animation: valo-animate-in-slide-down 300ms 10ms backwards; +} + +.mytheme .v-Notification.bar.v-position-top[class*="animate-out"] { + -webkit-animation: valo-animate-out-slide-up 200ms; + -moz-animation: valo-animate-out-slide-up 200ms; + animation: valo-animate-out-slide-up 200ms; +} + +.mytheme .v-Notification.bar.v-position-bottom { + bottom: 0; +} + +.mytheme .v-Notification.bar.v-position-bottom[class*="animate-in"] { + -webkit-animation: valo-animate-in-slide-up 300ms 10ms backwards; + -moz-animation: valo-animate-in-slide-up 300ms 10ms backwards; + animation: valo-animate-in-slide-up 300ms 10ms backwards; +} + +.mytheme .v-Notification.bar.v-position-bottom[class*="animate-out"] { + -webkit-animation: valo-animate-out-slide-down 200ms; + -moz-animation: valo-animate-out-slide-down 200ms; + animation: valo-animate-out-slide-down 200ms; +} + +.mytheme .v-Notification.small { + padding: 11px 13px; +} + +.mytheme .v-Notification.small .v-Notification-caption { + font-size: 16px; +} + +.mytheme .v-Notification.small .v-Notification-description { + font-size: 14px; +} + +.mytheme .v-Notification.closable { + padding-right: 59px; + overflow: hidden !important; + cursor: pointer; +} + +.mytheme .v-Notification.closable:after { + content: "\00d7"; + font-size: 1.5em; + position: absolute; + top: 50%; + margin-top: -12px; + right: 12px; + width: 25px; + height: 25px; + line-height: 24px; + cursor: pointer; + color: #000; + opacity: 0.5; + filter: alpha(opacity=50) ; + text-align: center; + border: 1px solid #000; + border-color: rgba(0, 0, 0, 0.3); + border-radius: 50%; + -webkit-transition: opacity 200ms; + -moz-transition: opacity 200ms; + transition: opacity 200ms; +} + +.mytheme .v-Notification.closable:hover:after { + opacity: 1; + filter: none ; +} + +.mytheme .v-Notification.closable:active:after { + background-color: #000; + color: #fff; + opacity: 0.3; + filter: alpha(opacity=30.0) ; + -webkit-transition: none 200ms; + -moz-transition: none 200ms; + transition: none 200ms; +} + +.mytheme .v-Notification.closable.dark:after, .mytheme .v-Notification.closable.error:after, .mytheme .v-Notification.closable.system:after { + color: #fff; + border-color: #fff; + border-color: rgba(255, 255, 255, 0.3); +} + +.mytheme .v-Notification.closable.dark:active:after, .mytheme .v-Notification.closable.error:active:after, .mytheme .v-Notification.closable.system:active:after { + background-color: #fff; + color: #000; +} + +.mytheme .v-Notification.closable.tray:after { + top: 16px; + margin-top: 0; +} + +.mytheme .v-Notification.success, .mytheme .v-Notification.failure { + background: #fff; + color: #555; + border: 2px solid #2c9720; +} + +.mytheme .v-Notification.success .v-Notification-caption, .mytheme .v-Notification.failure .v-Notification-caption { + color: #2c9720; + font-weight: 400; +} + +.mytheme .v-Notification.success .v-Notification-caption:before, .mytheme .v-Notification.failure .v-Notification-caption:before { + font-family: ThemeIcons; + content: "\f00c"; + margin-right: 0.5em; +} + +.mytheme .v-Notification.success.bar, .mytheme .v-Notification.failure.bar { + margin: -2px !important; +} + +.mytheme .v-Notification.failure { + border-color: #ed473b; +} + +.mytheme .v-Notification.failure .v-Notification-caption { + color: #ed473b; +} + +.mytheme .v-Notification.failure .v-Notification-caption:before { + content: "\f05e"; +} + +.mytheme .valo-menu { + height: 100%; + background-color: #4b4b4b; + background-image: -webkit-linear-gradient(right, #414141 0%, #4b4b4b 9px); + background-image: linear-gradient(to left,#414141 0%, #4b4b4b 9px); + color: #a5a5a5; + font-size: 14px; + line-height: 30px; + border-right: 1px solid #3b3b3b; + white-space: nowrap; +} + +.mytheme .valo-menu-toggle { + display: none; + position: fixed; + z-index: 200; + top: 3px; + left: 3px; + min-width: 0; +} + +.mytheme .valo-menu-part { + border-left: 1px solid #414141; + height: 100%; + padding-bottom: 37px; + overflow: auto; +} + +.mytheme .valo-menu-part:first-child { + border-left: none; +} + +.mytheme .valo-menu-title, .mytheme .valo-menu-subtitle, .mytheme .valo-menu-item { + display: block; + line-height: inherit; + white-space: nowrap; + position: relative; +} + +.mytheme .valo-menu-title .valo-menu-badge, .mytheme .valo-menu-subtitle .valo-menu-badge, .mytheme .valo-menu-item .valo-menu-badge { + position: absolute; + right: 19px; +} + +.mytheme .valo-menu-title { + line-height: 1.2; + background-color: #197de1; + background-image: -webkit-linear-gradient(top, #1b87e3 2%, #166ed5 98%); + background-image: linear-gradient(to bottom,#1b87e3 2%, #166ed5 98%); + color: white; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.05); + padding: 12px 19px; + font-size: 14px; + border-bottom: 1px solid #1362b1; + -webkit-box-shadow: 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: 0 2px 3px rgba(0, 0, 0, 0.05); + text-align: center; +} + +.mytheme .valo-menu-title .v-menubar.v-menubar { + background: transparent; + border-color: #1362b1; + color: inherit; + -webkit-box-shadow: none; + box-shadow: none; + text-shadow: inherit; +} + +.mytheme .valo-menu-title .v-menubar-menuitem { + background: transparent; + -webkit-box-shadow: inset 0 1px 0 #4d98e6, inset 0 -1px 0 #166bca; + box-shadow: inset 0 1px 0 #4d98e6, inset 0 -1px 0 #166bca; + text-shadow: inherit; + font-size: 16px; + border-color: inherit; +} + +.mytheme .valo-menu-title h1, .mytheme .valo-menu-title .v-label-h1, .mytheme .valo-menu-title h2, .mytheme .valo-menu-title .v-label-h2, .mytheme .valo-menu-title h3, .mytheme .valo-menu-title .v-label-h3, .mytheme .valo-menu-title h4, .mytheme .valo-menu-title .v-label-h4 { + margin-top: 0; + margin-bottom: 0; + color: inherit; +} + +.mytheme .v-menubar-user-menu { + border: none; + border-radius: 0; + padding: 1px; + -webkit-box-shadow: none; + box-shadow: none; + text-shadow: none; + background: transparent; + color: inherit; + margin: 19px 7px; + display: block; + overflow: hidden; + text-align: center; + height: auto; + color: inherit; +} + +.mytheme .v-menubar-user-menu:focus:after { + display: none; +} + +.mytheme .v-menubar-user-menu .v-menubar-menuitem { + -webkit-box-shadow: none; + box-shadow: none; + border: none; + margin-right: 1px; + border-radius: 4px; + color: #197de1; + padding: 0 12px; + -webkit-transition: color 140ms; + -moz-transition: color 140ms; + transition: color 140ms; +} + +.mytheme .v-menubar-user-menu .v-menubar-menuitem:first-child, .mytheme .v-menubar-user-menu .v-menubar-menuitem:last-child, .mytheme .v-menubar-user-menu .v-menubar-menuitem:first-child:last-child { + border-radius: 4px; +} + +.mytheme .v-menubar-user-menu .v-menubar-menuitem:before { + content: none; +} + +.mytheme .v-menubar-user-menu .v-menubar-menuitem:hover { + color: #4396ea; +} + +.mytheme .v-menubar-user-menu .v-menubar-menuitem:active { + color: inherit; +} + +.mytheme .v-menubar-user-menu .v-menubar-menuitem-checked, .mytheme .v-menubar-user-menu .v-menubar-menuitem-checked:first-child { + border: 1px solid #c5c5c5; + color: #197de1; +} + +.mytheme .v-menubar-user-menu .v-menubar-menuitem-checked .v-menubar-menuitem-caption, .mytheme .v-menubar-user-menu .v-menubar-menuitem-checked:first-child .v-menubar-menuitem-caption { + position: relative; + top: -1px; +} + +.mytheme .v-menubar-user-menu .v-menubar-menuitem-selected { + color: #ecf2f8; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.05); +} + +.mytheme .v-menubar-user-menu .v-menubar-menuitem-selected:hover { + color: #ecf2f8; +} + +.mytheme .v-menubar-user-menu .v-menubar-menuitem-disabled, .mytheme .v-menubar-user-menu .v-menubar-menuitem-disabled:hover { + color: inherit; +} + +.mytheme .v-menubar-user-menu > .v-menubar-menuitem { + color: inherit; + white-space: normal; + line-height: 1.4; + margin: 0; +} + +.mytheme .v-menubar-user-menu > .v-menubar-menuitem img.v-icon { + width: 56px; + height: 56px; + border-radius: 29px; + box-shadow: 0 2px 3px rgba(0, 0, 0, 0.05); + display: block; + margin: 0 auto 0.3em; + border: 1px solid #c5c5c5; +} + +.mytheme .v-menubar-user-menu > .v-menubar-menuitem:after { + top: 0; + right: 0; + bottom: 0; + left: 0; +} + +.mytheme .v-menubar-user-menu .v-menubar-menuitem-selected { + background: transparent; +} + +.mytheme .valo-menu-subtitle { + color: #868686; + margin: 7px 0 7px 19px; + border-bottom: 1px solid #666666; +} + +.mytheme .valo-menu-subtitle [class*="badge"] { + color: #73a5d7; +} + +.mytheme .valo-menuitems { + display: block; +} + +.mytheme .valo-menu-item { + outline: none; + font-weight: 400; + padding: 0 37px 0 19px; + cursor: pointer; + position: relative; + overflow: hidden; + text-shadow: 0 2px 0 rgba(0, 0, 0, 0.05); + -webkit-transition: background-color 300ms, color 60ms; + -moz-transition: background-color 300ms, color 60ms; + transition: background-color 300ms, color 60ms; +} + +.mytheme .valo-menu-item [class*="caption"] { + vertical-align: middle; + display: inline-block; + width: 90%; + max-width: 15em; + padding-right: 19px; + text-overflow: ellipsis; + overflow: hidden; +} + +.mytheme .valo-menu-item [class*="badge"] { + color: #73a5d7; +} + +.mytheme .valo-menu-item.selected { + background: #434343; +} + +.mytheme .valo-menu-item.selected .v-icon { + color: #197de1; +} + +.mytheme .valo-menu-item.selected [class*="badge"] { + background-color: #197de1; + background-image: -webkit-linear-gradient(top, #1b87e3 2%, #166ed5 98%); + background-image: linear-gradient(to bottom,#1b87e3 2%, #166ed5 98%); + color: #c8dbed; +} + +.mytheme .valo-menu-item:focus, .mytheme .valo-menu-item:hover, .mytheme .valo-menu-item.selected { + color: white; +} + +.mytheme .valo-menu-item span.v-icon { + min-width: 1em; + margin-right: 19px; + text-align: center; + vertical-align: middle; + -webkit-mask-image: -webkit-gradient(linear, left top, left bottom, from(black), to(rgba(0, 0, 0, 0.75))); +} + +.mytheme .valo-menu-item span.v-icon + span { + margin-left: 0; +} + +.mytheme .valo-menu-item [class*="badge"] { + background-color: #585858; + -webkit-transition: background-color 300ms; + -moz-transition: background-color 300ms; + transition: background-color 300ms; + line-height: 1; + padding: 4px 6px; + min-width: 11px; + text-align: center; + top: 4px; + border-radius: 4px; +} + +.mytheme .valo-menu-part.large-icons { + background-color: #4b4b4b; + min-width: 74px; + max-width: 111px; +} + +.mytheme .valo-menu-part.large-icons .valo-menu-title { + font-size: 12px; +} + +.mytheme .valo-menu-part.large-icons .valo-menu-title .v-label-undef-w { + white-space: normal; +} + +.mytheme .valo-menu-part.large-icons .v-menubar-user-menu { + margin-left: 0; + margin-right: 0; + font-size: 11px; +} + +.mytheme .valo-menu-part.large-icons .v-menubar-user-menu img.v-icon { + width: 28px; + height: 28px; +} + +.mytheme .valo-menu-part.large-icons [class*="subtitle"] { + margin: 9px 0 0; + padding: 7px 25px 7px 9px; + line-height: 1; + border: none; + text-overflow: ellipsis; + overflow: hidden; + background: #3c3c3c; + font-size: 13px; + box-shadow: 0 2px 3px rgba(0, 0, 0, 0.05); +} + +.mytheme .valo-menu-part.large-icons [class*="subtitle"] [class*="badge"] { + right: 9px; +} + +.mytheme .valo-menu-part.large-icons [class*="subtitle"] + .valo-menu-item { + border-top: none; +} + +.mytheme .valo-menu-part.large-icons .valo-menu-item { + display: block; + font-size: 26px; + line-height: 1; + padding: 12px; + text-align: center; + border-top: 1px solid #555555; +} + +.mytheme .valo-menu-part.large-icons .valo-menu-item:first-child { + border-top: none; +} + +.mytheme .valo-menu-part.large-icons .valo-menu-item [class*="caption"] { + display: block; + width: auto; + margin: 0.3em 0 0; + padding: 0; + font-size: 11px; + line-height: 1.3; +} + +.mytheme .valo-menu-part.large-icons .valo-menu-item .v-icon { + margin: 0; +} + +.mytheme .valo-menu-part.large-icons .valo-menu-item span.v-icon { + opacity: 0.8; +} + +.mytheme .valo-menu-part.large-icons .valo-menu-item.selected { + background: #434343; +} + +.mytheme .valo-menu-part.large-icons .valo-menu-item.selected .v-icon { + opacity: 1; +} + +.mytheme .valo-menu-part.large-icons .valo-menu-item.selected [class*="badge"] { + border-color: #434343; +} + +.mytheme .valo-menu-part.large-icons .valo-menu-item [class*="badge"] { + padding-left: 4px; + padding-right: 4px; + top: 7px; + right: 7px; + border: 2px solid #4b4b4b; +} + +.mytheme .valo-menu-logo { + display: block; + overflow: hidden; + width: 44px !important; + height: 44px; + border-radius: 4px; + text-align: center; + background-color: #197de1; + background-image: -webkit-linear-gradient(top, #1b87e3 2%, #166ed5 98%); + background-image: linear-gradient(to bottom,#1b87e3 2%, #166ed5 98%); + color: white; + font-size: 25px; + line-height: 44px; + margin: 19px auto; + -webkit-box-shadow: 0 2px 3px rgba(0, 0, 0, 0.05); + box-shadow: 0 2px 3px rgba(0, 0, 0, 0.05); +} + +.mytheme .valo-menu-logo:focus { + outline: none; +} + +.mytheme .valo-menu-responsive[width-range~="801px-1100px"] .valo-menu-part { + background-color: #4b4b4b; + min-width: 74px; + max-width: 111px; +} + +.mytheme .valo-menu-responsive[width-range~="801px-1100px"] .valo-menu-part .valo-menu-title { + font-size: 12px; +} + +.mytheme .valo-menu-responsive[width-range~="801px-1100px"] .valo-menu-part .valo-menu-title .v-label-undef-w { + white-space: normal; +} + +.mytheme .valo-menu-responsive[width-range~="801px-1100px"] .valo-menu-part .v-menubar-user-menu { + margin-left: 0; + margin-right: 0; + font-size: 11px; +} + +.mytheme .valo-menu-responsive[width-range~="801px-1100px"] .valo-menu-part .v-menubar-user-menu img.v-icon { + width: 28px; + height: 28px; +} + +.mytheme .valo-menu-responsive[width-range~="801px-1100px"] .valo-menu-part [class*="subtitle"] { + margin: 9px 0 0; + padding: 7px 25px 7px 9px; + line-height: 1; + border: none; + text-overflow: ellipsis; + overflow: hidden; + background: #3c3c3c; + font-size: 13px; + box-shadow: 0 2px 3px rgba(0, 0, 0, 0.05); +} + +.mytheme .valo-menu-responsive[width-range~="801px-1100px"] .valo-menu-part [class*="subtitle"] [class*="badge"] { + right: 9px; +} + +.mytheme .valo-menu-responsive[width-range~="801px-1100px"] .valo-menu-part [class*="subtitle"] + .valo-menu-item { + border-top: none; +} + +.mytheme .valo-menu-responsive[width-range~="801px-1100px"] .valo-menu-part .valo-menu-item { + display: block; + font-size: 26px; + line-height: 1; + padding: 12px; + text-align: center; + border-top: 1px solid #555555; +} + +.mytheme .valo-menu-responsive[width-range~="801px-1100px"] .valo-menu-part .valo-menu-item:first-child { + border-top: none; +} + +.mytheme .valo-menu-responsive[width-range~="801px-1100px"] .valo-menu-part .valo-menu-item [class*="caption"] { + display: block; + width: auto; + margin: 0.3em 0 0; + padding: 0; + font-size: 11px; + line-height: 1.3; +} + +.mytheme .valo-menu-responsive[width-range~="801px-1100px"] .valo-menu-part .valo-menu-item .v-icon { + margin: 0; +} + +.mytheme .valo-menu-responsive[width-range~="801px-1100px"] .valo-menu-part .valo-menu-item span.v-icon { + opacity: 0.8; +} + +.mytheme .valo-menu-responsive[width-range~="801px-1100px"] .valo-menu-part .valo-menu-item.selected { + background: #434343; +} + +.mytheme .valo-menu-responsive[width-range~="801px-1100px"] .valo-menu-part .valo-menu-item.selected .v-icon { + opacity: 1; +} + +.mytheme .valo-menu-responsive[width-range~="801px-1100px"] .valo-menu-part .valo-menu-item.selected [class*="badge"] { + border-color: #434343; +} + +.mytheme .valo-menu-responsive[width-range~="801px-1100px"] .valo-menu-part .valo-menu-item [class*="badge"] { + padding-left: 4px; + padding-right: 4px; + top: 7px; + right: 7px; + border: 2px solid #4b4b4b; +} + +.mytheme .valo-menu-responsive[width-range~="0-800px"] { + padding-top: 37px; + -webkit-box-sizing: border-box; + box-sizing: border-box; +} + +.mytheme .valo-menu-responsive[width-range~="0-800px"] .v-loading-indicator { + top: 37px; +} + +.mytheme .valo-menu-responsive[width-range~="0-800px"] > .v-widget { + position: relative !important; +} + +.mytheme .valo-menu-responsive[width-range~="0-800px"] .valo-menu { + border-right: none; +} + +.mytheme .valo-menu-responsive[width-range~="0-800px"] .valo-menu-part { + overflow: visible; +} + +.mytheme .valo-menu-responsive[width-range~="0-800px"] .valo-menu-toggle { + display: inline-block; +} + +.mytheme .valo-menu-responsive[width-range~="0-800px"] .valo-menu-title { + position: fixed; + z-index: 100; + top: 0; + left: 0; + right: 0; + height: 37px !important; + padding-top: 0; + padding-bottom: 0; + -webkit-backface-visibility: hidden; +} + +.mytheme .valo-menu-responsive[width-range~="0-800px"] .valo-menu .v-menubar-user-menu { + position: fixed; + z-index: 100; + top: 0; + right: 0; + margin: 0; + padding: 0; + height: 37px; + color: #97bee5; + max-width: 30%; + -webkit-backface-visibility: hidden; +} + +.mytheme .valo-menu-responsive[width-range~="0-800px"] .valo-menu .v-menubar-user-menu .v-menubar-menuitem { + line-height: 36px; + white-space: nowrap; +} + +.mytheme .valo-menu-responsive[width-range~="0-800px"] .valo-menu .v-menubar-user-menu img.v-icon { + display: inline-block; + margin: 0 6px 0 0; + width: 19px; + height: 19px; + border-radius: 10px; + border: none; +} + +.mytheme .valo-menu-responsive[width-range~="0-800px"] .valo-menuitems { + height: 100%; + background-color: #4b4b4b; + background-image: -webkit-linear-gradient(right, #414141 0%, #4b4b4b 9px); + background-image: linear-gradient(to left,#414141 0%, #4b4b4b 9px); + color: #a5a5a5; + font-size: 14px; + line-height: 30px; + border-right: 1px solid #3b3b3b; + white-space: nowrap; + position: fixed; + z-index: 9000; + top: 37px; + bottom: 0; + height: auto; + max-width: 100%; + overflow: auto; + padding: 19px 0; + -webkit-transform: translatex(-100%); + -moz-transform: translatex(-100%); + -ms-transform: translatex(-100%); + -o-transform: translatex(-100%); + transform: translatex(-100%); + -webkit-transition: all 300ms; + -moz-transition: all 300ms; + transition: all 300ms; +} + +.mytheme .valo-menu-responsive[width-range~="0-800px"] .valo-menu-visible .valo-menuitems, .mytheme .valo-menu-responsive[width-range~="0-800px"] .valo-menu-hover:hover .valo-menuitems { + -webkit-transform: translatex(0%); + -moz-transform: translatex(0%); + -ms-transform: translatex(0%); + -o-transform: translatex(0%); + transform: translatex(0%); +} + +.mytheme .valo-menu-responsive[width-range~="0-500px"] .valo-menu-toggle .v-button-caption { + display: none; +} + +.mytheme .valo-menu-responsive[width-range~="0-500px"] .valo-menu .v-menubar-user-menu .v-menubar-menuitem-caption { + display: inline-block; + width: 19px; + overflow: hidden; +} \ No newline at end of file diff --git a/libraries/src/main/webapp/VAADIN/themes/mytheme/styles.scss b/libraries/src/main/webapp/VAADIN/themes/mytheme/styles.scss new file mode 100644 index 0000000000..bba1d493c0 --- /dev/null +++ b/libraries/src/main/webapp/VAADIN/themes/mytheme/styles.scss @@ -0,0 +1,11 @@ +@import "mytheme.scss"; +@import "addons.scss"; + +// This file prefixes all rules with the theme name to avoid causing conflicts with other themes. +// The actual styles should be defined in mytheme.scss + +.mytheme { + @include addons; + @include mytheme; + +} diff --git a/libraries/src/main/webapp/VAADIN/themes/valo/addons.scss b/libraries/src/main/webapp/VAADIN/themes/valo/addons.scss new file mode 100644 index 0000000000..a5670b70c7 --- /dev/null +++ b/libraries/src/main/webapp/VAADIN/themes/valo/addons.scss @@ -0,0 +1,7 @@ +/* This file is automatically managed and will be overwritten from time to time. */ +/* Do not manually edit this file. */ + +/* Import and include this mixin into your project theme to include the addon themes */ +@mixin addons { +} + diff --git a/libraries/src/test/java/com/baeldung/vaadin/VaadinUITests.java b/libraries/src/test/java/com/baeldung/vaadin/VaadinUITests.java new file mode 100644 index 0000000000..1b7a35d865 --- /dev/null +++ b/libraries/src/test/java/com/baeldung/vaadin/VaadinUITests.java @@ -0,0 +1,99 @@ +package com.baeldung.vaadin; +import static org.junit.Assert.assertEquals; + +import org.eclipse.jetty.server.Connector; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.ServerConnector; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHolder; +import org.eclipse.jetty.util.thread.QueuedThreadPool; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.htmlunit.HtmlUnitDriver; + +import com.gargoylesoftware.htmlunit.BrowserVersion; +import com.vaadin.server.DefaultUIProvider; +import com.vaadin.server.VaadinServlet; + + +public class VaadinUITests { + + private WebDriver driver; + private Server server; + + @Before + public void setUp() throws Exception{ + startJettyServer(); + driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_45,true); + driver.get("http://localhost:8080"); + Thread.sleep(10000); + } + + @Test + public void whenPageLoadedThenShouldSeeURL(){ + String url = driver.getCurrentUrl(); + assertEquals("http://localhost:8080/", url); + } + + @Test + public void givenLabel_WhenGetValue_ThenValueMatch() { + WebElement label = driver.findElement(By.id("Label")); + assertEquals("Label Value", label.getText()); + } + + @Test + public void givenTextField_WhenGetValue_ThenValueMatch() { + WebElement textField = driver.findElement(By.id("TextField")); + assertEquals("TextField Value", textField.getAttribute("Value")); + } + + @Test + public void givenTextArea_WhenGetValue_ThenValueMatch() { + WebElement textArea = driver.findElement(By.id("TextArea")); + assertEquals("TextArea Value", textArea.getAttribute("Value")); + } + + @Test + public void givenDateField_WhenGetValue_ThenValueMatch() { + WebElement dateField = driver.findElement(By.id("DateField")); + assertEquals("12/31/69", dateField.getText()); + } + + @Test + public void givenPasswordField_WhenGetValue_ThenValueMatch() { + WebElement passwordField = driver.findElement(By.id("PasswordField")); + assertEquals("password", passwordField.getAttribute("Value")); + } + + @After + public void cleanUp() throws Exception{ + driver.close(); + server.stop(); + } + + public void startJettyServer() throws Exception{ + + int maxThreads = 100; + int minThreads = 10; + int idleTimeout = 120; + + QueuedThreadPool threadPool = new QueuedThreadPool(maxThreads, minThreads, idleTimeout); + server = new Server(threadPool); + ServerConnector connector = new ServerConnector(server); + connector.setPort(8080); + server.setConnectors(new Connector[]{connector}); + ServletContextHandler contextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS); + contextHandler.setContextPath("/"); + ServletHolder sh = new ServletHolder(new VaadinServlet()); + contextHandler.addServlet(sh, "/*"); + contextHandler.setInitParameter("ui", VaadinUI.class.getName()); + contextHandler.setInitParameter(VaadinServlet.SERVLET_PARAMETER_UI_PROVIDER, DefaultUIProvider.class.getName()); + server.setHandler(contextHandler); + + server.start(); + } +} \ No newline at end of file From 1b9353c83ed099982495e76ff23c22ffc405f69f Mon Sep 17 00:00:00 2001 From: Tomasz Lelek Date: Mon, 10 Jul 2017 21:02:21 +0200 Subject: [PATCH 15/89] Bael 806 lazy (#2248) * BAEL-806 lazy article code * BAEL-806 remove comment --- .../lazy/ClassWithHeavyInitialization.java | 14 ++++ .../com/baeldung/kotlin/LazyJavaUnitTest.java | 20 ++++++ .../com/baeldung/kotlin/LazyUnitTest.kt | 68 +++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 kotlin/src/main/java/com/baeldung/lazy/ClassWithHeavyInitialization.java create mode 100644 kotlin/src/test/java/com/baeldung/kotlin/LazyJavaUnitTest.java create mode 100644 kotlin/src/test/kotlin/com/baeldung/kotlin/LazyUnitTest.kt diff --git a/kotlin/src/main/java/com/baeldung/lazy/ClassWithHeavyInitialization.java b/kotlin/src/main/java/com/baeldung/lazy/ClassWithHeavyInitialization.java new file mode 100644 index 0000000000..273749e17e --- /dev/null +++ b/kotlin/src/main/java/com/baeldung/lazy/ClassWithHeavyInitialization.java @@ -0,0 +1,14 @@ +package com.baeldung.lazy; + +public class ClassWithHeavyInitialization { + private ClassWithHeavyInitialization() { + } + + private static class LazyHolder { + public static final ClassWithHeavyInitialization INSTANCE = new ClassWithHeavyInitialization(); + } + + public static ClassWithHeavyInitialization getInstance() { + return LazyHolder.INSTANCE; + } +} \ No newline at end of file diff --git a/kotlin/src/test/java/com/baeldung/kotlin/LazyJavaUnitTest.java b/kotlin/src/test/java/com/baeldung/kotlin/LazyJavaUnitTest.java new file mode 100644 index 0000000000..e2fe58d537 --- /dev/null +++ b/kotlin/src/test/java/com/baeldung/kotlin/LazyJavaUnitTest.java @@ -0,0 +1,20 @@ +package com.baeldung.kotlin; + + +import com.baeldung.lazy.ClassWithHeavyInitialization; +import org.junit.Test; + +import static junit.framework.TestCase.assertTrue; + +public class LazyJavaUnitTest { + + @Test + public void giveHeavyClass_whenInitLazy_thenShouldReturnInstanceOnFirstCall() { + //when + ClassWithHeavyInitialization classWithHeavyInitialization = ClassWithHeavyInitialization.getInstance(); + ClassWithHeavyInitialization classWithHeavyInitialization2 = ClassWithHeavyInitialization.getInstance(); + + //then + assertTrue(classWithHeavyInitialization == classWithHeavyInitialization2); + } +} diff --git a/kotlin/src/test/kotlin/com/baeldung/kotlin/LazyUnitTest.kt b/kotlin/src/test/kotlin/com/baeldung/kotlin/LazyUnitTest.kt new file mode 100644 index 0000000000..9e4179f4fe --- /dev/null +++ b/kotlin/src/test/kotlin/com/baeldung/kotlin/LazyUnitTest.kt @@ -0,0 +1,68 @@ +package com.baeldung.kotlin + +import org.junit.Test +import java.util.concurrent.CountDownLatch +import java.util.concurrent.Executors +import java.util.concurrent.TimeUnit +import java.util.concurrent.atomic.AtomicInteger +import kotlin.test.assertEquals + +class LazyUnitTest { + @Test + fun givenLazyValue_whenGetIt_thenShouldInitializeItOnlyOnce() { + //given + val numberOfInitializations: AtomicInteger = AtomicInteger() + val lazyValue: ClassWithHeavyInitialization by lazy { + numberOfInitializations.incrementAndGet() + ClassWithHeavyInitialization() + } + //when + println(lazyValue) + println(lazyValue) + + //then + assertEquals(numberOfInitializations.get(), 1) + } + + @Test + fun givenLazyValue_whenGetItUsingPublication_thenCouldInitializeItMoreThanOnce() { + //given + val numberOfInitializations: AtomicInteger = AtomicInteger() + val lazyValue: ClassWithHeavyInitialization by lazy(LazyThreadSafetyMode.PUBLICATION) { + numberOfInitializations.incrementAndGet() + ClassWithHeavyInitialization() + } + val executorService = Executors.newFixedThreadPool(2) + val countDownLatch = CountDownLatch(1) + //when + executorService.submit { countDownLatch.await(); println(lazyValue) } + executorService.submit { countDownLatch.await(); println(lazyValue) } + countDownLatch.countDown() + + //then + executorService.awaitTermination(1, TimeUnit.SECONDS) + executorService.shutdown() + assertEquals(numberOfInitializations.get(), 2) + } + + class ClassWithHeavyInitialization { + + } + + + lateinit var a: String + @Test + fun givenLateInitProperty_whenAccessItAfterInit_thenPass() { + //when + a = "it" + println(a) + + //then not throw + } + + @Test(expected = UninitializedPropertyAccessException::class) + fun givenLateInitProperty_whenAccessItWithoutInit_thenThrow() { + //when + println(a) + } +} \ No newline at end of file From 9c643cd652e52a48efe1213e7a1c4810c070307c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Ju=C3=A1rez?= Date: Mon, 10 Jul 2017 20:04:02 -0500 Subject: [PATCH 16/89] BAEL-970 A Guide to Apache Commons DbUtils (#2125) * BAEL-970 A Guide to Apache Commons DbUtils * BAEL-970 A Guide to Apache Commons DbUtils * BAEL-970 A Guide to Apache Commons DbUtils - Added employeeId to Email class - Minor corrections --- libraries/pom.xml | 9 +- .../com/baeldung/commons/dbutils/Email.java | 38 +++++ .../baeldung/commons/dbutils/Employee.java | 67 ++++++++ .../commons/dbutils/EmployeeHandler.java | 45 +++++ .../commons/dbutils/DbUtilsUnitTest.java | 160 ++++++++++++++++++ libraries/src/test/resources/employees.sql | 43 +++++ 6 files changed, 361 insertions(+), 1 deletion(-) create mode 100644 libraries/src/main/java/com/baeldung/commons/dbutils/Email.java create mode 100644 libraries/src/main/java/com/baeldung/commons/dbutils/Employee.java create mode 100644 libraries/src/main/java/com/baeldung/commons/dbutils/EmployeeHandler.java create mode 100644 libraries/src/test/java/com/baeldung/commons/dbutils/DbUtilsUnitTest.java create mode 100644 libraries/src/test/resources/employees.sql diff --git a/libraries/pom.xml b/libraries/pom.xml index 28dd36fceb..dfae8085bb 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -227,6 +227,11 @@ commons-io ${commons.io.version} + + commons-dbutils + commons-dbutils + ${commons.dbutils.version} + org.apache.flink flink-core @@ -369,7 +374,7 @@ com.h2database h2 - 1.4.195 + ${h2.version} pl.pragmatists @@ -530,6 +535,8 @@ 9.4.3.v20170317 4.5.3 2.5 + 1.6 + 1.4.196 9.4.2.v20170220 4.5.3 2.5 diff --git a/libraries/src/main/java/com/baeldung/commons/dbutils/Email.java b/libraries/src/main/java/com/baeldung/commons/dbutils/Email.java new file mode 100644 index 0000000000..c82798d52d --- /dev/null +++ b/libraries/src/main/java/com/baeldung/commons/dbutils/Email.java @@ -0,0 +1,38 @@ +package com.baeldung.commons.dbutils; + +public class Email { + private Integer id; + private Integer employeeId; + private String address; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getEmployeeId() { + return employeeId; + } + + public void setEmployeeId(Integer employeeId) { + this.employeeId = employeeId; + } + + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + @Override + public String toString() { + return "Email{" + "id=" + id + ", address=" + address + '}'; + } + +} diff --git a/libraries/src/main/java/com/baeldung/commons/dbutils/Employee.java b/libraries/src/main/java/com/baeldung/commons/dbutils/Employee.java new file mode 100644 index 0000000000..e6f34c0201 --- /dev/null +++ b/libraries/src/main/java/com/baeldung/commons/dbutils/Employee.java @@ -0,0 +1,67 @@ +package com.baeldung.commons.dbutils; + +import java.util.Date; +import java.util.List; + +public class Employee { + private Integer id; + private String firstName; + private String lastName; + private Double salary; + private Date hiredDate; + private List emails; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public Double getSalary() { + return salary; + } + + public void setSalary(Double salary) { + this.salary = salary; + } + + public Date getHiredDate() { + return hiredDate; + } + + public void setHiredDate(Date hiredDate) { + this.hiredDate = hiredDate; + } + + public List getEmails() { + return emails; + } + + public void setEmails(List emails) { + this.emails = emails; + } + + @Override + public String toString() { + return "Employee{" + "id=" + id + ", firstName=" + firstName + ", lastName=" + lastName + ", salary=" + salary + ", hiredDate=" + hiredDate + '}'; + } + +} \ No newline at end of file diff --git a/libraries/src/main/java/com/baeldung/commons/dbutils/EmployeeHandler.java b/libraries/src/main/java/com/baeldung/commons/dbutils/EmployeeHandler.java new file mode 100644 index 0000000000..6f68bafe57 --- /dev/null +++ b/libraries/src/main/java/com/baeldung/commons/dbutils/EmployeeHandler.java @@ -0,0 +1,45 @@ +package com.baeldung.commons.dbutils; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.commons.dbutils.BasicRowProcessor; +import org.apache.commons.dbutils.BeanProcessor; + +import org.apache.commons.dbutils.QueryRunner; +import org.apache.commons.dbutils.handlers.BeanListHandler; + +public class EmployeeHandler extends BeanListHandler { + + private Connection connection; + + public EmployeeHandler(Connection con) { + super(Employee.class, new BasicRowProcessor(new BeanProcessor(getColumnsToFieldsMap()))); + this.connection = con; + } + + @Override + public List handle(ResultSet rs) throws SQLException { + List employees = super.handle(rs); + + QueryRunner runner = new QueryRunner(); + BeanListHandler handler = new BeanListHandler<>(Email.class); + String query = "SELECT * FROM email WHERE employeeid = ?"; + for (Employee employee : employees) { + List emails = runner.query(connection, query, handler, employee.getId()); + employee.setEmails(emails); + } + return employees; + } + + public static Map getColumnsToFieldsMap() { + Map columnsToFieldsMap = new HashMap<>(); + columnsToFieldsMap.put("FIRST_NAME", "firstName"); + columnsToFieldsMap.put("LAST_NAME", "lastName"); + columnsToFieldsMap.put("HIRED_DATE", "hiredDate"); + return columnsToFieldsMap; + } +} diff --git a/libraries/src/test/java/com/baeldung/commons/dbutils/DbUtilsUnitTest.java b/libraries/src/test/java/com/baeldung/commons/dbutils/DbUtilsUnitTest.java new file mode 100644 index 0000000000..8eb2fd1350 --- /dev/null +++ b/libraries/src/test/java/com/baeldung/commons/dbutils/DbUtilsUnitTest.java @@ -0,0 +1,160 @@ +package com.baeldung.commons.dbutils; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import org.apache.commons.dbutils.AsyncQueryRunner; +import org.apache.commons.dbutils.DbUtils; +import org.apache.commons.dbutils.QueryRunner; +import org.apache.commons.dbutils.handlers.BeanListHandler; +import org.apache.commons.dbutils.handlers.MapListHandler; +import org.apache.commons.dbutils.handlers.ScalarHandler; +import org.junit.After; +import static org.junit.Assert.*; +import org.junit.Before; +import org.junit.Test; + +public class DbUtilsUnitTest { + + private Connection connection; + + @Before + public void setupDB() throws Exception { + Class.forName("org.h2.Driver"); + String db = "jdbc:h2:mem:;INIT=runscript from 'classpath:/employees.sql'"; + connection = DriverManager.getConnection(db); + } + + @After + public void closeBD() { + DbUtils.closeQuietly(connection); + } + + @Test + public void givenResultHandler_whenExecutingQuery_thenExpectedList() throws SQLException { + MapListHandler beanListHandler = new MapListHandler(); + + QueryRunner runner = new QueryRunner(); + List> list = runner.query(connection, "SELECT * FROM employee", beanListHandler); + + assertEquals(list.size(), 5); + assertEquals(list.get(0) + .get("firstname"), "John"); + assertEquals(list.get(4) + .get("firstname"), "Christian"); + } + + @Test + public void givenResultHandler_whenExecutingQuery_thenEmployeeList() throws SQLException { + BeanListHandler beanListHandler = new BeanListHandler<>(Employee.class); + + QueryRunner runner = new QueryRunner(); + List employeeList = runner.query(connection, "SELECT * FROM employee", beanListHandler); + + assertEquals(employeeList.size(), 5); + assertEquals(employeeList.get(0) + .getFirstName(), "John"); + assertEquals(employeeList.get(4) + .getFirstName(), "Christian"); + } + + @Test + public void givenResultHandler_whenExecutingQuery_thenExpectedScalar() throws SQLException { + ScalarHandler scalarHandler = new ScalarHandler<>(); + + QueryRunner runner = new QueryRunner(); + String query = "SELECT COUNT(*) FROM employee"; + long count = runner.query(connection, query, scalarHandler); + + assertEquals(count, 5); + } + + @Test + public void givenResultHandler_whenExecutingQuery_thenEmailsSetted() throws SQLException { + EmployeeHandler employeeHandler = new EmployeeHandler(connection); + + QueryRunner runner = new QueryRunner(); + List employees = runner.query(connection, "SELECT * FROM employee", employeeHandler); + + assertEquals(employees.get(0) + .getEmails() + .size(), 2); + assertEquals(employees.get(2) + .getEmails() + .size(), 3); + assertNotNull(employees.get(0).getEmails().get(0).getEmployeeId()); + } + + @Test + public void givenResultHandler_whenExecutingQuery_thenAllPropertiesSetted() throws SQLException { + EmployeeHandler employeeHandler = new EmployeeHandler(connection); + + QueryRunner runner = new QueryRunner(); + String query = "SELECT * FROM employee_legacy"; + List employees = runner.query(connection, query, employeeHandler); + + assertEquals((int) employees.get(0).getId(), 1); + assertEquals(employees.get(0).getFirstName(), "John"); + } + + @Test + public void whenInserting_thenInserted() throws SQLException { + QueryRunner runner = new QueryRunner(); + String insertSQL = "INSERT INTO employee (firstname,lastname,salary, hireddate) VALUES (?, ?, ?, ?)"; + + int numRowsInserted = runner.update(connection, insertSQL, "Leia", "Kane", 60000.60, new Date()); + + assertEquals(numRowsInserted, 1); + } + + @Test + public void givenHandler_whenInserting_thenExpectedId() throws SQLException { + ScalarHandler scalarHandler = new ScalarHandler<>(); + + QueryRunner runner = new QueryRunner(); + String insertSQL = "INSERT INTO employee (firstname,lastname,salary, hireddate) VALUES (?, ?, ?, ?)"; + + int newId = runner.insert(connection, insertSQL, scalarHandler, "Jenny", "Medici", 60000.60, new Date()); + + assertEquals(newId, 6); + } + + @Test + public void givenSalary_whenUpdating_thenUpdated() throws SQLException { + double salary = 35000; + + QueryRunner runner = new QueryRunner(); + String updateSQL = "UPDATE employee SET salary = salary * 1.1 WHERE salary <= ?"; + int numRowsUpdated = runner.update(connection, updateSQL, salary); + + assertEquals(numRowsUpdated, 3); + } + + @Test + public void whenDeletingRecord_thenDeleted() throws SQLException { + QueryRunner runner = new QueryRunner(); + String deleteSQL = "DELETE FROM employee WHERE id = ?"; + int numRowsDeleted = runner.update(connection, deleteSQL, 3); + + assertEquals(numRowsDeleted, 1); + } + + @Test + public void givenAsyncRunner_whenExecutingQuery_thenExpectedList() throws Exception { + AsyncQueryRunner runner = new AsyncQueryRunner(Executors.newCachedThreadPool()); + + EmployeeHandler employeeHandler = new EmployeeHandler(connection); + String query = "SELECT * FROM employee"; + Future> future = runner.query(connection, query, employeeHandler); + List employeeList = future.get(10, TimeUnit.SECONDS); + + assertEquals(employeeList.size(), 5); + } + +} diff --git a/libraries/src/test/resources/employees.sql b/libraries/src/test/resources/employees.sql new file mode 100644 index 0000000000..c6109724cf --- /dev/null +++ b/libraries/src/test/resources/employees.sql @@ -0,0 +1,43 @@ +CREATE TABLE employee( + id int NOT NULL PRIMARY KEY auto_increment, + firstname varchar(255), + lastname varchar(255), + salary double, + hireddate date +); + +CREATE TABLE email( + id int NOT NULL PRIMARY KEY auto_increment, + employeeid int, + address varchar(255) +); + +CREATE TABLE employee_legacy( + id int NOT NULL PRIMARY KEY auto_increment, + first_name varchar(255), + last_name varchar(255), + salary double, + hired_date date +); + + +INSERT INTO employee (firstname,lastname,salary,hireddate) VALUES ('John', 'Doe', 10000.10, to_date('01-01-2001','dd-mm-yyyy')); +INSERT INTO employee (firstname,lastname,salary,hireddate) VALUES ('Kevin', 'Smith', 20000.20, to_date('02-02-2002','dd-mm-yyyy')); +INSERT INTO employee (firstname,lastname,salary,hireddate) VALUES ('Kim', 'Smith', 30000.30, to_date('03-03-2003','dd-mm-yyyy')); +INSERT INTO employee (firstname,lastname,salary,hireddate) VALUES ('Stephen', 'Torvalds', 40000.40, to_date('04-04-2004','dd-mm-yyyy')); +INSERT INTO employee (firstname,lastname,salary,hireddate) VALUES ('Christian', 'Reynolds', 50000.50, to_date('05-05-2005','dd-mm-yyyy')); + +INSERT INTO employee_legacy (first_name,last_name,salary,hired_date) VALUES ('John', 'Doe', 10000.10, to_date('01-01-2001','dd-mm-yyyy')); +INSERT INTO employee_legacy (first_name,last_name,salary,hired_date) VALUES ('Kevin', 'Smith', 20000.20, to_date('02-02-2002','dd-mm-yyyy')); +INSERT INTO employee_legacy (first_name,last_name,salary,hired_date) VALUES ('Kim', 'Smith', 30000.30, to_date('03-03-2003','dd-mm-yyyy')); +INSERT INTO employee_legacy (first_name,last_name,salary,hired_date) VALUES ('Stephen', 'Torvalds', 40000.40, to_date('04-04-2004','dd-mm-yyyy')); +INSERT INTO employee_legacy (first_name,last_name,salary,hired_date) VALUES ('Christian', 'Reynolds', 50000.50, to_date('05-05-2005','dd-mm-yyyy')); + +INSERT INTO email (employeeid,address) VALUES (1, 'john@baeldung.com'); +INSERT INTO email (employeeid,address) VALUES (1, 'john@gmail.com'); +INSERT INTO email (employeeid,address) VALUES (2, 'kevin@baeldung.com'); +INSERT INTO email (employeeid,address) VALUES (3, 'kim@baeldung.com'); +INSERT INTO email (employeeid,address) VALUES (3, 'kim@gmail.com'); +INSERT INTO email (employeeid,address) VALUES (3, 'kim@outlook.com'); +INSERT INTO email (employeeid,address) VALUES (4, 'stephen@baeldung.com'); +INSERT INTO email (employeeid,address) VALUES (5, 'christian@gmail.com'); From 2f651ddea33f0418c6c405204895b0c6e807c1af Mon Sep 17 00:00:00 2001 From: KevinGilmore Date: Mon, 10 Jul 2017 20:20:20 -0500 Subject: [PATCH 17/89] BAEL-1005: README (#2246) * BAEL-886: Updated README * BAEL-917 Testing with Google Truth Updated README * BAEL-936: adding akka-streams module to parent * BAEL-936: Update README * BAEL-918: Update README * BAEL-980: Update README * BAEL-967: Update README * BAEL-509: Using @GetMapping instead of @RequestMapping with method=GET * BAEL-1005: Update README --- guava/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/guava/README.md b/guava/README.md index 56d282560b..7ab70cb01f 100644 --- a/guava/README.md +++ b/guava/README.md @@ -28,3 +28,4 @@ - [Guide to Guava ClassToInstanceMap](http://www.baeldung.com/guava-class-to-instance-map) - [Guide to Guava MinMaxPriorityQueue and EvictingQueue](http://www.baeldung.com/guava-minmax-priority-queue-and-evicting-queue) - [Guide to Mathematical Utilities in Guava](http://www.baeldung.com/guava-math) +- [Bloom Filter in Java using Guava](http://www.baeldung.com/guava-bloom-filter) From e6a0bbe0906344bb6dfceca7ed884288ba41f84a Mon Sep 17 00:00:00 2001 From: Tomasz Lelek Date: Tue, 11 Jul 2017 04:05:08 +0200 Subject: [PATCH 18/89] BAEL-1010 HLL article code (#2188) * BAEL-1010 HLL article code * BAEL-1010 moved tolerated difference to a variable * Merge branch 'master' of https://github.com/eugenp/tutorials into BAEL-1010_hll # Conflicts: # libraries/pom.xml --- libraries/pom.xml | 16 +++-- .../java/com/baeldung/hll/HLLUnitTest.java | 67 +++++++++++++++++++ 2 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 libraries/src/test/java/com/baeldung/hll/HLLUnitTest.java diff --git a/libraries/pom.xml b/libraries/pom.xml index dfae8085bb..c3535f884a 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -485,22 +485,22 @@ org.eclipse.jetty.websocket websocket-server ${jetty.version} - + org.eclipse.jetty.websocket websocket-client ${jetty.version} - + org.eclipse.jetty.websocket websocket-api ${jetty.version} - + org.eclipse.jetty.websocket websocket-common ${jetty.version} - + org.eclipse.jetty jetty-continuation @@ -510,7 +510,7 @@ org.eclipse.jetty jetty-util ${jetty.version} - + org.seleniumhq.selenium selenium-api @@ -519,6 +519,11 @@ jar + + net.agkn + hll + ${hll.version} + 0.7.0 @@ -559,6 +564,7 @@ 8.0.6 mytheme + 1.6.0 diff --git a/libraries/src/test/java/com/baeldung/hll/HLLUnitTest.java b/libraries/src/test/java/com/baeldung/hll/HLLUnitTest.java new file mode 100644 index 0000000000..1d318b7e4e --- /dev/null +++ b/libraries/src/test/java/com/baeldung/hll/HLLUnitTest.java @@ -0,0 +1,67 @@ +package com.baeldung.hll; + + +import com.google.common.hash.HashFunction; +import com.google.common.hash.Hashing; +import net.agkn.hll.HLL; +import org.junit.Test; + +import java.util.stream.LongStream; + +import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; + +public class HLLUnitTest { + + @Test + public void givenHLL_whenAddHugeAmountOfNumbers_thenShouldReturnEstimatedCardinality() { + //given + int numberOfElements = 100_000_000; + int toleratedDifference = 1_000_000; + HashFunction hashFunction = Hashing.murmur3_128(); + HLL hll = new HLL(14, 5); + + //when + LongStream.range(0, numberOfElements).forEach(element -> { + long hashedValue = hashFunction.newHasher().putLong(element).hash().asLong(); + hll.addRaw(hashedValue); + } + ); + + //then + long cardinality = hll.cardinality(); + assertThat(isSimilarTo(cardinality, numberOfElements, toleratedDifference)).isTrue(); + } + + @Test + public void givenTwoHLLs_whenAddHugeAmountOfNumbers_thenShouldReturnEstimatedCardinalityForUnionOfHLLs() { + //given + int numberOfElements = 100_000_000; + int toleratedDifference = 1_000_000; + HashFunction hashFunction = Hashing.murmur3_128(); + HLL firstHll = new HLL(15, 5); + HLL secondHLL = new HLL(15, 5); + + //when + LongStream.range(0, numberOfElements).forEach(element -> { + long hashedValue = hashFunction.newHasher().putLong(element).hash().asLong(); + firstHll.addRaw(hashedValue); + } + ); + + LongStream.range(numberOfElements, numberOfElements * 2).forEach(element -> { + long hashedValue = hashFunction.newHasher().putLong(element).hash().asLong(); + secondHLL.addRaw(hashedValue); + } + ); + + //then + firstHll.union(secondHLL); + long cardinality = firstHll.cardinality(); + assertThat(isSimilarTo(cardinality, numberOfElements * 2, toleratedDifference)).isTrue(); + } + + private boolean isSimilarTo(long cardinality, int numberOfElements, int maxToleratedDifference) { + System.out.println(cardinality); + return Math.abs(cardinality - numberOfElements) <= maxToleratedDifference; + } +} From dfae14537bf80832be8cedda2583a897bc5b71b4 Mon Sep 17 00:00:00 2001 From: lor6 Date: Tue, 11 Jul 2017 08:54:52 +0300 Subject: [PATCH 19/89] junit 5 extensions (#2233) * junit 5 extensions * fix exceptions * add back parent --- junit5/pom.xml | 90 ++++++++++++------- .../test/java/com/baeldung/EmployeesTest.java | 48 ++++++++++ .../test/java/com/baeldung/TestLauncher.java | 37 ++++++++ .../EmployeeDaoParameterResolver.java | 23 +++++ .../EmployeeDatabaseSetupExtension.java | 46 ++++++++++ .../extensions/EnvironmentExtension.java | 27 ++++++ .../IgnoreFileNotFoundExceptionExtension.java | 23 +++++ .../baeldung/extensions/LoggingExtension.java | 16 ++++ .../com/baeldung/helpers/EmployeeJdbcDao.java | 51 +++++++++++ .../baeldung/helpers/JdbcConnectionUtil.java | 32 +++++++ .../junit5/extensions/TraceUnitExtension.java | 6 +- .../java/com/baeldung/suites/AllTests.java | 8 +- .../org.junit.jupiter.api.extension.Extension | 1 + .../extensions/application.properties | 1 + .../com/baeldung/helpers/jdbc.properties | 5 ++ 15 files changed, 376 insertions(+), 38 deletions(-) create mode 100644 junit5/src/test/java/com/baeldung/EmployeesTest.java create mode 100644 junit5/src/test/java/com/baeldung/TestLauncher.java create mode 100644 junit5/src/test/java/com/baeldung/extensions/EmployeeDaoParameterResolver.java create mode 100644 junit5/src/test/java/com/baeldung/extensions/EmployeeDatabaseSetupExtension.java create mode 100644 junit5/src/test/java/com/baeldung/extensions/EnvironmentExtension.java create mode 100644 junit5/src/test/java/com/baeldung/extensions/IgnoreFileNotFoundExceptionExtension.java create mode 100644 junit5/src/test/java/com/baeldung/extensions/LoggingExtension.java create mode 100644 junit5/src/test/java/com/baeldung/helpers/EmployeeJdbcDao.java create mode 100644 junit5/src/test/java/com/baeldung/helpers/JdbcConnectionUtil.java create mode 100644 junit5/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension create mode 100644 junit5/src/test/resources/com/baeldung/extensions/application.properties create mode 100644 junit5/src/test/resources/com/baeldung/helpers/jdbc.properties diff --git a/junit5/pom.xml b/junit5/pom.xml index 6cc1405de8..2316b034e9 100644 --- a/junit5/pom.xml +++ b/junit5/pom.xml @@ -9,7 +9,7 @@ junit5 Intro to JUnit 5 - + com.baeldung parent-modules @@ -19,16 +19,24 @@ UTF-8 1.8 - 5.0.0-M4 - 1.0.0-M4 - 4.12.0-M4 - 4.12 + 5.0.0-M5 + 1.0.0-M5 + 4.12.0-M5 + 2.8.2 + 1.4.196 3.6.0 2.19.1 + 4.12 + + + src/test/resources + true + + maven-compiler-plugin @@ -49,44 +57,60 @@ + + org.codehaus.mojo + exec-maven-plugin + 1.6.0 + + + + java + + + + + com.baeldung.TestLauncher + + - - - junit - junit - ${junit4.version} - test - - - - org.junit.jupiter - junit-jupiter-api - ${junit.jupiter.version} - test - - org.junit.jupiter junit-jupiter-engine ${junit.jupiter.version} test - - org.junit.platform - junit-platform-runner - ${junit.platform.version} - test - - - + org.junit.platform + junit-platform-runner + ${junit.platform.version} + test + + + org.junit.vintage + junit-vintage-engine + ${junit.vintage.version} + test + + + org.apache.logging.log4j + log4j-core + ${log4j2.version} + + + com.h2database + h2 + ${h2.version} + + + junit + junit + ${junit4.version} + test + + + \ No newline at end of file diff --git a/junit5/src/test/java/com/baeldung/EmployeesTest.java b/junit5/src/test/java/com/baeldung/EmployeesTest.java new file mode 100644 index 0000000000..1a6da37d72 --- /dev/null +++ b/junit5/src/test/java/com/baeldung/EmployeesTest.java @@ -0,0 +1,48 @@ +package com.baeldung; + +import java.sql.SQLException; + +import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import com.baeldung.extensions.EmployeeDaoParameterResolver; +import com.baeldung.extensions.EmployeeDatabaseSetupExtension; +import com.baeldung.extensions.EnvironmentExtension; +import com.baeldung.extensions.IgnoreFileNotFoundExceptionExtension; +import com.baeldung.extensions.LoggingExtension; +import com.baeldung.helpers.Employee; +import com.baeldung.helpers.EmployeeJdbcDao; + +import static org.junit.jupiter.api.Assertions.*; + +@ExtendWith({ EnvironmentExtension.class, EmployeeDatabaseSetupExtension.class, EmployeeDaoParameterResolver.class }) +@ExtendWith(LoggingExtension.class) +@ExtendWith(IgnoreFileNotFoundExceptionExtension.class) +public class EmployeesTest { + + private EmployeeJdbcDao employeeDao; + + private Logger logger; + + public EmployeesTest(EmployeeJdbcDao employeeDao) { + this.employeeDao = employeeDao; + } + + @Test + public void whenAddEmployee_thenGetEmployee() throws SQLException { + Employee emp = new Employee(1, "john"); + employeeDao.add(emp); + assertEquals(1, employeeDao.findAll().size()); + } + + @Test + public void whenGetEmployees_thenEmptyList() throws SQLException { + assertEquals(0, employeeDao.findAll().size()); + } + + public void setLogger(Logger logger) { + this.logger = logger; + } + +} diff --git a/junit5/src/test/java/com/baeldung/TestLauncher.java b/junit5/src/test/java/com/baeldung/TestLauncher.java new file mode 100644 index 0000000000..d0354e19a9 --- /dev/null +++ b/junit5/src/test/java/com/baeldung/TestLauncher.java @@ -0,0 +1,37 @@ +package com.baeldung; + +import org.junit.platform.launcher.LauncherDiscoveryRequest; +import org.junit.platform.launcher.TestExecutionListener; +import org.junit.platform.launcher.TestPlan; +import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder; +import org.junit.platform.launcher.core.LauncherFactory; +import org.junit.platform.launcher.listeners.SummaryGeneratingListener; + +import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClass; + +import java.io.PrintWriter; + +import org.junit.platform.launcher.Launcher; + +public class TestLauncher { + public static void main(String[] args) { + + //@formatter:off + LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request() + .selectors(selectClass("com.baeldung.EmployeesTest")) + .configurationParameter("junit.conditions.deactivate", "com.baeldung.extensions.*") + .configurationParameter("junit.extensions.autodetection.enabled", "true") + .build(); + + //@formatter:on + + TestPlan plan = LauncherFactory.create().discover(request); + Launcher launcher = LauncherFactory.create(); + SummaryGeneratingListener summaryGeneratingListener = new SummaryGeneratingListener(); + launcher.execute(request, new TestExecutionListener[] { summaryGeneratingListener }); + launcher.execute(request); + + summaryGeneratingListener.getSummary().printTo(new PrintWriter(System.out)); + + } +} diff --git a/junit5/src/test/java/com/baeldung/extensions/EmployeeDaoParameterResolver.java b/junit5/src/test/java/com/baeldung/extensions/EmployeeDaoParameterResolver.java new file mode 100644 index 0000000000..2626266454 --- /dev/null +++ b/junit5/src/test/java/com/baeldung/extensions/EmployeeDaoParameterResolver.java @@ -0,0 +1,23 @@ +package com.baeldung.extensions; + +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.ParameterContext; +import org.junit.jupiter.api.extension.ParameterResolutionException; +import org.junit.jupiter.api.extension.ParameterResolver; + +import com.baeldung.helpers.EmployeeJdbcDao; +import com.baeldung.helpers.JdbcConnectionUtil; + +public class EmployeeDaoParameterResolver implements ParameterResolver { + + @Override + public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException { + return parameterContext.getParameter().getType().equals(EmployeeJdbcDao.class); + } + + @Override + public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException { + return new EmployeeJdbcDao(JdbcConnectionUtil.getConnection()); + } + +} diff --git a/junit5/src/test/java/com/baeldung/extensions/EmployeeDatabaseSetupExtension.java b/junit5/src/test/java/com/baeldung/extensions/EmployeeDatabaseSetupExtension.java new file mode 100644 index 0000000000..69e420b28a --- /dev/null +++ b/junit5/src/test/java/com/baeldung/extensions/EmployeeDatabaseSetupExtension.java @@ -0,0 +1,46 @@ +package com.baeldung.extensions; + +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Savepoint; + +import org.junit.jupiter.api.extension.AfterAllCallback; +import org.junit.jupiter.api.extension.AfterEachCallback; +import org.junit.jupiter.api.extension.BeforeAllCallback; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; + +import com.baeldung.helpers.EmployeeJdbcDao; +import com.baeldung.helpers.JdbcConnectionUtil; + +public class EmployeeDatabaseSetupExtension implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback { + + private Connection con = JdbcConnectionUtil.getConnection(); + private EmployeeJdbcDao employeeDao = new EmployeeJdbcDao(con); + private Savepoint savepoint; + + @Override + public void afterAll(ExtensionContext context) throws SQLException { + if (con != null) { + con.close(); + } + } + + @Override + public void beforeAll(ExtensionContext context) throws SQLException { + employeeDao.createTable(); + + } + + @Override + public void afterEach(ExtensionContext context) throws SQLException { + con.rollback(savepoint); + } + + @Override + public void beforeEach(ExtensionContext context) throws SQLException { + con.setAutoCommit(false); + savepoint = con.setSavepoint("before"); + } + +} diff --git a/junit5/src/test/java/com/baeldung/extensions/EnvironmentExtension.java b/junit5/src/test/java/com/baeldung/extensions/EnvironmentExtension.java new file mode 100644 index 0000000000..e2c335799b --- /dev/null +++ b/junit5/src/test/java/com/baeldung/extensions/EnvironmentExtension.java @@ -0,0 +1,27 @@ +package com.baeldung.extensions; + +import java.io.IOException; +import java.util.Properties; + +import org.junit.jupiter.api.extension.ConditionEvaluationResult; +import org.junit.jupiter.api.extension.ExecutionCondition; +import org.junit.jupiter.api.extension.ExtensionContext; + +public class EnvironmentExtension implements ExecutionCondition { + + @Override + public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { + Properties props = new Properties(); + + try { + props.load(EnvironmentExtension.class.getResourceAsStream("application.properties")); + String env = props.getProperty("env"); + if ("qa".equalsIgnoreCase(env)) { + return ConditionEvaluationResult.disabled("Test disabled on QA environment"); + } + } catch (IOException e) { + e.printStackTrace(); + } + return ConditionEvaluationResult.enabled("Test enabled on QA environment"); + } +} diff --git a/junit5/src/test/java/com/baeldung/extensions/IgnoreFileNotFoundExceptionExtension.java b/junit5/src/test/java/com/baeldung/extensions/IgnoreFileNotFoundExceptionExtension.java new file mode 100644 index 0000000000..7216c68c1a --- /dev/null +++ b/junit5/src/test/java/com/baeldung/extensions/IgnoreFileNotFoundExceptionExtension.java @@ -0,0 +1,23 @@ +package com.baeldung.extensions; + +import java.io.FileNotFoundException; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.TestExecutionExceptionHandler; + +public class IgnoreFileNotFoundExceptionExtension implements TestExecutionExceptionHandler { + + Logger logger = LogManager.getLogger(IgnoreFileNotFoundExceptionExtension.class); + + @Override + public void handleTestExecutionException(ExtensionContext context, Throwable throwable) throws Throwable { + + if (throwable instanceof FileNotFoundException) { + logger.error("File not found:" + throwable.getMessage()); + return; + } + throw throwable; + } +} diff --git a/junit5/src/test/java/com/baeldung/extensions/LoggingExtension.java b/junit5/src/test/java/com/baeldung/extensions/LoggingExtension.java new file mode 100644 index 0000000000..437c5c24de --- /dev/null +++ b/junit5/src/test/java/com/baeldung/extensions/LoggingExtension.java @@ -0,0 +1,16 @@ +package com.baeldung.extensions; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.TestInstancePostProcessor; + +public class LoggingExtension implements TestInstancePostProcessor { + + @Override + public void postProcessTestInstance(Object testInstance, ExtensionContext context) throws Exception { + Logger logger = LogManager.getLogger(testInstance.getClass()); + testInstance.getClass().getMethod("setLogger", Logger.class).invoke(testInstance, logger); + } + +} diff --git a/junit5/src/test/java/com/baeldung/helpers/EmployeeJdbcDao.java b/junit5/src/test/java/com/baeldung/helpers/EmployeeJdbcDao.java new file mode 100644 index 0000000000..7600f763cd --- /dev/null +++ b/junit5/src/test/java/com/baeldung/helpers/EmployeeJdbcDao.java @@ -0,0 +1,51 @@ +package com.baeldung.helpers; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class EmployeeJdbcDao { + + private Connection con; + + public EmployeeJdbcDao(Connection con) { + this.con = con; + } + + public void createTable() throws SQLException { + String createQuery = "CREATE TABLE employees(id long primary key, firstName varchar(50))"; + PreparedStatement pstmt = con.prepareStatement(createQuery); + + pstmt.execute(); + } + + public void add(Employee emp) throws SQLException { + String insertQuery = "INSERT INTO employees(id, firstName) VALUES(?,?)"; + PreparedStatement pstmt = con.prepareStatement(insertQuery); + pstmt.setLong(1, emp.getId()); + pstmt.setString(2, emp.getFirstName()); + + pstmt.executeUpdate(); + + } + + public List findAll() throws SQLException { + List employees = new ArrayList<>(); + String query = "SELECT * FROM employees"; + PreparedStatement pstmt = con.prepareStatement(query); + + ResultSet rs = pstmt.executeQuery(); + while (rs.next()) { + Employee emp = new Employee(rs.getLong("id"), rs.getString("firstName")); + employees.add(emp); + } + + return employees; + } +} \ No newline at end of file diff --git a/junit5/src/test/java/com/baeldung/helpers/JdbcConnectionUtil.java b/junit5/src/test/java/com/baeldung/helpers/JdbcConnectionUtil.java new file mode 100644 index 0000000000..f380f9674c --- /dev/null +++ b/junit5/src/test/java/com/baeldung/helpers/JdbcConnectionUtil.java @@ -0,0 +1,32 @@ +package com.baeldung.helpers; + +import java.io.IOException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.util.Properties; + +public class JdbcConnectionUtil { + + private static Connection con; + + public static Connection getConnection() { + if (con == null) { + try { + Properties props = new Properties(); + props.load(JdbcConnectionUtil.class.getResourceAsStream("jdbc.properties")); + Class.forName(props.getProperty("jdbc.driver")); + con = DriverManager.getConnection(props.getProperty("jdbc.url"), props.getProperty("jdbc.user"), props.getProperty("jdbc.password")); + return con; + } catch (IOException exc) { + exc.printStackTrace(); + } catch (ClassNotFoundException exc) { + exc.printStackTrace(); + } catch (SQLException exc) { + exc.printStackTrace(); + } + return null; + } + return con; + } +} diff --git a/junit5/src/test/java/com/baeldung/migration/junit5/extensions/TraceUnitExtension.java b/junit5/src/test/java/com/baeldung/migration/junit5/extensions/TraceUnitExtension.java index 104d311bc0..db5d3e2573 100644 --- a/junit5/src/test/java/com/baeldung/migration/junit5/extensions/TraceUnitExtension.java +++ b/junit5/src/test/java/com/baeldung/migration/junit5/extensions/TraceUnitExtension.java @@ -2,17 +2,17 @@ package com.baeldung.migration.junit5.extensions; import org.junit.jupiter.api.extension.AfterEachCallback; import org.junit.jupiter.api.extension.BeforeEachCallback; -import org.junit.jupiter.api.extension.TestExtensionContext; +import org.junit.jupiter.api.extension.ExtensionContext; public class TraceUnitExtension implements AfterEachCallback, BeforeEachCallback { @Override - public void beforeEach(TestExtensionContext context) throws Exception { + public void beforeEach(ExtensionContext context) throws Exception { System.out.println("Starting test ... " + context.getDisplayName()); } @Override - public void afterEach(TestExtensionContext context) throws Exception { + public void afterEach(ExtensionContext context) throws Exception { System.out.println("... test finished. " + context.getDisplayName()); } diff --git a/junit5/src/test/java/com/baeldung/suites/AllTests.java b/junit5/src/test/java/com/baeldung/suites/AllTests.java index 24af1e733b..69f28373eb 100644 --- a/junit5/src/test/java/com/baeldung/suites/AllTests.java +++ b/junit5/src/test/java/com/baeldung/suites/AllTests.java @@ -1,7 +1,11 @@ package com.baeldung.suites; -//@RunWith(JUnitPlatform.class) -//@SelectPackages("com.baeldung") +import org.junit.platform.runner.JUnitPlatform; +import org.junit.platform.suite.api.SelectPackages; +import org.junit.runner.RunWith; + +@RunWith(JUnitPlatform.class) +@SelectPackages("com.baeldung") //@SelectClasses({AssertionTest.class, AssumptionTest.class, ExceptionTest.class}) public class AllTests { diff --git a/junit5/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension b/junit5/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension new file mode 100644 index 0000000000..6bd0136b96 --- /dev/null +++ b/junit5/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension @@ -0,0 +1 @@ +com.baeldung.extensions.EmployeeDaoParameterResolver \ No newline at end of file diff --git a/junit5/src/test/resources/com/baeldung/extensions/application.properties b/junit5/src/test/resources/com/baeldung/extensions/application.properties new file mode 100644 index 0000000000..601f964ff3 --- /dev/null +++ b/junit5/src/test/resources/com/baeldung/extensions/application.properties @@ -0,0 +1 @@ +env=dev \ No newline at end of file diff --git a/junit5/src/test/resources/com/baeldung/helpers/jdbc.properties b/junit5/src/test/resources/com/baeldung/helpers/jdbc.properties new file mode 100644 index 0000000000..8783ea2375 --- /dev/null +++ b/junit5/src/test/resources/com/baeldung/helpers/jdbc.properties @@ -0,0 +1,5 @@ +#h2 db +jdbc.driver=org.h2.Driver +jdbc.url=jdbc:h2:mem:myDb;DB_CLOSE_DELAY=-1 +jdbc.user=sa +jdbc.password= \ No newline at end of file From 5767ff183237dbf593d0e80e4e831cc721c54672 Mon Sep 17 00:00:00 2001 From: KevinGilmore Date: Tue, 11 Jul 2017 08:08:44 -0500 Subject: [PATCH 20/89] BAEL-509 README (#2250) * BAEL-886: Updated README * BAEL-917 Testing with Google Truth Updated README * BAEL-936: adding akka-streams module to parent * BAEL-936: Update README * BAEL-918: Update README * BAEL-980: Update README * BAEL-967: Update README * BAEL-509: Using @GetMapping instead of @RequestMapping with method=GET * BAEL-1005: Update README * BAEL-509: Security and WebSockets (README) --- spring-security-mvc-socket/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-security-mvc-socket/README.md b/spring-security-mvc-socket/README.md index 2144765a04..5ae9d4f4cd 100644 --- a/spring-security-mvc-socket/README.md +++ b/spring-security-mvc-socket/README.md @@ -1,2 +1,2 @@ ### Relevant Articles: -- [Intro to Security and WebSockets](http://www.baeldung.com/intro-to-security-and-websockets) \ No newline at end of file +- [Intro to Security and WebSockets](http://www.baeldung.com/spring-security-websockets) From de93039d4a9472a287cfbe33f51b5927147d9972 Mon Sep 17 00:00:00 2001 From: slavisa-baeldung Date: Tue, 11 Jul 2017 15:49:57 +0100 Subject: [PATCH 21/89] BAEL-964 - removing assertion from print formatted map --- .../java/com/baeldung/commons/collections/MapUtilsTest.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libraries/src/test/java/com/baeldung/commons/collections/MapUtilsTest.java b/libraries/src/test/java/com/baeldung/commons/collections/MapUtilsTest.java index 4954f2574a..84ca2d1281 100644 --- a/libraries/src/test/java/com/baeldung/commons/collections/MapUtilsTest.java +++ b/libraries/src/test/java/com/baeldung/commons/collections/MapUtilsTest.java @@ -71,12 +71,9 @@ public class MapUtilsTest { outPrint.println(" GREEN = #00FF00"); outPrint.println("}"); - String expectedOut = out.toString(); - - out.reset(); + out.reset(); MapUtils.verbosePrint(outPrint, "Optional Label", this.colorMap); - assertEquals(expectedOut, out.toString()); } @Test From 84956990b647400c872a8dccf074c3721587a974 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Wed, 12 Jul 2017 19:28:47 +0200 Subject: [PATCH 22/89] Build optimization (#2253) --- .../awaitility/AsyncServiceUnitTest.java | 1 - .../proxy/BeanGeneratorIntegrationTest.java | 8 +-- .../baeldung/cglib/proxy/MixinUnitTest.java | 10 ++- .../commons/collections/BidiMapUnitTest.java | 10 +-- .../collections/CollectionUtilsGuideTest.java | 35 ++++----- .../commons/collections/MapUtilsTest.java | 72 ++++++++++--------- .../commons/collections/SetUtilsUnitTest.java | 29 ++++---- .../orderedmap/OrderedMapUnitTest.java | 10 +-- .../commons/dbutils/DbUtilsUnitTest.java | 39 +++++----- .../commons/lang3/StringUtilsUnitTest.java | 3 +- ...Test.java => HikariCPIntegrationTest.java} | 2 +- .../java/com/baeldung/hll/HLLUnitTest.java | 18 ++--- .../com/baeldung/jasypt/JasyptUnitTest.java | 11 +-- .../jdo/GuideToJDOIntegrationTest.java | 1 - .../PactConsumerDrivenContractUnitTest.java | 56 ++++++++------- .../java/com/baeldung/text/WordUtilsTest.java | 4 +- .../com/baeldung/vaadin/VaadinUITests.java | 34 ++++----- .../org/baeldung/boot/boottest/JsonUtil.java | 4 +- spring-mvc-java/pom.xml | 1 - 19 files changed, 178 insertions(+), 170 deletions(-) rename libraries/src/test/java/com/baeldung/hikaricp/{HikariCPUnitTest.java => HikariCPIntegrationTest.java} (88%) diff --git a/libraries/src/test/java/com/baeldung/awaitility/AsyncServiceUnitTest.java b/libraries/src/test/java/com/baeldung/awaitility/AsyncServiceUnitTest.java index 677d989fba..43537965f8 100644 --- a/libraries/src/test/java/com/baeldung/awaitility/AsyncServiceUnitTest.java +++ b/libraries/src/test/java/com/baeldung/awaitility/AsyncServiceUnitTest.java @@ -3,7 +3,6 @@ package com.baeldung.awaitility; import org.awaitility.Awaitility; import org.awaitility.Duration; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import java.util.concurrent.Callable; diff --git a/libraries/src/test/java/com/baeldung/cglib/proxy/BeanGeneratorIntegrationTest.java b/libraries/src/test/java/com/baeldung/cglib/proxy/BeanGeneratorIntegrationTest.java index 033cc47c74..1224d73724 100644 --- a/libraries/src/test/java/com/baeldung/cglib/proxy/BeanGeneratorIntegrationTest.java +++ b/libraries/src/test/java/com/baeldung/cglib/proxy/BeanGeneratorIntegrationTest.java @@ -19,14 +19,14 @@ public class BeanGeneratorIntegrationTest { beanGenerator.addProperty("name", String.class); Object myBean = beanGenerator.create(); Method setter = myBean - .getClass() - .getMethod("setName", String.class); + .getClass() + .getMethod("setName", String.class); setter.invoke(myBean, "some string value set by a cglib"); //then Method getter = myBean - .getClass() - .getMethod("getName"); + .getClass() + .getMethod("getName"); assertEquals("some string value set by a cglib", getter.invoke(myBean)); } } diff --git a/libraries/src/test/java/com/baeldung/cglib/proxy/MixinUnitTest.java b/libraries/src/test/java/com/baeldung/cglib/proxy/MixinUnitTest.java index a89d9fe2c3..93b34bf92b 100644 --- a/libraries/src/test/java/com/baeldung/cglib/proxy/MixinUnitTest.java +++ b/libraries/src/test/java/com/baeldung/cglib/proxy/MixinUnitTest.java @@ -1,6 +1,10 @@ package com.baeldung.cglib.proxy; -import com.baeldung.cglib.mixin.*; +import com.baeldung.cglib.mixin.Class1; +import com.baeldung.cglib.mixin.Class2; +import com.baeldung.cglib.mixin.Interface1; +import com.baeldung.cglib.mixin.Interface2; +import com.baeldung.cglib.mixin.MixinInterface; import net.sf.cglib.proxy.Mixin; import org.junit.Test; @@ -12,8 +16,8 @@ public class MixinUnitTest { public void givenTwoClasses_whenMixedIntoOne_thenMixinShouldHaveMethodsFromBothClasses() throws Exception { //when Mixin mixin = Mixin.create( - new Class[]{Interface1.class, Interface2.class, MixinInterface.class}, - new Object[]{new Class1(), new Class2()} + new Class[]{Interface1.class, Interface2.class, MixinInterface.class}, + new Object[]{new Class1(), new Class2()} ); MixinInterface mixinDelegate = (MixinInterface) mixin; diff --git a/libraries/src/test/java/com/baeldung/commons/collections/BidiMapUnitTest.java b/libraries/src/test/java/com/baeldung/commons/collections/BidiMapUnitTest.java index 64a3932fb3..e46d8654a2 100644 --- a/libraries/src/test/java/com/baeldung/commons/collections/BidiMapUnitTest.java +++ b/libraries/src/test/java/com/baeldung/commons/collections/BidiMapUnitTest.java @@ -2,16 +2,12 @@ package com.baeldung.commons.collections; import org.apache.commons.collections4.BidiMap; import org.apache.commons.collections4.bidimap.DualHashBidiMap; -import org.apache.commons.collections4.bidimap.DualLinkedHashBidiMap; -import org.apache.commons.collections4.bidimap.DualTreeBidiMap; -import org.apache.commons.collections4.bidimap.TreeBidiMap; import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; -/** - * Created by smatt on 03/07/2017. - */ public class BidiMapUnitTest { @Test diff --git a/libraries/src/test/java/com/baeldung/commons/collections/CollectionUtilsGuideTest.java b/libraries/src/test/java/com/baeldung/commons/collections/CollectionUtilsGuideTest.java index 90e30b01dc..aa8b799c9d 100644 --- a/libraries/src/test/java/com/baeldung/commons/collections/CollectionUtilsGuideTest.java +++ b/libraries/src/test/java/com/baeldung/commons/collections/CollectionUtilsGuideTest.java @@ -3,14 +3,17 @@ package com.baeldung.commons.collections; import com.baeldung.commons.collectionutil.Address; import com.baeldung.commons.collectionutil.Customer; -import org.apache.commons.collections4.Closure; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.Predicate; import org.apache.commons.collections4.Transformer; import org.junit.Before; import org.junit.Test; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -36,13 +39,13 @@ public class CollectionUtilsGuideTest { linkedList1 = new LinkedList<>(list1); } - + @Test public void givenList_whenAddIgnoreNull_thenNoNullAdded() { CollectionUtils.addIgnoreNull(list1, null); assertFalse(list1.contains(null)); } - + @Test public void givenTwoSortedLists_whenCollated_thenSorted() { List sortedList = CollectionUtils.collate(list1, list2); @@ -51,7 +54,7 @@ public class CollectionUtilsGuideTest { assertTrue(sortedList.get(0).getName().equals("Bob")); assertTrue(sortedList.get(2).getName().equals("Daniel")); } - + @Test public void givenListOfCustomers_whenTransformed_thenListOfAddress() { Collection
addressCol = CollectionUtils.collect(list1, new Transformer() { @@ -59,61 +62,61 @@ public class CollectionUtilsGuideTest { return new Address(customer.getLocality(), customer.getCity(), customer.getZip()); } }); - + List
addressList = new ArrayList<>(addressCol); assertTrue(addressList.size() == 3); assertTrue(addressList.get(0).getLocality().equals("locality1")); } - + @Test public void givenCustomerList_whenFiltered_thenCorrectSize() { boolean isModified = CollectionUtils.filter(linkedList1, new Predicate() { public boolean evaluate(Customer customer) { - return Arrays.asList("Daniel","Kyle").contains(customer.getName()); + return Arrays.asList("Daniel", "Kyle").contains(customer.getName()); } }); //filterInverse does the opposite. It removes the element from the list if the Predicate returns true //select and selectRejected work the same way except that they do not remove elements from the given collection and return a new collection - + assertTrue(isModified && linkedList1.size() == 2); } - + @Test public void givenNonEmptyList_whenCheckedIsNotEmpty_thenTrue() { List emptyList = new ArrayList<>(); List nullList = null; - + //Very handy at times where we want to check if a collection is not null and not empty too. //isNotEmpty does the opposite. Handy because using ! operator on isEmpty makes it missable while reading assertTrue(CollectionUtils.isNotEmpty(list1)); assertTrue(CollectionUtils.isEmpty(nullList)); assertTrue(CollectionUtils.isEmpty(emptyList)); } - + @Test public void givenCustomerListAndASubcollection_whenChecked_thenTrue() { assertTrue(CollectionUtils.isSubCollection(list3, list1)); } - + @Test public void givenTwoLists_whenIntersected_thenCheckSize() { Collection intersection = CollectionUtils.intersection(list1, list3); assertTrue(intersection.size() == 2); } - + @Test public void givenTwoLists_whenSubtracted_thenCheckElementNotPresentInA() { Collection result = CollectionUtils.subtract(list1, list3); assertFalse(result.contains(customer1)); } - + @Test public void givenTwoLists_whenUnioned_thenCheckElementPresentInResult() { Collection union = CollectionUtils.union(list1, list2); assertTrue(union.contains(customer1)); assertTrue(union.contains(customer4)); } - + } \ No newline at end of file diff --git a/libraries/src/test/java/com/baeldung/commons/collections/MapUtilsTest.java b/libraries/src/test/java/com/baeldung/commons/collections/MapUtilsTest.java index 84ca2d1281..470eb46cb0 100644 --- a/libraries/src/test/java/com/baeldung/commons/collections/MapUtilsTest.java +++ b/libraries/src/test/java/com/baeldung/commons/collections/MapUtilsTest.java @@ -16,33 +16,35 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.collection.IsMapContaining.hasEntry; import static org.hamcrest.collection.IsMapWithSize.aMapWithSize; import static org.hamcrest.collection.IsMapWithSize.anEmptyMap; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; public class MapUtilsTest { - private String[][] color2DArray = new String[][] { - {"RED", "#FF0000"}, - {"GREEN", "#00FF00"}, - {"BLUE", "#0000FF"} + private String[][] color2DArray = new String[][]{ + {"RED", "#FF0000"}, + {"GREEN", "#00FF00"}, + {"BLUE", "#0000FF"} }; - private String[] color1DArray = new String[] { - "RED", "#FF0000", - "GREEN", "#00FF00", - "BLUE", "#0000FF" + private String[] color1DArray = new String[]{ + "RED", "#FF0000", + "GREEN", "#00FF00", + "BLUE", "#0000FF" }; private Map colorMap; - + @Before public void createMap() { this.colorMap = MapUtils.putAll(new HashMap(), this.color2DArray); } - + @Test public void whenCreateMapFrom2DArray_theMapIsCreated() { this.colorMap = MapUtils.putAll(new HashMap(), this.color2DArray); assertThat(this.colorMap, is(aMapWithSize(this.color2DArray.length))); - + assertThat(this.colorMap, hasEntry("RED", "#FF0000")); assertThat(this.colorMap, hasEntry("GREEN", "#00FF00")); assertThat(this.colorMap, hasEntry("BLUE", "#0000FF")); @@ -51,26 +53,26 @@ public class MapUtilsTest { @Test public void whenCreateMapFrom1DArray_theMapIsCreated() { this.colorMap = MapUtils.putAll(new HashMap(), this.color1DArray); - + assertThat(this.colorMap, is(aMapWithSize(this.color1DArray.length / 2))); assertThat(this.colorMap, hasEntry("RED", "#FF0000")); assertThat(this.colorMap, hasEntry("GREEN", "#00FF00")); assertThat(this.colorMap, hasEntry("BLUE", "#0000FF")); } - + @Test public void whenVerbosePrintMap_thenMustPrintFormattedMap() { ByteArrayOutputStream out = new ByteArrayOutputStream(); PrintStream outPrint = new PrintStream(out); - + outPrint.println("Optional Label = "); outPrint.println("{"); outPrint.println(" RED = #FF0000"); outPrint.println(" BLUE = #0000FF"); outPrint.println(" GREEN = #00FF00"); outPrint.println("}"); - + out.reset(); MapUtils.verbosePrint(outPrint, "Optional Label", this.colorMap); @@ -80,15 +82,15 @@ public class MapUtilsTest { public void whenGetKeyNotPresent_thenMustReturnDefaultValue() { String defaultColorStr = "COLOR_NOT_FOUND"; String color = MapUtils.getString(this.colorMap, "BLACK", defaultColorStr); - + assertEquals(color, defaultColorStr); } - + @Test public void whenGetOnNullMap_thenMustReturnDefaultValue() { String defaultColorStr = "COLOR_NOT_FOUND"; String color = MapUtils.getString(null, "RED", defaultColorStr); - + assertEquals(color, defaultColorStr); } @@ -96,49 +98,49 @@ public class MapUtilsTest { public void whenInvertMap_thenMustReturnInvertedMap() { Map invColorMap = MapUtils.invertMap(this.colorMap); assertEquals(this.colorMap.size(), invColorMap.size()); - - MapIterator itColorMap + + MapIterator itColorMap = MapUtils.iterableMap(this.colorMap).mapIterator(); - + while (itColorMap.hasNext()) { String colorMapKey = itColorMap.next(); String colorMapValue = itColorMap.getValue(); String invColorMapValue = MapUtils.getString(invColorMap, colorMapValue); - + assertTrue(invColorMapValue.equals(colorMapKey)); } } - + @Test(expected = IllegalArgumentException.class) public void whenCreateFixedSizedMapAndAdd_thenMustThrowException() { Map rgbMap = MapUtils.fixedSizeMap(MapUtils.putAll( - new HashMap(), - this.color1DArray)); - + new HashMap(), + this.color1DArray)); + rgbMap.put("ORANGE", "#FFA500"); } - + @Test(expected = IllegalArgumentException.class) public void whenAddDuplicateToUniqueValuesPredicateMap_thenMustThrowException() { - Map uniqValuesMap + Map uniqValuesMap = MapUtils.predicatedMap(this.colorMap, null, PredicateUtils.uniquePredicate()); - + uniqValuesMap.put("NEW_RED", "#FF0000"); } @Test public void whenCreateLazyMap_theMapIsCreated() { Map intStrMap = MapUtils.lazyMap( - new HashMap(), - TransformerUtils.stringValueTransformer()); - + new HashMap(), + TransformerUtils.stringValueTransformer()); + assertThat(intStrMap, is(anEmptyMap())); - + intStrMap.get(1); intStrMap.get(2); intStrMap.get(3); - + assertThat(intStrMap, is(aMapWithSize(3))); } } diff --git a/libraries/src/test/java/com/baeldung/commons/collections/SetUtilsUnitTest.java b/libraries/src/test/java/com/baeldung/commons/collections/SetUtilsUnitTest.java index 4d264e3aea..7d214bc5c5 100644 --- a/libraries/src/test/java/com/baeldung/commons/collections/SetUtilsUnitTest.java +++ b/libraries/src/test/java/com/baeldung/commons/collections/SetUtilsUnitTest.java @@ -11,9 +11,6 @@ import java.util.Set; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -/** - * Created by smatt on 21/06/2017. - */ public class SetUtilsUnitTest { @Test(expected = IllegalArgumentException.class) @@ -27,33 +24,33 @@ public class SetUtilsUnitTest { @Test public void givenTwoSets_whenDifference_thenSetView() { - Set a = new HashSet<>(Arrays.asList(1,2,5)); - Set b = new HashSet<>(Arrays.asList(1,2)); + Set a = new HashSet<>(Arrays.asList(1, 2, 5)); + Set b = new HashSet<>(Arrays.asList(1, 2)); SetUtils.SetView result = SetUtils.difference(a, b); assertTrue(result.size() == 1 && result.contains(5)); } @Test public void givenTwoSets_whenUnion_thenUnionResult() { - Set a = new HashSet<>(Arrays.asList(1,2,5)); - Set b = new HashSet<>(Arrays.asList(1,2)); - Set expected = new HashSet<>(Arrays.asList(1,2,5)); + Set a = new HashSet<>(Arrays.asList(1, 2, 5)); + Set b = new HashSet<>(Arrays.asList(1, 2)); + Set expected = new HashSet<>(Arrays.asList(1, 2, 5)); SetUtils.SetView union = SetUtils.union(a, b); assertTrue(SetUtils.isEqualSet(expected, union)); } @Test public void givenTwoSets_whenIntersection_thenIntersectionResult() { - Set a = new HashSet<>(Arrays.asList(1,2,5)); - Set b = new HashSet<>(Arrays.asList(1,2)); - Set expected = new HashSet<>(Arrays.asList(1,2)); + Set a = new HashSet<>(Arrays.asList(1, 2, 5)); + Set b = new HashSet<>(Arrays.asList(1, 2)); + Set expected = new HashSet<>(Arrays.asList(1, 2)); SetUtils.SetView intersect = SetUtils.intersection(a, b); assertTrue(SetUtils.isEqualSet(expected, intersect)); } @Test public void givenSet_whenTransformedSet_thenTransformedResult() { - Set a = SetUtils.transformedSet(new HashSet<>(), (e) -> e * 2 ); + Set a = SetUtils.transformedSet(new HashSet<>(), (e) -> e * 2); a.add(2); assertEquals(a.toArray()[0], 4); @@ -65,19 +62,19 @@ public class SetUtilsUnitTest { @Test public void givenTwoSet_whenDisjunction_thenDisjunctionSet() { - Set a = new HashSet<>(Arrays.asList(1,2,5)); - Set b = new HashSet<>(Arrays.asList(1,2,3)); + Set a = new HashSet<>(Arrays.asList(1, 2, 5)); + Set b = new HashSet<>(Arrays.asList(1, 2, 3)); SetUtils.SetView result = SetUtils.disjunction(a, b); assertTrue(result.toSet().contains(5) && result.toSet().contains(3)); } @Test public void givenSet_when_OrderedSet_thenMaintainElementOrder() { - Set set = new HashSet<>(Arrays.asList(10,1,5)); + Set set = new HashSet<>(Arrays.asList(10, 1, 5)); System.out.println("unordered set: " + set); Set orderedSet = SetUtils.orderedSet(new HashSet<>()); - orderedSet.addAll(Arrays.asList(10,1,5)); + orderedSet.addAll(Arrays.asList(10, 1, 5)); System.out.println("ordered set = " + orderedSet); } } \ No newline at end of file diff --git a/libraries/src/test/java/com/baeldung/commons/collections/orderedmap/OrderedMapUnitTest.java b/libraries/src/test/java/com/baeldung/commons/collections/orderedmap/OrderedMapUnitTest.java index 6b2777c289..7a05228e51 100644 --- a/libraries/src/test/java/com/baeldung/commons/collections/orderedmap/OrderedMapUnitTest.java +++ b/libraries/src/test/java/com/baeldung/commons/collections/orderedmap/OrderedMapUnitTest.java @@ -1,10 +1,5 @@ package com.baeldung.commons.collections.orderedmap; -import static org.junit.Assert.assertEquals; - -import java.util.ArrayList; -import java.util.List; - import org.apache.commons.collections4.OrderedMap; import org.apache.commons.collections4.OrderedMapIterator; import org.apache.commons.collections4.map.LinkedMap; @@ -12,6 +7,11 @@ import org.apache.commons.collections4.map.ListOrderedMap; import org.junit.Before; import org.junit.Test; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertEquals; + public class OrderedMapUnitTest { private String[] names = {"Emily", "Mathew", "Rose", "John", "Anna"}; diff --git a/libraries/src/test/java/com/baeldung/commons/dbutils/DbUtilsUnitTest.java b/libraries/src/test/java/com/baeldung/commons/dbutils/DbUtilsUnitTest.java index 8eb2fd1350..bc7623589c 100644 --- a/libraries/src/test/java/com/baeldung/commons/dbutils/DbUtilsUnitTest.java +++ b/libraries/src/test/java/com/baeldung/commons/dbutils/DbUtilsUnitTest.java @@ -1,5 +1,15 @@ package com.baeldung.commons.dbutils; +import org.apache.commons.dbutils.AsyncQueryRunner; +import org.apache.commons.dbutils.DbUtils; +import org.apache.commons.dbutils.QueryRunner; +import org.apache.commons.dbutils.handlers.BeanListHandler; +import org.apache.commons.dbutils.handlers.MapListHandler; +import org.apache.commons.dbutils.handlers.ScalarHandler; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; @@ -9,16 +19,9 @@ import java.util.Map; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; -import org.apache.commons.dbutils.AsyncQueryRunner; -import org.apache.commons.dbutils.DbUtils; -import org.apache.commons.dbutils.QueryRunner; -import org.apache.commons.dbutils.handlers.BeanListHandler; -import org.apache.commons.dbutils.handlers.MapListHandler; -import org.apache.commons.dbutils.handlers.ScalarHandler; -import org.junit.After; -import static org.junit.Assert.*; -import org.junit.Before; -import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; public class DbUtilsUnitTest { @@ -45,9 +48,9 @@ public class DbUtilsUnitTest { assertEquals(list.size(), 5); assertEquals(list.get(0) - .get("firstname"), "John"); + .get("firstname"), "John"); assertEquals(list.get(4) - .get("firstname"), "Christian"); + .get("firstname"), "Christian"); } @Test @@ -59,9 +62,9 @@ public class DbUtilsUnitTest { assertEquals(employeeList.size(), 5); assertEquals(employeeList.get(0) - .getFirstName(), "John"); + .getFirstName(), "John"); assertEquals(employeeList.get(4) - .getFirstName(), "Christian"); + .getFirstName(), "Christian"); } @Test @@ -83,11 +86,11 @@ public class DbUtilsUnitTest { List employees = runner.query(connection, "SELECT * FROM employee", employeeHandler); assertEquals(employees.get(0) - .getEmails() - .size(), 2); + .getEmails() + .size(), 2); assertEquals(employees.get(2) - .getEmails() - .size(), 3); + .getEmails() + .size(), 3); assertNotNull(employees.get(0).getEmails().get(0).getEmployeeId()); } diff --git a/libraries/src/test/java/com/baeldung/commons/lang3/StringUtilsUnitTest.java b/libraries/src/test/java/com/baeldung/commons/lang3/StringUtilsUnitTest.java index 15620455aa..191387d088 100644 --- a/libraries/src/test/java/com/baeldung/commons/lang3/StringUtilsUnitTest.java +++ b/libraries/src/test/java/com/baeldung/commons/lang3/StringUtilsUnitTest.java @@ -2,9 +2,10 @@ package com.baeldung.commons.lang3; import org.apache.commons.lang3.StringUtils; import org.junit.Test; + import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class StringUtilsUnitTest { @Test diff --git a/libraries/src/test/java/com/baeldung/hikaricp/HikariCPUnitTest.java b/libraries/src/test/java/com/baeldung/hikaricp/HikariCPIntegrationTest.java similarity index 88% rename from libraries/src/test/java/com/baeldung/hikaricp/HikariCPUnitTest.java rename to libraries/src/test/java/com/baeldung/hikaricp/HikariCPIntegrationTest.java index 1a1c5ef868..80588ecc03 100644 --- a/libraries/src/test/java/com/baeldung/hikaricp/HikariCPUnitTest.java +++ b/libraries/src/test/java/com/baeldung/hikaricp/HikariCPIntegrationTest.java @@ -6,7 +6,7 @@ import java.util.List; import static org.junit.Assert.assertEquals; -public class HikariCPUnitTest { +public class HikariCPIntegrationTest { @Test public void givenConnection_thenFetchDbData() { diff --git a/libraries/src/test/java/com/baeldung/hll/HLLUnitTest.java b/libraries/src/test/java/com/baeldung/hll/HLLUnitTest.java index 1d318b7e4e..42af5d0f0b 100644 --- a/libraries/src/test/java/com/baeldung/hll/HLLUnitTest.java +++ b/libraries/src/test/java/com/baeldung/hll/HLLUnitTest.java @@ -22,9 +22,9 @@ public class HLLUnitTest { //when LongStream.range(0, numberOfElements).forEach(element -> { - long hashedValue = hashFunction.newHasher().putLong(element).hash().asLong(); - hll.addRaw(hashedValue); - } + long hashedValue = hashFunction.newHasher().putLong(element).hash().asLong(); + hll.addRaw(hashedValue); + } ); //then @@ -43,15 +43,15 @@ public class HLLUnitTest { //when LongStream.range(0, numberOfElements).forEach(element -> { - long hashedValue = hashFunction.newHasher().putLong(element).hash().asLong(); - firstHll.addRaw(hashedValue); - } + long hashedValue = hashFunction.newHasher().putLong(element).hash().asLong(); + firstHll.addRaw(hashedValue); + } ); LongStream.range(numberOfElements, numberOfElements * 2).forEach(element -> { - long hashedValue = hashFunction.newHasher().putLong(element).hash().asLong(); - secondHLL.addRaw(hashedValue); - } + long hashedValue = hashFunction.newHasher().putLong(element).hash().asLong(); + secondHLL.addRaw(hashedValue); + } ); //then diff --git a/libraries/src/test/java/com/baeldung/jasypt/JasyptUnitTest.java b/libraries/src/test/java/com/baeldung/jasypt/JasyptUnitTest.java index 39d54085e2..5e65c585aa 100644 --- a/libraries/src/test/java/com/baeldung/jasypt/JasyptUnitTest.java +++ b/libraries/src/test/java/com/baeldung/jasypt/JasyptUnitTest.java @@ -8,7 +8,9 @@ import org.jasypt.util.text.BasicTextEncryptor; import org.junit.Ignore; import org.junit.Test; -import static junit.framework.Assert.*; +import static junit.framework.Assert.assertFalse; +import static junit.framework.Assert.assertNotSame; +import static junit.framework.Assert.assertTrue; import static junit.framework.TestCase.assertEquals; public class JasyptUnitTest { @@ -30,7 +32,7 @@ public class JasyptUnitTest { } @Test - public void givenTextPassword_whenOneWayEncryption_thenCompareEncryptedPasswordsShouldBeSame(){ + public void givenTextPassword_whenOneWayEncryption_thenCompareEncryptedPasswordsShouldBeSame() { String password = "secret-pass"; BasicPasswordEncryptor passwordEncryptor = new BasicPasswordEncryptor(); String encryptedPassword = passwordEncryptor.encryptPassword(password); @@ -43,7 +45,7 @@ public class JasyptUnitTest { } @Test - public void givenTextPassword_whenOneWayEncryption_thenCompareEncryptedPasswordsShouldNotBeSame(){ + public void givenTextPassword_whenOneWayEncryption_thenCompareEncryptedPasswordsShouldNotBeSame() { String password = "secret-pass"; BasicPasswordEncryptor passwordEncryptor = new BasicPasswordEncryptor(); String encryptedPassword = passwordEncryptor.encryptPassword(password); @@ -56,7 +58,6 @@ public class JasyptUnitTest { } - @Test @Ignore("should have installed local_policy.jar") public void givenTextPrivateData_whenDecrypt_thenCompareToEncryptedWithCustomAlgorithm() { @@ -77,7 +78,7 @@ public class JasyptUnitTest { @Test @Ignore("should have installed local_policy.jar") - public void givenTextPrivateData_whenDecryptOnHighPerformance_thenDecrypt(){ + public void givenTextPrivateData_whenDecryptOnHighPerformance_thenDecrypt() { //given String privateData = "secret-data"; PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor(); diff --git a/libraries/src/test/java/com/baeldung/jdo/GuideToJDOIntegrationTest.java b/libraries/src/test/java/com/baeldung/jdo/GuideToJDOIntegrationTest.java index 578f9ff902..e916a229f7 100644 --- a/libraries/src/test/java/com/baeldung/jdo/GuideToJDOIntegrationTest.java +++ b/libraries/src/test/java/com/baeldung/jdo/GuideToJDOIntegrationTest.java @@ -8,7 +8,6 @@ import javax.jdo.PersistenceManager; import javax.jdo.PersistenceManagerFactory; import javax.jdo.Query; import javax.jdo.Transaction; -import java.util.Iterator; import java.util.List; import static org.junit.Assert.assertEquals; diff --git a/libraries/src/test/java/com/baeldung/pact/PactConsumerDrivenContractUnitTest.java b/libraries/src/test/java/com/baeldung/pact/PactConsumerDrivenContractUnitTest.java index 2952938cd9..b152b22964 100644 --- a/libraries/src/test/java/com/baeldung/pact/PactConsumerDrivenContractUnitTest.java +++ b/libraries/src/test/java/com/baeldung/pact/PactConsumerDrivenContractUnitTest.java @@ -8,7 +8,11 @@ import au.com.dius.pact.consumer.dsl.PactDslWithProvider; import au.com.dius.pact.model.RequestResponsePact; import org.junit.Rule; import org.junit.Test; -import org.springframework.http.*; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.web.client.RestTemplate; import java.util.HashMap; @@ -20,7 +24,7 @@ public class PactConsumerDrivenContractUnitTest { @Rule public PactProviderRuleMk2 mockProvider - = new PactProviderRuleMk2("test_provider", "localhost", 8080, this); + = new PactProviderRuleMk2("test_provider", "localhost", 8080, this); @Pact(consumer = "test_consumer") public RequestResponsePact createPact(PactDslWithProvider builder) { @@ -28,25 +32,25 @@ public class PactConsumerDrivenContractUnitTest { headers.put("Content-Type", "application/json"); return builder - .given("test GET ") - .uponReceiving("GET REQUEST") - .path("/") - .method("GET") - .willRespondWith() - .status(200) - .headers(headers) - .body("{\"condition\": true, \"name\": \"tom\"}") - .given("test POST") - .uponReceiving("POST REQUEST") - .method("POST") - .headers(headers) - .body("{\"name\": \"Michael\"}") - .path("/create") - .willRespondWith() - .status(201) - .headers(headers) - .body("") - .toPact(); + .given("test GET ") + .uponReceiving("GET REQUEST") + .path("/") + .method("GET") + .willRespondWith() + .status(200) + .headers(headers) + .body("{\"condition\": true, \"name\": \"tom\"}") + .given("test POST") + .uponReceiving("POST REQUEST") + .method("POST") + .headers(headers) + .body("{\"name\": \"Michael\"}") + .path("/create") + .willRespondWith() + .status(201) + .headers(headers) + .body("") + .toPact(); } @@ -55,7 +59,7 @@ public class PactConsumerDrivenContractUnitTest { public void givenGet_whenSendRequest_shouldReturn200WithProperHeaderAndBody() { //when ResponseEntity response - = new RestTemplate().getForEntity(mockProvider.getUrl(), String.class); + = new RestTemplate().getForEntity(mockProvider.getUrl(), String.class); //then assertThat(response.getStatusCode().value()).isEqualTo(200); @@ -69,10 +73,10 @@ public class PactConsumerDrivenContractUnitTest { //when ResponseEntity postResponse = new RestTemplate().exchange( - mockProvider.getUrl() + "/create", - HttpMethod.POST, - new HttpEntity<>(jsonBody, httpHeaders), - String.class + mockProvider.getUrl() + "/create", + HttpMethod.POST, + new HttpEntity<>(jsonBody, httpHeaders), + String.class ); //then diff --git a/libraries/src/test/java/com/baeldung/text/WordUtilsTest.java b/libraries/src/test/java/com/baeldung/text/WordUtilsTest.java index b9268d67b3..fafba2fbb5 100644 --- a/libraries/src/test/java/com/baeldung/text/WordUtilsTest.java +++ b/libraries/src/test/java/com/baeldung/text/WordUtilsTest.java @@ -13,11 +13,11 @@ public class WordUtilsTest { Assert.assertEquals("To Be Capitalized!", result); } - + @Test public void whenContainsWords_thenCorrect() { boolean containsWords = WordUtils.containsAllWords("String to search", "to", "search"); - + Assert.assertTrue(containsWords); } } diff --git a/libraries/src/test/java/com/baeldung/vaadin/VaadinUITests.java b/libraries/src/test/java/com/baeldung/vaadin/VaadinUITests.java index 1b7a35d865..228b91de34 100644 --- a/libraries/src/test/java/com/baeldung/vaadin/VaadinUITests.java +++ b/libraries/src/test/java/com/baeldung/vaadin/VaadinUITests.java @@ -1,6 +1,8 @@ package com.baeldung.vaadin; -import static org.junit.Assert.assertEquals; +import com.gargoylesoftware.htmlunit.BrowserVersion; +import com.vaadin.server.DefaultUIProvider; +import com.vaadin.server.VaadinServlet; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; @@ -15,9 +17,7 @@ import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.htmlunit.HtmlUnitDriver; -import com.gargoylesoftware.htmlunit.BrowserVersion; -import com.vaadin.server.DefaultUIProvider; -import com.vaadin.server.VaadinServlet; +import static org.junit.Assert.assertEquals; public class VaadinUITests { @@ -26,56 +26,56 @@ public class VaadinUITests { private Server server; @Before - public void setUp() throws Exception{ + public void setUp() throws Exception { startJettyServer(); - driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_45,true); + driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_45, true); driver.get("http://localhost:8080"); Thread.sleep(10000); } - - @Test - public void whenPageLoadedThenShouldSeeURL(){ + + @Test + public void whenPageLoadedThenShouldSeeURL() { String url = driver.getCurrentUrl(); assertEquals("http://localhost:8080/", url); } - + @Test public void givenLabel_WhenGetValue_ThenValueMatch() { WebElement label = driver.findElement(By.id("Label")); assertEquals("Label Value", label.getText()); } - + @Test public void givenTextField_WhenGetValue_ThenValueMatch() { WebElement textField = driver.findElement(By.id("TextField")); assertEquals("TextField Value", textField.getAttribute("Value")); } - + @Test public void givenTextArea_WhenGetValue_ThenValueMatch() { WebElement textArea = driver.findElement(By.id("TextArea")); assertEquals("TextArea Value", textArea.getAttribute("Value")); } - + @Test public void givenDateField_WhenGetValue_ThenValueMatch() { WebElement dateField = driver.findElement(By.id("DateField")); assertEquals("12/31/69", dateField.getText()); } - + @Test public void givenPasswordField_WhenGetValue_ThenValueMatch() { WebElement passwordField = driver.findElement(By.id("PasswordField")); assertEquals("password", passwordField.getAttribute("Value")); } - + @After - public void cleanUp() throws Exception{ + public void cleanUp() throws Exception { driver.close(); server.stop(); } - public void startJettyServer() throws Exception{ + public void startJettyServer() throws Exception { int maxThreads = 100; int minThreads = 10; diff --git a/spring-boot/src/test/java/org/baeldung/boot/boottest/JsonUtil.java b/spring-boot/src/test/java/org/baeldung/boot/boottest/JsonUtil.java index 3d532ce54a..8c7e5576ce 100644 --- a/spring-boot/src/test/java/org/baeldung/boot/boottest/JsonUtil.java +++ b/spring-boot/src/test/java/org/baeldung/boot/boottest/JsonUtil.java @@ -5,8 +5,8 @@ import java.io.IOException; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; -public class JsonUtil { - public static byte[] toJson(Object object) throws IOException { +class JsonUtil { + static byte[] toJson(Object object) throws IOException { ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); return mapper.writeValueAsBytes(object); diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index eb8e1455a7..b939f0496d 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -5,7 +5,6 @@ spring-mvc-java 0.1-SNAPSHOT spring-mvc-java - war com.baeldung From 78de955aac2e92ff98f2cb59381f8543e67ffc30 Mon Sep 17 00:00:00 2001 From: Syed Ali Raza Date: Thu, 13 Jul 2017 12:02:05 +0500 Subject: [PATCH 23/89] BAEL-995: resolved merge issues (#2255) --- libraries/pom.xml | 5 +++ .../chronicle/queue/ChronicleQueue.java | 23 ++++++++++ .../chronicle/queue/ChronicleQueueTest.java | 43 +++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 libraries/src/main/java/com/baeldung/chronicle/queue/ChronicleQueue.java create mode 100644 libraries/src/test/java/com/baeldung/chronicle/queue/ChronicleQueueTest.java diff --git a/libraries/pom.xml b/libraries/pom.xml index c3535f884a..231233afbb 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -331,6 +331,11 @@ datanucleus-xml 5.0.0-release + + net.openhft + chronicle + 3.6.4 + org.springframework spring-web diff --git a/libraries/src/main/java/com/baeldung/chronicle/queue/ChronicleQueue.java b/libraries/src/main/java/com/baeldung/chronicle/queue/ChronicleQueue.java new file mode 100644 index 0000000000..b7770e0b78 --- /dev/null +++ b/libraries/src/main/java/com/baeldung/chronicle/queue/ChronicleQueue.java @@ -0,0 +1,23 @@ +package com.baeldung.chronicle.queue; + +import java.io.IOException; + +import net.openhft.chronicle.Chronicle; +import net.openhft.chronicle.ExcerptAppender; + +public class ChronicleQueue { + + public static void writeToQueue( + Chronicle chronicle, String stringValue, int intValue, long longValue, double doubleValue) + throws IOException { + ExcerptAppender appender = chronicle.createAppender(); + appender.startExcerpt(); + appender.writeUTF(stringValue); + appender.writeInt(intValue); + appender.writeLong(longValue); + appender.writeDouble(doubleValue); + appender.finish(); + appender.close(); + } + +} diff --git a/libraries/src/test/java/com/baeldung/chronicle/queue/ChronicleQueueTest.java b/libraries/src/test/java/com/baeldung/chronicle/queue/ChronicleQueueTest.java new file mode 100644 index 0000000000..e64aaed544 --- /dev/null +++ b/libraries/src/test/java/com/baeldung/chronicle/queue/ChronicleQueueTest.java @@ -0,0 +1,43 @@ +package com.baeldung.chronicle.queue; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; + +import org.junit.Test; + +import net.openhft.chronicle.Chronicle; +import net.openhft.chronicle.ChronicleQueueBuilder; +import net.openhft.chronicle.ExcerptTailer; +import net.openhft.chronicle.tools.ChronicleTools; + +public class ChronicleQueueTest { + + @Test + public void givenSetOfValues_whenWriteToQueue_thenWriteSuccesfully() throws IOException { + File queueDir = Files.createTempDirectory("chronicle-queue").toFile(); + ChronicleTools.deleteOnExit(queueDir.getPath()); + + Chronicle chronicle = ChronicleQueueBuilder.indexed(queueDir).build(); + String stringVal = "Hello World"; + int intVal = 101; + long longVal = System.currentTimeMillis(); + double doubleVal = 90.00192091d; + + ChronicleQueue.writeToQueue(chronicle, stringVal, intVal, longVal, doubleVal); + + ExcerptTailer tailer = chronicle.createTailer(); + while (tailer.nextIndex()) { + assertEquals(stringVal, tailer.readUTF()); + assertEquals(intVal, tailer.readInt()); + assertEquals(longVal, tailer.readLong()); + assertEquals((Double) doubleVal, (Double) tailer.readDouble()); + } + tailer.finish(); + tailer.close(); + chronicle.close(); + } + +} From 24b14e55b7e30c17201fd56379a564bf6a4a525c Mon Sep 17 00:00:00 2001 From: ramansahasi Date: Thu, 13 Jul 2017 19:02:32 +0530 Subject: [PATCH 24/89] BAEL-787 AWS S3 with Java (#2179) * Files - S3 Bucket Creation and Object Upload S3 Bucket Creation and Object Upload Using the AWS SDK for Java. Please note. This code is not readily plug-and-play type. User needs to put his own 'access key' and 'secret key' * S3 Bucket Creation and Object Upload-dependencies S3 Bucket Creation and Object Upload - Adding Dependencies * Update S3Application.java * Update S3Application.java * Update S3Application.java * Fixed Test Names * Update S3Application.java * Added more test cases * Added more examples * Delete AWSS3Service.java * Delete S3Application.java * Added more examples * Added more test cases --- aws/pom.xml | 32 +++++ .../java/com/baeldung/s3/AWSS3Service.java | 87 ++++++++++++++ .../java/com/baeldung/s3/S3Application.java | 108 +++++++++++++++++ .../s3/AWSS3ServiceIntegrationTest.java | 113 ++++++++++++++++++ 4 files changed, 340 insertions(+) create mode 100644 aws/src/main/java/com/baeldung/s3/AWSS3Service.java create mode 100644 aws/src/main/java/com/baeldung/s3/S3Application.java create mode 100644 aws/src/test/java/com/baeldung/s3/AWSS3ServiceIntegrationTest.java diff --git a/aws/pom.xml b/aws/pom.xml index 8d60240c87..c66c420fae 100644 --- a/aws/pom.xml +++ b/aws/pom.xml @@ -18,9 +18,41 @@ 1.3.0 1.1.0 2.8.0 + 1.11.154 + 4.12 + 2.8.9 + 3.8.0 + + + com.amazonaws + aws-java-sdk + ${aws-java-sdk.version} + + + + junit + junit + ${junit.version} + test + + + + org.mockito + mockito-core + ${mockito-core.version} + test + + + + org.assertj + assertj-core + ${assertj-core.version} + test + + com.amazonaws aws-lambda-java-core diff --git a/aws/src/main/java/com/baeldung/s3/AWSS3Service.java b/aws/src/main/java/com/baeldung/s3/AWSS3Service.java new file mode 100644 index 0000000000..792e41a188 --- /dev/null +++ b/aws/src/main/java/com/baeldung/s3/AWSS3Service.java @@ -0,0 +1,87 @@ +package com.baeldung.s3; + +import java.io.File; +import java.util.List; + +import com.amazonaws.services.s3.AmazonS3; +import com.amazonaws.services.s3.AmazonS3Client; +import com.amazonaws.services.s3.model.Bucket; +import com.amazonaws.services.s3.model.CopyObjectResult; +import com.amazonaws.services.s3.model.DeleteObjectsRequest; +import com.amazonaws.services.s3.model.DeleteObjectsResult; +import com.amazonaws.services.s3.model.ObjectListing; +import com.amazonaws.services.s3.model.PutObjectResult; +import com.amazonaws.services.s3.model.S3Object; + +public class AWSS3Service { + private final AmazonS3 s3client; + + public AWSS3Service() { + this(new AmazonS3Client() { + }); + } + + public AWSS3Service(AmazonS3 s3client) { + this.s3client = s3client; + } + + //is bucket exist? + public boolean doesBucketExist(String bucketName) { + return s3client.doesBucketExist(bucketName); + } + + //create a bucket + public Bucket createBucket(String bucketName) { + return s3client.createBucket(bucketName); + } + + //list all buckets + public List listBuckets() { + return s3client.listBuckets(); + } + + //delete a bucket + public void deleteBucket(String bucketName) { + s3client.deleteBucket(bucketName); + } + + //uploading object + public PutObjectResult putObject(String bucketName, String key, File file) { + return s3client.putObject(bucketName, key, file); + } + + //listing objects + public ObjectListing listObjects(String bucketName) { + return s3client.listObjects(bucketName); + } + + //get an object + public S3Object getObject(String bucketName, String objectKey) { + return s3client.getObject(bucketName, objectKey); + } + + //copying an object + public CopyObjectResult copyObject( + String sourceBucketName, + String sourceKey, + String destinationBucketName, + String destinationKey + ) { + return s3client.copyObject( + sourceBucketName, + sourceKey, + destinationBucketName, + destinationKey + ); + } + + //deleting an object + public void deleteObject(String bucketName, String objectKey) { + s3client.deleteObject(bucketName, objectKey); + } + + //deleting multiple Objects + public DeleteObjectsResult deleteObjects(DeleteObjectsRequest delObjReq) { + return s3client.deleteObjects(delObjReq); + } +} diff --git a/aws/src/main/java/com/baeldung/s3/S3Application.java b/aws/src/main/java/com/baeldung/s3/S3Application.java new file mode 100644 index 0000000000..fcbd7811b5 --- /dev/null +++ b/aws/src/main/java/com/baeldung/s3/S3Application.java @@ -0,0 +1,108 @@ +package com.baeldung.s3; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import com.amazonaws.auth.AWSCredentials; +import com.amazonaws.auth.AWSStaticCredentialsProvider; +import com.amazonaws.auth.BasicAWSCredentials; +import com.amazonaws.regions.Regions; +import com.amazonaws.services.s3.AmazonS3; +import com.amazonaws.services.s3.AmazonS3ClientBuilder; +import com.amazonaws.services.s3.model.Bucket; +import com.amazonaws.services.s3.model.DeleteObjectsRequest; +import com.amazonaws.services.s3.model.ObjectListing; +import com.amazonaws.services.s3.model.S3Object; +import com.amazonaws.services.s3.model.S3ObjectInputStream; +import com.amazonaws.services.s3.model.S3ObjectSummary; + +public class S3Application { + + private static final AWSCredentials credentials; + private static String bucketName; + + static { + //put your accesskey and secretkey here + credentials = new BasicAWSCredentials( + "", + "" + ); + } + + public static void main(String[] args) throws IOException { + //set-up the client + AmazonS3 s3client = AmazonS3ClientBuilder + .standard() + .withCredentials(new AWSStaticCredentialsProvider(credentials)) + .withRegion(Regions.US_EAST_2) + .build(); + + AWSS3Service awsService = new AWSS3Service(s3client); + + bucketName = "baeldung-bucket"; + + //creating a bucket + if(awsService.doesBucketExist(bucketName)) { + System.out.println("Bucket name is not available." + + " Try again with a different Bucket name."); + return; + } + awsService.createBucket(bucketName); + + //list all the buckets + for(Bucket s : awsService.listBuckets() ) { + System.out.println(s.getName()); + } + + //deleting bucket + awsService.deleteBucket("baeldung-bucket-test2"); + + //uploading object + awsService.putObject( + bucketName, + "Document/hello.txt", + new File("/Users/user/Document/hello.txt") + ); + + //listing objects + ObjectListing objectListing = awsService.listObjects(bucketName); + for(S3ObjectSummary os : objectListing.getObjectSummaries()) { + System.out.println(os.getKey()); + } + + //downloading an object + S3Object s3object = awsService.getObject(bucketName, "Document/hello.txt"); + S3ObjectInputStream inputStream = s3object.getObjectContent(); + FileOutputStream fos = new FileOutputStream(new File("/Users/user/Desktop/hello.txt")); + + int read = 0; + byte[] bytes = new byte[1024]; + while ((read = inputStream.read(bytes)) != -1) { + fos.write(bytes, 0, read); + } + inputStream.close(); + fos.close(); + + //copying an object + awsService.copyObject( + "baeldung-bucket", + "picture/pic.png", + "baeldung-bucket2", + "Document/picture.png" + ); + + //deleting an object + awsService.deleteObject(bucketName, "Document/hello.txt"); + + //deleting multiple objects + String objkeyArr[] = { + "Document/hello2.txt", + "Document/picture.png" + }; + + DeleteObjectsRequest delObjReq = new DeleteObjectsRequest("baeldung-bucket") + .withKeys(objkeyArr); + awsService.deleteObjects(delObjReq); + } +} diff --git a/aws/src/test/java/com/baeldung/s3/AWSS3ServiceIntegrationTest.java b/aws/src/test/java/com/baeldung/s3/AWSS3ServiceIntegrationTest.java new file mode 100644 index 0000000000..d386704513 --- /dev/null +++ b/aws/src/test/java/com/baeldung/s3/AWSS3ServiceIntegrationTest.java @@ -0,0 +1,113 @@ +package com.baeldung.s3; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.io.File; + +import org.junit.Before; +import org.junit.Test; + +import com.amazonaws.services.s3.AmazonS3; +import com.amazonaws.services.s3.model.CopyObjectResult; +import com.amazonaws.services.s3.model.DeleteObjectsRequest; +import com.amazonaws.services.s3.model.DeleteObjectsResult; +import com.amazonaws.services.s3.model.PutObjectResult; + +public class AWSS3ServiceIntegrationTest { + + private static final String BUCKET_NAME = "bucket_name"; + private static final String KEY_NAME = "key_name"; + private static final String BUCKET_NAME2 = "bucket_name2"; + private static final String KEY_NAME2 = "key_name2"; + + private AmazonS3 s3; + private AWSS3Service service; + + @Before + public void setUp() { + s3 = mock(AmazonS3.class); + service = new AWSS3Service(s3); + } + + @Test + public void whenInitializingAWSS3Service_thenNotNull() { + assertThat(new AWSS3Service()).isNotNull(); + } + + @Test + public void whenVerifyingIfS3BucketExist_thenCorrect() { + service.doesBucketExist(BUCKET_NAME); + verify(s3).doesBucketExist(BUCKET_NAME); + } + + @Test + public void whenVerifyingCreationOfS3Bucket_thenCorrect() { + service.createBucket(BUCKET_NAME); + verify(s3).createBucket(BUCKET_NAME); + } + + @Test + public void whenVerifyingListBuckets_thenCorrect() { + service.listBuckets(); + verify(s3).listBuckets(); + } + + @Test + public void whenDeletingBucket_thenCorrect() { + service.deleteBucket(BUCKET_NAME); + verify(s3).deleteBucket(BUCKET_NAME); + } + + @Test + public void whenVerifyingPutObject_thenCorrect() { + File file = mock(File.class); + PutObjectResult result = mock(PutObjectResult.class); + when(s3.putObject(anyString(), anyString(), (File) any())).thenReturn(result); + + assertThat(service.putObject(BUCKET_NAME, KEY_NAME, file)).isEqualTo(result); + verify(s3).putObject(BUCKET_NAME, KEY_NAME, file); + } + + @Test + public void whenVerifyingListObjects_thenCorrect() { + service.listObjects(BUCKET_NAME); + verify(s3).listObjects(BUCKET_NAME); + } + + @Test + public void whenVerifyingGetObject_thenCorrect() { + service.getObject(BUCKET_NAME, KEY_NAME); + verify(s3).getObject(BUCKET_NAME, KEY_NAME); + } + + @Test + public void whenVerifyingCopyObject_thenCorrect() { + CopyObjectResult result = mock(CopyObjectResult.class); + when(s3.copyObject(anyString(), anyString(), anyString(), anyString())).thenReturn(result); + + assertThat(service.copyObject(BUCKET_NAME, KEY_NAME, BUCKET_NAME2, KEY_NAME2)).isEqualTo(result); + verify(s3).copyObject(BUCKET_NAME, KEY_NAME, BUCKET_NAME2, KEY_NAME2); + } + + @Test + public void whenVerifyingDeleteObject_thenCorrect() { + service.deleteObject(BUCKET_NAME, KEY_NAME); + verify(s3).deleteObject(BUCKET_NAME, KEY_NAME); + } + + @Test + public void whenVerifyingDeleteObjects_thenCorrect() { + DeleteObjectsRequest request = mock(DeleteObjectsRequest.class); + DeleteObjectsResult result = mock(DeleteObjectsResult.class); + when(s3.deleteObjects((DeleteObjectsRequest)any())).thenReturn(result); + + assertThat(service.deleteObjects(request)).isEqualTo(result); + verify(s3).deleteObjects(request); + } + +} From 8ca38e15dac413dc433e13f7786ed83fbaa4b880 Mon Sep 17 00:00:00 2001 From: Rokon Uddin Ahmed Date: Thu, 13 Jul 2017 19:43:43 +0600 Subject: [PATCH 25/89] Github11.07 (#2254) * Update README.md * Update README.md * Create README.md * Create README.md * Create README.md * Update README.md * Update README.md * Update README.md * Create README.md * Update README.MD * Create README.md * Update README.md * Update README.md * Update README.md * Create README.md * Update README.md * Update README.md * Update README.md * Update README.MD * Update README.md --- algorithms/README.md | 2 ++ core-java-9/README.md | 3 +++ core-java/README.md | 10 ++++++++++ ejb/README.md | 1 + kotlin/README.md | 1 + libraries/README.md | 5 +++++ liquibase/README.md | 2 ++ log-mdc/README.md | 1 + metrics/README.md | 1 + selenium-junit-testng/README.md | 1 + spring-5-mvc/README.md | 2 ++ spring-5/README.md | 4 +++- spring-boot-bootstrap/README.md | 2 ++ spring-boot/README.MD | 3 +++ spring-cloud/spring-cloud-bootstrap/README.MD | 2 +- spring-mvc-java/README.md | 1 + spring-security-sso/README.md | 2 ++ spring-vertx/README.md | 2 ++ structurizr/README.md | 2 ++ vavr/README.md | 1 + 20 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 liquibase/README.md create mode 100644 spring-5-mvc/README.md create mode 100644 spring-boot-bootstrap/README.md create mode 100644 spring-security-sso/README.md create mode 100644 spring-vertx/README.md create mode 100644 structurizr/README.md diff --git a/algorithms/README.md b/algorithms/README.md index f1e12ee243..dc12b528da 100644 --- a/algorithms/README.md +++ b/algorithms/README.md @@ -6,3 +6,5 @@ - [Validating Input With Finite Automata in Java](http://www.baeldung.com/finite-automata-java) - [Introduction to Jenetics Library](http://www.baeldung.com/jenetics) - [Check If a Number Is Prime in Java](http://www.baeldung.com/java-prime-numbers) +- [Example of Hill Climbing Algorithm](http://www.baeldung.com/java-hill-climbing-algorithm) +- [Monte Carlo Tree Search for Tic-Tac-Toe Game](http://www.baeldung.com/java-monte-carlo-tree-search) diff --git a/core-java-9/README.md b/core-java-9/README.md index 3e82ffe14b..22d6903f06 100644 --- a/core-java-9/README.md +++ b/core-java-9/README.md @@ -13,3 +13,6 @@ - [Java 9 Process API Improvements](http://www.baeldung.com/java-9-process-api) - [Introduction to Java 9 StackWalking API](http://www.baeldung.com/java-9-stackwalking-api) - [Introduction to Project Jigsaw](http://www.baeldung.com/project-jigsaw-java-modularity) +- [Java 9 Optional API Additions](http://www.baeldung.com/java-9-optional) +- [Java 9 Reactive Streams](http://www.baeldung.com/java-9-reactive-streams) +- [How to Get All Dates Between Two Dates?](http://www.baeldung.com/java-between-dates) diff --git a/core-java/README.md b/core-java/README.md index 559507e472..dabf6f39be 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -113,6 +113,16 @@ - [Difference Between Wait and Sleep in Java](http://www.baeldung.com/java-wait-and-sleep) - [LongAdder and LongAccumulator in Java](http://www.baeldung.com/java-longadder-and-longaccumulator) - [Using Java MappedByteBuffer](http://www.baeldung.com/java-mapped-byte-buffer) +- [The Dining Philosophers Problem in Java](http://www.baeldung.com/java-dining-philoshophers) +- [The Difference Between map() and flatMap()](http://www.baeldung.com/java-difference-map-and-flatmap) +- [How to Round a Number to N Decimal Places in Java](http://www.baeldung.com/java-round-decimal-number) +- [Changing Annotation Parameters At Runtime](http://www.baeldung.com/java-reflection-change-annotation-params) +- [How to Find all Getters Returning Null](http://www.baeldung.com/java-getters-returning-null) +- [Converting String to Stream of chars](http://www.baeldung.com/java-string-to-stream) +- [Changing the Order in a Sum Operation Can Produce Different Results?](http://www.baeldung.com/java-floating-point-sum-order) +- [How to Get a Name of a Method Being Executed?](http://www.baeldung.com/java-name-of-executing-method) +- [Iterate over a Map in Java](http://www.baeldung.com/java-iterate-map) +- [CyclicBarrier in Java](http://www.baeldung.com/java-cyclic-barrier) - [Dynamic Proxies in Java](http://www.baeldung.com/java-dynamic-proxies) - [How to Copy an Array in Java](http://www.baeldung.com/java-array-copy) - [Introduction to JDBC](http://www.baeldung.com/java-jdbc) diff --git a/ejb/README.md b/ejb/README.md index 08392bc80d..3b729318d4 100644 --- a/ejb/README.md +++ b/ejb/README.md @@ -1,3 +1,4 @@ ## Relevant articles: - [Guide to EJB Set-up](http://www.baeldung.com/ejb-intro) +- [Java EE Session Beans](http://www.baeldung.com/ejb-session-beans) diff --git a/kotlin/README.md b/kotlin/README.md index 1408bc1ebd..6b3fb93dcc 100644 --- a/kotlin/README.md +++ b/kotlin/README.md @@ -6,3 +6,4 @@ - [Kotlin Java Interoperability](http://www.baeldung.com/kotlin-java-interoperability) - [Difference Between “==” and “===” in Kotlin](http://www.baeldung.com/kotlin-equality-operators) - [Generics in Kotlin](http://www.baeldung.com/kotlin-generics) +- [Introduction to Kotlin Coroutines](http://www.baeldung.com/kotlin-coroutines) diff --git a/libraries/README.md b/libraries/README.md index 293e11cf0c..76119b87a3 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -12,6 +12,11 @@ - [Introduction to Apache Commons Math](http://www.baeldung.com/apache-commons-math) - [Intro to JaVer](http://www.baeldung.com/serenity-bdd) - [Introduction to Netty](http://www.baeldung.com/netty) +- [Merging Streams in Java](http://www.baeldung.com/java-merge-streams) +- [Serenity BDD and Screenplay](http://www.baeldung.com/serenity-screenplay) +- [Introduction to Quartz](http://www.baeldung.com/quartz) +- [How to Warm Up the JVM](http://www.baeldung.com/java-jvm-warmup) +- [Apache Commons Collections SetUtils](http://www.baeldung.com/apache-commons-setutils) - [Guide to Java Data Objects](http://www.baeldung.com/jdo) - [Software Transactional Memory in Java Using Multiverse](http://www.baeldung.com/java-multiverse-stm) - [Introduction to HikariCP](http://www.baeldung.com/hikaricp) diff --git a/liquibase/README.md b/liquibase/README.md new file mode 100644 index 0000000000..0e5bfcb8a6 --- /dev/null +++ b/liquibase/README.md @@ -0,0 +1,2 @@ +### Relevant Articles: +- [Introduction to Liquibase Rollback](http://www.baeldung.com/liquibase-rollback) diff --git a/log-mdc/README.md b/log-mdc/README.md index be0b2670c3..3841224824 100644 --- a/log-mdc/README.md +++ b/log-mdc/README.md @@ -2,6 +2,7 @@ - TBD - [Improved Java Logging with Mapped Diagnostic Context (MDC)](http://www.baeldung.com/mdc-in-log4j-2-logback) - [Java Logging with Nested Diagnostic Context (NDC)](http://www.baeldung.com/java-logging-ndc-log4j) +- [Drools Using Rules from Excel Files](http://www.baeldung.com/drools-excel) ### References diff --git a/metrics/README.md b/metrics/README.md index c98024c479..09fe925604 100644 --- a/metrics/README.md +++ b/metrics/README.md @@ -1,3 +1,4 @@ ## Relevant articles: - [Intro to Dropwizard Metrics](http://www.baeldung.com/dropwizard-metrics) +- [Introduction to Netflix Servo](http://www.baeldung.com/netflix-servo) diff --git a/selenium-junit-testng/README.md b/selenium-junit-testng/README.md index cc1b728287..29393b956b 100644 --- a/selenium-junit-testng/README.md +++ b/selenium-junit-testng/README.md @@ -1,3 +1,4 @@ ### Relevant Articles: - [Guide to Selenium with JUnit / TestNG](http://www.baeldung.com/java-selenium-with-junit-and-testng) - [Testing a Site with Selenium / Webdriver](http://www.baeldung.com) +- [Testing with Selenium/WebDriver and the Page Object Pattern](http://www.baeldung.com/selenium-webdriver-page-object) diff --git a/spring-5-mvc/README.md b/spring-5-mvc/README.md new file mode 100644 index 0000000000..c031a9d10e --- /dev/null +++ b/spring-5-mvc/README.md @@ -0,0 +1,2 @@ +### Relevant Articles: +- [Spring Boot and Kotlin](http://www.baeldung.com/spring-boot-kotlin) diff --git a/spring-5/README.md b/spring-5/README.md index 510ee45f03..03b8121f90 100644 --- a/spring-5/README.md +++ b/spring-5/README.md @@ -7,4 +7,6 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Concurrent Test Execution in Spring 5](http://www.baeldung.com/spring-5-concurrent-tests) - [Introduction to the Functional Web Framework in Spring 5](http://www.baeldung.com/spring-5-functional-web) -- [Exploring the Spring MVC URL Matching Improvements](http://www.baeldung.com/spring-mvc-url-matching) +- [Exploring the Spring 5 MVC URL Matching Improvements](http://www.baeldung.com/spring-5-mvc-url-matching) + + diff --git a/spring-boot-bootstrap/README.md b/spring-boot-bootstrap/README.md new file mode 100644 index 0000000000..75a2b35be7 --- /dev/null +++ b/spring-boot-bootstrap/README.md @@ -0,0 +1,2 @@ +### Relevant Articles: +- [Bootstrap a Simple Application using Spring Boot](http://www.baeldung.com/spring-boot-start) diff --git a/spring-boot/README.MD b/spring-boot/README.MD index 9a4a9f3686..e837c88804 100644 --- a/spring-boot/README.MD +++ b/spring-boot/README.MD @@ -23,4 +23,7 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Create a Custom Auto-Configuration with Spring Boot](http://www.baeldung.com/spring-boot-custom-auto-configuration) - [Testing in Spring Boot](http://www.baeldung.com/spring-boot-testing) - [Guide to @ConfigurationProperties in Spring Boot](http://www.baeldung.com/configuration-properties-in-spring-boot) +- [How to Get All Spring-Managed Beans?](http://www.baeldung.com/spring-show-all-beans) +- [A Java Client for a WebSockets API](http://www.baeldung.com/websockets-api-java-spring-client) - [Spring Boot and Togglz Aspect](http://www.baeldung.com/spring-togglz) + diff --git a/spring-cloud/spring-cloud-bootstrap/README.MD b/spring-cloud/spring-cloud-bootstrap/README.MD index a174fba3dd..164219c185 100644 --- a/spring-cloud/spring-cloud-bootstrap/README.MD +++ b/spring-cloud/spring-cloud-bootstrap/README.MD @@ -2,9 +2,9 @@ - [Spring Cloud – Bootstrapping](http://www.baeldung.com/spring-cloud-bootstrapping) - [Spring Cloud – Securing Services](http://www.baeldung.com/spring-cloud-securing-services) - [Spring Cloud – Tracing Services with Zipkin](http://www.baeldung.com/tracing-services-with-zipkin) +- [Spring Cloud Series – The Gateway Pattern](http://www.baeldung.com/spring-cloud-gateway-pattern) - [Spring Cloud – Adding Angular 4](http://www.baeldung.com/spring-cloud-angular) - - To run the project: - copy the appliction-config folder to c:\Users\{username}\ on Windows or /Users/{username}/ on *nix. Then open a git bash terminal in application-config and run: - git init diff --git a/spring-mvc-java/README.md b/spring-mvc-java/README.md index 504cfcdcc7..d42efa7ff6 100644 --- a/spring-mvc-java/README.md +++ b/spring-mvc-java/README.md @@ -23,3 +23,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Uploading and Displaying Excel Files with Spring MVC](http://www.baeldung.com/spring-mvc-excel-files) - [Spring MVC Custom Validation](http://www.baeldung.com/spring-mvc-custom-validator) - [web.xml vs Initializer with Spring](http://www.baeldung.com/spring-xml-vs-java-config) +- [The HttpMediaTypeNotAcceptableException in Spring MVC](http://www.baeldung.com/spring-httpmediatypenotacceptable) diff --git a/spring-security-sso/README.md b/spring-security-sso/README.md new file mode 100644 index 0000000000..11b5f011d5 --- /dev/null +++ b/spring-security-sso/README.md @@ -0,0 +1,2 @@ +### Relevant Articles: +- [Simple Single Sign On with Spring Security OAuth2](http://www.baeldung.com/sso-spring-security-oauth2) diff --git a/spring-vertx/README.md b/spring-vertx/README.md new file mode 100644 index 0000000000..05d059e1b2 --- /dev/null +++ b/spring-vertx/README.md @@ -0,0 +1,2 @@ +### Relevant Articles: +- [Vert.x Spring Integration](http://www.baeldung.com/spring-vertx) diff --git a/structurizr/README.md b/structurizr/README.md new file mode 100644 index 0000000000..e596dfa458 --- /dev/null +++ b/structurizr/README.md @@ -0,0 +1,2 @@ +### Relevant Articles: +- [Intro to Structurizr](http://www.baeldung.com/structurizr) diff --git a/vavr/README.md b/vavr/README.md index e79e3269d5..d95e026bde 100644 --- a/vavr/README.md +++ b/vavr/README.md @@ -3,3 +3,4 @@ - [Guide to Try in Vavr](http://www.baeldung.com/javaslang-try) - [Guide to Pattern Matching in Vavr](http://www.baeldung.com/javaslang-pattern-matching) - [Property Testing Example With Vavr](http://www.baeldung.com/javaslang-property-testing) +- [Exceptions in Lambda Expression Using Vavr](http://www.baeldung.com/exceptions-using-vavr) From 835d9814fdf8acf11c5fa6e9e12a1fc217f4cc13 Mon Sep 17 00:00:00 2001 From: yetanotherallisonf Date: Thu, 13 Jul 2017 12:23:53 -0500 Subject: [PATCH 26/89] Update README.md (#2252) --- junit5/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/junit5/README.md b/junit5/README.md index c1ff0eab63..49cd8e61a4 100644 --- a/junit5/README.md +++ b/junit5/README.md @@ -4,3 +4,4 @@ - [Guide to Dynamic Tests in Junit 5](http://www.baeldung.com/junit5-dynamic-tests) - [A Guide to @RepeatedTest in Junit 5](http://www.baeldung.com/junit-5-repeated-test) - [Guide to Dynamic Tests in Junit 5](http://www.baeldung.com/junit5-dynamic-tests) +- [A Guied to JUnit 5 Extensions](http://www.baeldung.com/junit-5-extensions) From 7df3f24350c7574a525758832ca105957e74c566 Mon Sep 17 00:00:00 2001 From: yetanotherallisonf Date: Thu, 13 Jul 2017 12:24:07 -0500 Subject: [PATCH 27/89] Update README.md (#2249) --- libraries/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/README.md b/libraries/README.md index 76119b87a3..c7e56db3b8 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -23,6 +23,7 @@ - [Serenity BDD with Spring and JBehave](http://www.baeldung.com/serenity-spring-jbehave) - [Locality-Sensitive Hashing in Java Using Java-LSH](http://www.baeldung.com/locality-sensitive-hashing) - [Apache Commons Collections OrderedMap](http://www.baeldung.com/apache-commons-ordered-map) +- [A Guide to Apache Commons DbUtils](http://www.baeldung.com/apache-commons-dbutils) The libraries module contains examples related to small libraries that are relatively easy to use and does not require any separate module of its own. From 3718dfd0d16f20017ff1229e7cf76271ecb239d8 Mon Sep 17 00:00:00 2001 From: Tomasz Lelek Date: Thu, 13 Jul 2017 20:24:49 +0200 Subject: [PATCH 28/89] Bael 1010 hll (#2256) * BAEL-1010 HLL article code * BAEL-1010 moved tolerated difference to a variable * Merge branch 'master' of https://github.com/eugenp/tutorials into BAEL-1010_hll # Conflicts: # libraries/pom.xml * BAEL-1010 clearer code --- .../java/com/baeldung/hll/HLLUnitTest.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/libraries/src/test/java/com/baeldung/hll/HLLUnitTest.java b/libraries/src/test/java/com/baeldung/hll/HLLUnitTest.java index 42af5d0f0b..2745e1e681 100644 --- a/libraries/src/test/java/com/baeldung/hll/HLLUnitTest.java +++ b/libraries/src/test/java/com/baeldung/hll/HLLUnitTest.java @@ -22,9 +22,9 @@ public class HLLUnitTest { //when LongStream.range(0, numberOfElements).forEach(element -> { - long hashedValue = hashFunction.newHasher().putLong(element).hash().asLong(); - hll.addRaw(hashedValue); - } + long hashedValue = hashFunction.newHasher().putLong(element).hash().asLong(); + hll.addRaw(hashedValue); + } ); //then @@ -43,21 +43,22 @@ public class HLLUnitTest { //when LongStream.range(0, numberOfElements).forEach(element -> { - long hashedValue = hashFunction.newHasher().putLong(element).hash().asLong(); - firstHll.addRaw(hashedValue); - } + long hashedValue = hashFunction.newHasher().putLong(element).hash().asLong(); + firstHll.addRaw(hashedValue); + } ); LongStream.range(numberOfElements, numberOfElements * 2).forEach(element -> { - long hashedValue = hashFunction.newHasher().putLong(element).hash().asLong(); - secondHLL.addRaw(hashedValue); - } + long hashedValue = hashFunction.newHasher().putLong(element).hash().asLong(); + secondHLL.addRaw(hashedValue); + } ); //then firstHll.union(secondHLL); long cardinality = firstHll.cardinality(); - assertThat(isSimilarTo(cardinality, numberOfElements * 2, toleratedDifference)).isTrue(); + assertThat(isSimilarTo(cardinality, numberOfElements * 2, + toleratedDifference * 2)).isTrue(); } private boolean isSimilarTo(long cardinality, int numberOfElements, int maxToleratedDifference) { From 4233d909023e2ef157d720822fd04f45c1ad84d2 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Thu, 13 Jul 2017 21:15:19 +0200 Subject: [PATCH 29/89] Remove vaadin tests (#2257) * Refactor Vaadin samples * Refactor Vaadin samples --- libraries/pom.xml | 4 - .../java/com/baeldung/jetty/JettyServer.java | 6 +- .../junitparams/SafeAdditionUtil.java | 4 +- .../java/com/baeldung/netty/NettyServer.java | 4 +- .../java/com/baeldung/netty/RequestData.java | 14 +-- .../java/com/baeldung/netty/ResponseData.java | 4 +- .../baeldung/netty/ResponseDataDecoder.java | 4 +- .../com/baeldung/quartz/QuartzExample.java | 66 ++++++------- .../java/com/baeldung/quartz/SimpleJob.java | 4 +- .../main/java/com/baeldung/stm/Account.java | 12 +-- .../java/com/baeldung/vaadin/VaadinUI.java | 59 ++++++----- .../com/baeldung/vaadin/VaadinUITests.java | 99 ------------------- 12 files changed, 87 insertions(+), 193 deletions(-) delete mode 100644 libraries/src/test/java/com/baeldung/vaadin/VaadinUITests.java diff --git a/libraries/pom.xml b/libraries/pom.xml index 231233afbb..9093a2db03 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -463,10 +463,6 @@ com.vaadin vaadin-server - - com.vaadin - vaadin-push - com.vaadin vaadin-client-compiled diff --git a/libraries/src/main/java/com/baeldung/jetty/JettyServer.java b/libraries/src/main/java/com/baeldung/jetty/JettyServer.java index 1033a7266d..364b05473a 100644 --- a/libraries/src/main/java/com/baeldung/jetty/JettyServer.java +++ b/libraries/src/main/java/com/baeldung/jetty/JettyServer.java @@ -6,11 +6,11 @@ import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.servlet.ServletHandler; import org.eclipse.jetty.util.thread.QueuedThreadPool; -public class JettyServer { +class JettyServer { private Server server; - public void start() throws Exception { + void start() throws Exception { int maxThreads = 100; int minThreads = 10; @@ -33,7 +33,7 @@ public class JettyServer { } - public void stop() throws Exception { + void stop() throws Exception { server.stop(); } } diff --git a/libraries/src/main/java/com/baeldung/junitparams/SafeAdditionUtil.java b/libraries/src/main/java/com/baeldung/junitparams/SafeAdditionUtil.java index a2c1573dca..60436865a9 100644 --- a/libraries/src/main/java/com/baeldung/junitparams/SafeAdditionUtil.java +++ b/libraries/src/main/java/com/baeldung/junitparams/SafeAdditionUtil.java @@ -1,8 +1,8 @@ package com.baeldung.junitparams; -public class SafeAdditionUtil { +class SafeAdditionUtil { - public int safeAdd(int a, int b) { + int safeAdd(int a, int b) { long result = ((long) a) + b; if (result > Integer.MAX_VALUE) { return Integer.MAX_VALUE; diff --git a/libraries/src/main/java/com/baeldung/netty/NettyServer.java b/libraries/src/main/java/com/baeldung/netty/NettyServer.java index b9d35859d0..319829b7b6 100644 --- a/libraries/src/main/java/com/baeldung/netty/NettyServer.java +++ b/libraries/src/main/java/com/baeldung/netty/NettyServer.java @@ -13,7 +13,7 @@ public class NettyServer { private int port; - public NettyServer(int port) { + private NettyServer(int port) { this.port = port; } @@ -27,7 +27,7 @@ public class NettyServer { new NettyServer(port).run(); } - public void run() throws Exception { + private void run() throws Exception { EventLoopGroup bossGroup = new NioEventLoopGroup(); EventLoopGroup workerGroup = new NioEventLoopGroup(); try { diff --git a/libraries/src/main/java/com/baeldung/netty/RequestData.java b/libraries/src/main/java/com/baeldung/netty/RequestData.java index e7404c1663..402aa1ef91 100644 --- a/libraries/src/main/java/com/baeldung/netty/RequestData.java +++ b/libraries/src/main/java/com/baeldung/netty/RequestData.java @@ -4,27 +4,27 @@ public class RequestData { private int intValue; private String stringValue; - public int getIntValue() { + int getIntValue() { return intValue; } - public void setIntValue(int intValue) { + void setIntValue(int intValue) { this.intValue = intValue; } - public String getStringValue() { + String getStringValue() { return stringValue; } - public void setStringValue(String stringValue) { + void setStringValue(String stringValue) { this.stringValue = stringValue; } @Override public String toString() { return "RequestData{" + - "intValue=" + intValue + - ", stringValue='" + stringValue + '\'' + - '}'; + "intValue=" + intValue + + ", stringValue='" + stringValue + '\'' + + '}'; } } diff --git a/libraries/src/main/java/com/baeldung/netty/ResponseData.java b/libraries/src/main/java/com/baeldung/netty/ResponseData.java index ce388a9a3d..51d1adaafb 100644 --- a/libraries/src/main/java/com/baeldung/netty/ResponseData.java +++ b/libraries/src/main/java/com/baeldung/netty/ResponseData.java @@ -3,11 +3,11 @@ package com.baeldung.netty; public class ResponseData { private int intValue; - public int getIntValue() { + int getIntValue() { return intValue; } - public void setIntValue(int intValue) { + void setIntValue(int intValue) { this.intValue = intValue; } diff --git a/libraries/src/main/java/com/baeldung/netty/ResponseDataDecoder.java b/libraries/src/main/java/com/baeldung/netty/ResponseDataDecoder.java index ee33679dfe..16e2a61bd3 100644 --- a/libraries/src/main/java/com/baeldung/netty/ResponseDataDecoder.java +++ b/libraries/src/main/java/com/baeldung/netty/ResponseDataDecoder.java @@ -1,11 +1,11 @@ package com.baeldung.netty; -import java.util.List; - import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ReplayingDecoder; +import java.util.List; + public class ResponseDataDecoder extends ReplayingDecoder { @Override diff --git a/libraries/src/main/java/com/baeldung/quartz/QuartzExample.java b/libraries/src/main/java/com/baeldung/quartz/QuartzExample.java index 20853aa01b..4757d912f8 100644 --- a/libraries/src/main/java/com/baeldung/quartz/QuartzExample.java +++ b/libraries/src/main/java/com/baeldung/quartz/QuartzExample.java @@ -20,44 +20,44 @@ public class QuartzExample { Scheduler sched = schedFact.getScheduler(); JobDetail job = JobBuilder.newJob(SimpleJob.class) - .withIdentity("myJob", "group1") - .usingJobData("jobSays", "Hello World!") - .usingJobData("myFloatValue", 3.141f) - .build(); + .withIdentity("myJob", "group1") + .usingJobData("jobSays", "Hello World!") + .usingJobData("myFloatValue", 3.141f) + .build(); Trigger trigger = TriggerBuilder.newTrigger() - .withIdentity("myTrigger", "group1") - .startNow() - .withSchedule(SimpleScheduleBuilder.simpleSchedule() - .withIntervalInSeconds(40) - .repeatForever()) - .build(); - + .withIdentity("myTrigger", "group1") + .startNow() + .withSchedule(SimpleScheduleBuilder.simpleSchedule() + .withIntervalInSeconds(40) + .repeatForever()) + .build(); + JobDetail jobA = JobBuilder.newJob(JobA.class) - .withIdentity("jobA", "group2") - .build(); - + .withIdentity("jobA", "group2") + .build(); + JobDetail jobB = JobBuilder.newJob(JobB.class) - .withIdentity("jobB", "group2") - .build(); - + .withIdentity("jobB", "group2") + .build(); + Trigger triggerA = TriggerBuilder.newTrigger() - .withIdentity("triggerA", "group2") - .startNow() - .withPriority(15) - .withSchedule(SimpleScheduleBuilder.simpleSchedule() - .withIntervalInSeconds(40) - .repeatForever()) - .build(); - - Trigger triggerB = TriggerBuilder.newTrigger() - .withIdentity("triggerB", "group2") - .startNow() - .withPriority(10) - .withSchedule(SimpleScheduleBuilder.simpleSchedule() - .withIntervalInSeconds(20) - .repeatForever()) - .build(); + .withIdentity("triggerA", "group2") + .startNow() + .withPriority(15) + .withSchedule(SimpleScheduleBuilder.simpleSchedule() + .withIntervalInSeconds(40) + .repeatForever()) + .build(); + + Trigger triggerB = TriggerBuilder.newTrigger() + .withIdentity("triggerB", "group2") + .startNow() + .withPriority(10) + .withSchedule(SimpleScheduleBuilder.simpleSchedule() + .withIntervalInSeconds(20) + .repeatForever()) + .build(); sched.scheduleJob(job, trigger); sched.scheduleJob(jobA, triggerA); diff --git a/libraries/src/main/java/com/baeldung/quartz/SimpleJob.java b/libraries/src/main/java/com/baeldung/quartz/SimpleJob.java index 986c5e96e5..554d3b9358 100644 --- a/libraries/src/main/java/com/baeldung/quartz/SimpleJob.java +++ b/libraries/src/main/java/com/baeldung/quartz/SimpleJob.java @@ -9,13 +9,11 @@ public class SimpleJob implements Job { public void execute(JobExecutionContext context) throws JobExecutionException { JobDataMap dataMap = context.getJobDetail() - .getJobDataMap(); + .getJobDataMap(); String jobSays = dataMap.getString("jobSays"); float myFloatValue = dataMap.getFloat("myFloatValue"); System.out.println("Job says: " + jobSays + ", and val is: " + myFloatValue); - } - } \ No newline at end of file diff --git a/libraries/src/main/java/com/baeldung/stm/Account.java b/libraries/src/main/java/com/baeldung/stm/Account.java index 734d332308..8b17f87120 100644 --- a/libraries/src/main/java/com/baeldung/stm/Account.java +++ b/libraries/src/main/java/com/baeldung/stm/Account.java @@ -10,20 +10,20 @@ public class Account { private final TxnLong lastUpdate; private final TxnInteger balance; - public Account(final int balance) { + Account(final int balance) { this.lastUpdate = StmUtils.newTxnLong(System.currentTimeMillis()); this.balance = StmUtils.newTxnInteger(balance); } - public Integer getBalance() { + Integer getBalance() { return balance.atomicGet(); } - public void adjustBy(final int amount) { + void adjustBy(final int amount) { adjustBy(amount, System.currentTimeMillis()); } - public void adjustBy(final int amount, final long date) { + private void adjustBy(final int amount, final long date) { StmUtils.atomic(() -> { balance.increment(amount); lastUpdate.set(date); @@ -34,7 +34,7 @@ public class Account { }); } - public void transferTo(final Account other, final int amount) { + void transferTo(final Account other, final int amount) { StmUtils.atomic(() -> { final long date = System.currentTimeMillis(); adjustBy(-amount, date); @@ -45,6 +45,6 @@ public class Account { @Override public String toString() { return StmUtils.atomic((TxnCallable) - txn -> "Balance: " + balance.get(txn) + " lastUpdateDate: " + lastUpdate.get(txn)); + txn -> "Balance: " + balance.get(txn) + " lastUpdateDate: " + lastUpdate.get(txn)); } } \ No newline at end of file diff --git a/libraries/src/main/java/com/baeldung/vaadin/VaadinUI.java b/libraries/src/main/java/com/baeldung/vaadin/VaadinUI.java index 659d45248f..e134b501c8 100644 --- a/libraries/src/main/java/com/baeldung/vaadin/VaadinUI.java +++ b/libraries/src/main/java/com/baeldung/vaadin/VaadinUI.java @@ -1,9 +1,4 @@ package com.baeldung.vaadin; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import javax.servlet.annotation.WebServlet; import com.vaadin.annotations.Theme; import com.vaadin.annotations.VaadinServletConfiguration; @@ -34,7 +29,11 @@ import com.vaadin.ui.TwinColSelect; import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; -@SuppressWarnings("serial") +import javax.servlet.annotation.WebServlet; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + @Theme("mytheme") public class VaadinUI extends UI { @@ -43,7 +42,7 @@ public class VaadinUI extends UI { final VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setSpacing(true); verticalLayout.setMargin(true); - final GridLayout gridLayout = new GridLayout(3,2); + final GridLayout gridLayout = new GridLayout(3, 2); gridLayout.setSpacing(true); gridLayout.setMargin(true); final HorizontalLayout horizontalLayout = new HorizontalLayout(); @@ -61,9 +60,9 @@ public class VaadinUI extends UI { label.setValue("Label Value"); label.setCaption("Label"); gridLayout.addComponent(label); - + final Link link = new Link("Baeldung", - new ExternalResource("http://www.baeldung.com/")); + new ExternalResource("http://www.baeldung.com/")); link.setId("Link"); link.setTargetName("_blank"); gridLayout.addComponent(link); @@ -80,41 +79,41 @@ public class VaadinUI extends UI { textArea.setId("TextArea"); textArea.setValue("TextArea Value"); gridLayout.addComponent(textArea); - + final DateField dateField = new DateField("DateField", new Date(0)); dateField.setId("DateField"); gridLayout.addComponent(dateField); - + final PasswordField passwordField = new PasswordField(); passwordField.setId("PasswordField"); passwordField.setCaption("PasswordField:"); passwordField.setValue("password"); gridLayout.addComponent(passwordField); - + final RichTextArea richTextArea = new RichTextArea(); richTextArea.setCaption("Rich Text Area"); richTextArea.setValue("

RichTextArea

"); richTextArea.setSizeFull(); - + Panel richTextPanel = new Panel(); richTextPanel.setContent(richTextArea); - + final InlineDateField inlineDateField = new InlineDateField(); inlineDateField.setValue(new Date(0)); inlineDateField.setCaption("Inline Date Field"); horizontalLayout.addComponent(inlineDateField); - + Button normalButton = new Button("Normal Button"); normalButton.setId("NormalButton"); normalButton.addClickListener(e -> { label.setValue("CLICK"); }); buttonLayout.addComponent(normalButton); - + Button tinyButton = new Button("Tiny Button"); tinyButton.addStyleName("tiny"); buttonLayout.addComponent(tinyButton); - + Button smallButton = new Button("Small Button"); smallButton.addStyleName("small"); buttonLayout.addComponent(smallButton); @@ -148,14 +147,14 @@ public class VaadinUI extends UI { Button primaryButton = new Button("Primary Button"); primaryButton.addStyleName("primary"); buttonLayout.addComponent(primaryButton); - + NativeButton nativeButton = new NativeButton("Native Button"); buttonLayout.addComponent(nativeButton); Button iconButton = new Button("Icon Button"); iconButton.setIcon(FontAwesome.ALIGN_LEFT); buttonLayout.addComponent(iconButton); - + Button borderlessButton = new Button("BorderLess Button"); borderlessButton.addStyleName("borderless"); buttonLayout.addComponent(borderlessButton); @@ -170,12 +169,12 @@ public class VaadinUI extends UI { horizontalLayout.addComponent(buttonLayout); - final CheckBox checkbox = new CheckBox("CheckBox"); + final CheckBox checkbox = new CheckBox("CheckBox"); checkbox.setValue(true); checkbox.addValueChangeListener(e -> - checkbox.setValue(!checkbox.getValue())); + checkbox.setValue(!checkbox.getValue())); formLayout.addComponent(checkbox); - + List numbers = new ArrayList(); numbers.add("One"); numbers.add("Ten"); @@ -183,28 +182,28 @@ public class VaadinUI extends UI { ComboBox comboBox = new ComboBox("ComboBox"); comboBox.addItems(numbers); formLayout.addComponent(comboBox); - + ListSelect listSelect = new ListSelect("ListSelect"); listSelect.addItems(numbers); listSelect.setRows(2); formLayout.addComponent(listSelect); - + NativeSelect nativeSelect = new NativeSelect("NativeSelect"); nativeSelect.addItems(numbers); formLayout.addComponent(nativeSelect); TwinColSelect twinColSelect = new TwinColSelect("TwinColSelect"); twinColSelect.addItems(numbers); - + Grid grid = new Grid("Grid"); - grid.setColumns(new Object[] {"Column1", "Column2", "Column3"}); - grid.addRow(new Object[] {"Item1", "Item2", "Item3"}); - grid.addRow(new Object[] {"Item4", "Item5", "Item6"}); - + grid.setColumns("Column1", "Column2", "Column3"); + grid.addRow("Item1", "Item2", "Item3"); + grid.addRow("Item4", "Item5", "Item6"); + Panel panel = new Panel("Panel"); panel.setContent(grid); panel.setSizeUndefined(); - + verticalLayout.addComponent(gridLayout); verticalLayout.addComponent(richTextPanel); verticalLayout.addComponent(horizontalLayout); diff --git a/libraries/src/test/java/com/baeldung/vaadin/VaadinUITests.java b/libraries/src/test/java/com/baeldung/vaadin/VaadinUITests.java deleted file mode 100644 index 228b91de34..0000000000 --- a/libraries/src/test/java/com/baeldung/vaadin/VaadinUITests.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.baeldung.vaadin; - -import com.gargoylesoftware.htmlunit.BrowserVersion; -import com.vaadin.server.DefaultUIProvider; -import com.vaadin.server.VaadinServlet; -import org.eclipse.jetty.server.Connector; -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.ServerConnector; -import org.eclipse.jetty.servlet.ServletContextHandler; -import org.eclipse.jetty.servlet.ServletHolder; -import org.eclipse.jetty.util.thread.QueuedThreadPool; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.htmlunit.HtmlUnitDriver; - -import static org.junit.Assert.assertEquals; - - -public class VaadinUITests { - - private WebDriver driver; - private Server server; - - @Before - public void setUp() throws Exception { - startJettyServer(); - driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_45, true); - driver.get("http://localhost:8080"); - Thread.sleep(10000); - } - - @Test - public void whenPageLoadedThenShouldSeeURL() { - String url = driver.getCurrentUrl(); - assertEquals("http://localhost:8080/", url); - } - - @Test - public void givenLabel_WhenGetValue_ThenValueMatch() { - WebElement label = driver.findElement(By.id("Label")); - assertEquals("Label Value", label.getText()); - } - - @Test - public void givenTextField_WhenGetValue_ThenValueMatch() { - WebElement textField = driver.findElement(By.id("TextField")); - assertEquals("TextField Value", textField.getAttribute("Value")); - } - - @Test - public void givenTextArea_WhenGetValue_ThenValueMatch() { - WebElement textArea = driver.findElement(By.id("TextArea")); - assertEquals("TextArea Value", textArea.getAttribute("Value")); - } - - @Test - public void givenDateField_WhenGetValue_ThenValueMatch() { - WebElement dateField = driver.findElement(By.id("DateField")); - assertEquals("12/31/69", dateField.getText()); - } - - @Test - public void givenPasswordField_WhenGetValue_ThenValueMatch() { - WebElement passwordField = driver.findElement(By.id("PasswordField")); - assertEquals("password", passwordField.getAttribute("Value")); - } - - @After - public void cleanUp() throws Exception { - driver.close(); - server.stop(); - } - - public void startJettyServer() throws Exception { - - int maxThreads = 100; - int minThreads = 10; - int idleTimeout = 120; - - QueuedThreadPool threadPool = new QueuedThreadPool(maxThreads, minThreads, idleTimeout); - server = new Server(threadPool); - ServerConnector connector = new ServerConnector(server); - connector.setPort(8080); - server.setConnectors(new Connector[]{connector}); - ServletContextHandler contextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS); - contextHandler.setContextPath("/"); - ServletHolder sh = new ServletHolder(new VaadinServlet()); - contextHandler.addServlet(sh, "/*"); - contextHandler.setInitParameter("ui", VaadinUI.class.getName()); - contextHandler.setInitParameter(VaadinServlet.SERVLET_PARAMETER_UI_PROVIDER, DefaultUIProvider.class.getName()); - server.setHandler(contextHandler); - - server.start(); - } -} \ No newline at end of file From 26fdeaac4625b4f51bda59d3c56081da6a700fc0 Mon Sep 17 00:00:00 2001 From: lor6 Date: Fri, 14 Jul 2017 06:06:36 +0300 Subject: [PATCH 30/89] vavr spring data (#2242) * vavr spring data * formatting * formatting * formatting * formatting --- vavr/pom.xml | 36 ++++++++++++-- .../main/java/com/baeldung/Application.java | 11 +++++ .../repositories/VavrUserRepository.java | 18 +++++++ .../src/main/java/com/baeldung/vavr/User.java | 32 +++++++++++++ .../VavrRepositoryIntegrationTest.java | 47 +++++++++++++++++++ 5 files changed, 140 insertions(+), 4 deletions(-) create mode 100644 vavr/src/main/java/com/baeldung/Application.java create mode 100644 vavr/src/main/java/com/baeldung/repositories/VavrUserRepository.java create mode 100644 vavr/src/main/java/com/baeldung/vavr/User.java create mode 100644 vavr/src/test/java/com/baeldung/vavr/repositories/VavrRepositoryIntegrationTest.java diff --git a/vavr/pom.xml b/vavr/pom.xml index 5356417b3e..cbf2a37ec9 100644 --- a/vavr/pom.xml +++ b/vavr/pom.xml @@ -6,10 +6,11 @@ 1.0 vavr - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT + + org.springframework.boot + spring-boot-starter-parent + 2.0.0.BUILD-SNAPSHOT + @@ -24,9 +25,36 @@ junit ${junit.version}
+ + + org.springframework.boot + spring-boot-starter-data-jpa + + + + com.h2database + h2 + + + + org.springframework.boot + spring-boot-starter-test +
+ + + + spring-snapshot + Spring Snapshot Repository + https://repo.spring.io/snapshot + + true + + + + 1.8 0.9.0 4.12 diff --git a/vavr/src/main/java/com/baeldung/Application.java b/vavr/src/main/java/com/baeldung/Application.java new file mode 100644 index 0000000000..d58049fb35 --- /dev/null +++ b/vavr/src/main/java/com/baeldung/Application.java @@ -0,0 +1,11 @@ +package com.baeldung; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/vavr/src/main/java/com/baeldung/repositories/VavrUserRepository.java b/vavr/src/main/java/com/baeldung/repositories/VavrUserRepository.java new file mode 100644 index 0000000000..a3dd7937f7 --- /dev/null +++ b/vavr/src/main/java/com/baeldung/repositories/VavrUserRepository.java @@ -0,0 +1,18 @@ +package com.baeldung.repositories; + +import org.springframework.data.repository.Repository; + +import com.baeldung.vavr.User; + +import io.vavr.collection.Seq; +import io.vavr.control.Option; + +public interface VavrUserRepository extends Repository { + + Option findById(long id); + + Seq findByName(String name); + + User save(User user); + +} diff --git a/vavr/src/main/java/com/baeldung/vavr/User.java b/vavr/src/main/java/com/baeldung/vavr/User.java new file mode 100644 index 0000000000..69dd9aea24 --- /dev/null +++ b/vavr/src/main/java/com/baeldung/vavr/User.java @@ -0,0 +1,32 @@ +package com.baeldung.vavr; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +public class User { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String name; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/vavr/src/test/java/com/baeldung/vavr/repositories/VavrRepositoryIntegrationTest.java b/vavr/src/test/java/com/baeldung/vavr/repositories/VavrRepositoryIntegrationTest.java new file mode 100644 index 0000000000..c2e9f377dd --- /dev/null +++ b/vavr/src/test/java/com/baeldung/vavr/repositories/VavrRepositoryIntegrationTest.java @@ -0,0 +1,47 @@ +package com.baeldung.vavr.repositories; + +import com.baeldung.Application; +import com.baeldung.repositories.VavrUserRepository; +import com.baeldung.vavr.User; + +import io.vavr.collection.Seq; +import io.vavr.control.Option; + +import org.junit.Test; +import org.junit.Before; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.junit.Assert.*; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = Application.class) +public class VavrRepositoryIntegrationTest { + + @Autowired + private VavrUserRepository userRepository; + + @Before + public void setup() { + User user1 = new User(); + user1.setName("John"); + User user2 = new User(); + user2.setName("John"); + + userRepository.save(user1); + userRepository.save(user2); + } + + @Test + public void whenAddUsers_thenGetUsers() { + Option user = userRepository.findById(1L); + assertFalse(user.isEmpty()); + assertTrue(user.get().getName().equals("John")); + + Seq users = userRepository.findByName("John"); + assertEquals(2, users.size()); + } + +} From 1acbe9b1622631192531f6976b36e39f2a93e94f Mon Sep 17 00:00:00 2001 From: Tian Baoqiang Date: Sat, 15 Jul 2017 02:24:28 -0500 Subject: [PATCH 31/89] #BAEL-1007 (#2264) * #BAEL-1007 * fix format err of pom --- metrics/pom.xml | 18 +++- .../metrics/servo/AtlasObserverLiveTest.java | 95 +++++++++++++++++++ 2 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 metrics/src/test/java/com/baeldung/metrics/servo/AtlasObserverLiveTest.java diff --git a/metrics/pom.xml b/metrics/pom.xml index 794c53b157..574c1ac132 100644 --- a/metrics/pom.xml +++ b/metrics/pom.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 @@ -15,7 +15,7 @@ 3.1.2 3.1.0 - 0.12.16 + 0.12.17 @@ -44,10 +44,24 @@ javax.servlet-api ${dep.ver.servlet}
+ com.netflix.servo servo-core ${netflix.servo.ver} + test + + + com.netflix.servo + servo-atlas + ${netflix.servo.ver} + test + + + com.fasterxml.jackson.dataformat + jackson-dataformat-smile + 2.8.9 + test diff --git a/metrics/src/test/java/com/baeldung/metrics/servo/AtlasObserverLiveTest.java b/metrics/src/test/java/com/baeldung/metrics/servo/AtlasObserverLiveTest.java new file mode 100644 index 0000000000..cc2d3aa393 --- /dev/null +++ b/metrics/src/test/java/com/baeldung/metrics/servo/AtlasObserverLiveTest.java @@ -0,0 +1,95 @@ +package com.baeldung.metrics.servo; + +import com.netflix.servo.DefaultMonitorRegistry; +import com.netflix.servo.monitor.BasicCounter; +import com.netflix.servo.monitor.Counter; +import com.netflix.servo.monitor.MonitorConfig; +import com.netflix.servo.publish.BasicMetricFilter; +import com.netflix.servo.publish.MonitorRegistryMetricPoller; +import com.netflix.servo.publish.PollRunnable; +import com.netflix.servo.publish.PollScheduler; +import com.netflix.servo.publish.atlas.AtlasMetricObserver; +import com.netflix.servo.publish.atlas.BasicAtlasConfig; +import com.netflix.servo.tag.BasicTagList; +import org.apache.commons.lang.math.RandomUtils; +import org.apache.http.HttpEntity; +import org.apache.http.impl.client.HttpClients; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.io.BufferedReader; +import java.io.InputStreamReader; + +import static java.util.concurrent.TimeUnit.SECONDS; +import static org.apache.http.client.methods.RequestBuilder.get; +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.not; +import static org.junit.Assert.assertThat; + +/** + * @author aiet + */ +public class AtlasObserverLiveTest { + + private final String atlasUri = "http://localhost:7101/api/v1"; + + @Before + public void prepareScheduler() { + System.setProperty("servo.pollers", "1000"); + System.setProperty("servo.atlas.batchSize", "1"); + System.setProperty("servo.atlas.uri", atlasUri + "/publish"); + AtlasMetricObserver observer = new AtlasMetricObserver(new BasicAtlasConfig(), BasicTagList.of("servo", "counter")); + + PollRunnable task = new PollRunnable(new MonitorRegistryMetricPoller(), new BasicMetricFilter(true), observer); + PollScheduler + .getInstance() + .start(); + PollScheduler + .getInstance() + .addPoller(task, 1, SECONDS); + } + + @After + public void stopScheduler() { + if (PollScheduler + .getInstance() + .isStarted()) { + PollScheduler + .getInstance() + .stop(); + } + } + + private String atlasValuesOfTag(String tagname) throws Exception { + HttpEntity entity = HttpClients + .createDefault() + .execute(get() + .setUri(atlasUri + "/tags/" + tagname) + .build()) + .getEntity(); + return new BufferedReader(new InputStreamReader(entity.getContent())).readLine(); + } + + @Test + public void givenAtlasAndCounter_whenRegister_thenPublishedToAtlas() throws Exception { + Counter counter = new BasicCounter(MonitorConfig + .builder("test") + .withTag("servo", "counter") + .build()); + DefaultMonitorRegistry + .getInstance() + .register(counter); + assertThat(atlasValuesOfTag("servo"), not(containsString("counter"))); + + for (int i = 0; i < 3; i++) { + counter.increment(RandomUtils.nextInt(10)); + SECONDS.sleep(1); + counter.increment(-1 * RandomUtils.nextInt(10)); + SECONDS.sleep(1); + } + + assertThat(atlasValuesOfTag("servo"), containsString("counter")); + } + +} From 3e2d766f37f3820a5d0b68d4d6fea12c22087522 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sat, 15 Jul 2017 17:08:56 +0200 Subject: [PATCH 32/89] Refactor TemporalAdjusters (#2266) --- .../CustomTemporalAdjuster.java | 17 +++++---- .../CustomTemporalAdjusterTest.java | 36 +++++++------------ 2 files changed, 20 insertions(+), 33 deletions(-) diff --git a/core-java/src/main/java/com/baeldung/temporaladjuster/CustomTemporalAdjuster.java b/core-java/src/main/java/com/baeldung/temporaladjuster/CustomTemporalAdjuster.java index ab491bee66..bfb6681f7c 100644 --- a/core-java/src/main/java/com/baeldung/temporaladjuster/CustomTemporalAdjuster.java +++ b/core-java/src/main/java/com/baeldung/temporaladjuster/CustomTemporalAdjuster.java @@ -10,14 +10,13 @@ public class CustomTemporalAdjuster implements TemporalAdjuster { @Override public Temporal adjustInto(Temporal temporal) { - DayOfWeek dayOfWeek = DayOfWeek.of(temporal.get(ChronoField.DAY_OF_WEEK)); - int daysToAdd; - if (dayOfWeek == DayOfWeek.FRIDAY) - daysToAdd = 3; - else if (dayOfWeek == DayOfWeek.SATURDAY) - daysToAdd = 2; - else - daysToAdd = 1; - return temporal.plus(daysToAdd, ChronoUnit.DAYS); + switch (DayOfWeek.of(temporal.get(ChronoField.DAY_OF_WEEK))) { + case FRIDAY: + return temporal.plus(3, ChronoUnit.DAYS); + case SATURDAY: + return temporal.plus(2, ChronoUnit.DAYS); + default: + return temporal.plus(1, ChronoUnit.DAYS); + } } } diff --git a/core-java/src/test/java/com/baeldung/temporaladjusters/CustomTemporalAdjusterTest.java b/core-java/src/test/java/com/baeldung/temporaladjusters/CustomTemporalAdjusterTest.java index a7acc9f743..ad8de82e1f 100644 --- a/core-java/src/test/java/com/baeldung/temporaladjusters/CustomTemporalAdjusterTest.java +++ b/core-java/src/test/java/com/baeldung/temporaladjusters/CustomTemporalAdjusterTest.java @@ -1,34 +1,34 @@ package com.baeldung.temporaladjusters; -import java.time.DayOfWeek; -import java.time.LocalDate; -import java.time.Period; -import java.time.temporal.TemporalAdjuster; -import java.time.temporal.TemporalAdjusters; - +import com.baeldung.temporaladjuster.CustomTemporalAdjuster; import org.junit.Assert; import org.junit.Test; -import com.baeldung.temporaladjuster.CustomTemporalAdjuster; +import java.time.LocalDate; +import java.time.Period; +import java.time.temporal.TemporalAdjuster; + +import static org.junit.Assert.assertEquals; public class CustomTemporalAdjusterTest { + private static final TemporalAdjuster NEXT_WORKING_DAY = new CustomTemporalAdjuster(); + @Test public void whenAdjustAndImplementInterface_thenNextWorkingDay() { LocalDate localDate = LocalDate.of(2017, 07, 8); CustomTemporalAdjuster temporalAdjuster = new CustomTemporalAdjuster(); LocalDate nextWorkingDay = localDate.with(temporalAdjuster); - Assert.assertEquals("2017-07-10", nextWorkingDay.toString()); + assertEquals("2017-07-10", nextWorkingDay.toString()); } @Test public void whenAdjust_thenNextWorkingDay() { LocalDate localDate = LocalDate.of(2017, 07, 8); - TemporalAdjuster temporalAdjuster = NEXT_WORKING_DAY; - LocalDate date = localDate.with(temporalAdjuster); + LocalDate date = localDate.with(NEXT_WORKING_DAY); - Assert.assertEquals("2017-07-10", date.toString()); + assertEquals("2017-07-10", date.toString()); } @Test @@ -39,18 +39,6 @@ public class CustomTemporalAdjusterTest { String fourteenDaysAfterDate = "2017-07-22"; - Assert.assertEquals(fourteenDaysAfterDate, result.toString()); + assertEquals(fourteenDaysAfterDate, result.toString()); } - - static TemporalAdjuster NEXT_WORKING_DAY = TemporalAdjusters.ofDateAdjuster(date -> { - DayOfWeek dayOfWeek = date.getDayOfWeek(); - int daysToAdd; - if (dayOfWeek == DayOfWeek.FRIDAY) - daysToAdd = 3; - else if (dayOfWeek == DayOfWeek.SATURDAY) - daysToAdd = 2; - else - daysToAdd = 1; - return date.plusDays(daysToAdd); - }); } From 470ac0c7bb48e8c33b7687ab0243d1eed7fc70c5 Mon Sep 17 00:00:00 2001 From: KevinGilmore Date: Sat, 15 Jul 2017 10:14:47 -0500 Subject: [PATCH 33/89] BAEL-861 README update (#2267) * BAEL-886: Updated README * BAEL-917 Testing with Google Truth Updated README * BAEL-936: adding akka-streams module to parent * BAEL-936: Update README * BAEL-918: Update README * BAEL-980: Update README * BAEL-967: Update README * BAEL-509: Using @GetMapping instead of @RequestMapping with method=GET * BAEL-1005: Update README * BAEL-509: Security and WebSockets (README) * BAEL-861: Intro to Awaitility (README) --- libraries/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/README.md b/libraries/README.md index c7e56db3b8..30f02e5c5a 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -24,6 +24,7 @@ - [Locality-Sensitive Hashing in Java Using Java-LSH](http://www.baeldung.com/locality-sensitive-hashing) - [Apache Commons Collections OrderedMap](http://www.baeldung.com/apache-commons-ordered-map) - [A Guide to Apache Commons DbUtils](http://www.baeldung.com/apache-commons-dbutils) +- [Introduction to Awaitility](http://www.baeldung.com/awaitlity-testing) The libraries module contains examples related to small libraries that are relatively easy to use and does not require any separate module of its own. From 8739094a161da0817093843d5da04825f44ef676 Mon Sep 17 00:00:00 2001 From: Doha2012 Date: Sat, 15 Jul 2017 17:26:13 +0200 Subject: [PATCH 34/89] minor upgrade (#2259) * minor logging fix * spring security sso * use basic auth * use form login * cleanup * cleanup * final cleanup * second client app for sso * spring boot bootstrap * add logic * cleanup * add simple controller * add thymeleaf and security * minor fix * minor fix * add more boot properties * fix live test * fix live test * minor fix * semaphores * fix configuration * kotlin collection * add more collection examples * minor upgrade --- httpclient/pom.xml | 2 +- .../org/baeldung/httpclient/HttpClientPostingLiveTest.java | 2 +- spring-data-mongodb/pom.xml | 2 +- .../org/baeldung/event/CascadeSaveMongoEventListener.java | 4 +++- .../baeldung/event/UserCascadeSaveMongoEventListener.java | 6 ++++-- spring-security-rest/pom.xml | 2 +- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/httpclient/pom.xml b/httpclient/pom.xml index 562b3e9bcd..b7567e0c4b 100644 --- a/httpclient/pom.xml +++ b/httpclient/pom.xml @@ -147,7 +147,7 @@ 2.5.1 4.4.5 - 4.5.2 + 4.5.3 1.6.1 diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientPostingLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientPostingLiveTest.java index ada5667f0b..ad173f9cd8 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientPostingLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientPostingLiveTest.java @@ -33,7 +33,7 @@ import org.junit.Test; * NOTE : Need module spring-rest to be running */ public class HttpClientPostingLiveTest { - private static final String SAMPLE_URL = "http://localhost:8080/spring-rest/users"; + private static final String SAMPLE_URL = "http://localhost:8082/spring-rest/users"; private static final String URL_SECURED_BY_BASIC_AUTHENTICATION = "http://browserspy.dk/password-ok.php"; private static final String DEFAULT_USER = "test"; private static final String DEFAULT_PASS = "test"; diff --git a/spring-data-mongodb/pom.xml b/spring-data-mongodb/pom.xml index 84d49a3e35..7060ec5b36 100644 --- a/spring-data-mongodb/pom.xml +++ b/spring-data-mongodb/pom.xml @@ -115,7 +115,7 @@ 4.3.4.RELEASE - 1.9.6.RELEASE + 1.10.4.RELEASE 2.9.0 4.1.4 diff --git a/spring-data-mongodb/src/main/java/org/baeldung/event/CascadeSaveMongoEventListener.java b/spring-data-mongodb/src/main/java/org/baeldung/event/CascadeSaveMongoEventListener.java index 79840fb570..acc377011d 100644 --- a/spring-data-mongodb/src/main/java/org/baeldung/event/CascadeSaveMongoEventListener.java +++ b/spring-data-mongodb/src/main/java/org/baeldung/event/CascadeSaveMongoEventListener.java @@ -3,6 +3,7 @@ package org.baeldung.event; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.mongodb.core.MongoOperations; import org.springframework.data.mongodb.core.mapping.event.AbstractMongoEventListener; +import org.springframework.data.mongodb.core.mapping.event.BeforeConvertEvent; import org.springframework.util.ReflectionUtils; public class CascadeSaveMongoEventListener extends AbstractMongoEventListener { @@ -11,7 +12,8 @@ public class CascadeSaveMongoEventListener extends AbstractMongoEventListener event) { + final Object source = event.getSource(); ReflectionUtils.doWithFields(source.getClass(), new CascadeCallback(source, mongoOperations)); } } \ No newline at end of file diff --git a/spring-data-mongodb/src/main/java/org/baeldung/event/UserCascadeSaveMongoEventListener.java b/spring-data-mongodb/src/main/java/org/baeldung/event/UserCascadeSaveMongoEventListener.java index 423df59b95..ade20bcc1d 100644 --- a/spring-data-mongodb/src/main/java/org/baeldung/event/UserCascadeSaveMongoEventListener.java +++ b/spring-data-mongodb/src/main/java/org/baeldung/event/UserCascadeSaveMongoEventListener.java @@ -4,14 +4,16 @@ import org.baeldung.model.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.mongodb.core.MongoOperations; import org.springframework.data.mongodb.core.mapping.event.AbstractMongoEventListener; +import org.springframework.data.mongodb.core.mapping.event.BeforeConvertEvent; public class UserCascadeSaveMongoEventListener extends AbstractMongoEventListener { @Autowired private MongoOperations mongoOperations; @Override - public void onBeforeConvert(final Object source) { - if (source instanceof User && ((User) source).getEmailAddress() != null) { + public void onBeforeConvert(final BeforeConvertEvent event) { + final Object source = event.getSource(); + if ((source instanceof User) && (((User) source).getEmailAddress() != null)) { mongoOperations.save(((User) source).getEmailAddress()); } } diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index 64c0160e1f..13db431ae3 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -307,7 +307,7 @@ 2.9.0 - 2.6.1 + 2.7.0 4.4.5 4.5.2 From d8d1171afa10a839ce81e7f6519f8532ac797f82 Mon Sep 17 00:00:00 2001 From: slavisa-baeldung Date: Sat, 15 Jul 2017 18:51:14 +0100 Subject: [PATCH 35/89] BAEL-964 - printing directly to standard output --- .../baeldung/commons/collections/MapUtilsTest.java | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/libraries/src/test/java/com/baeldung/commons/collections/MapUtilsTest.java b/libraries/src/test/java/com/baeldung/commons/collections/MapUtilsTest.java index 470eb46cb0..10d408b467 100644 --- a/libraries/src/test/java/com/baeldung/commons/collections/MapUtilsTest.java +++ b/libraries/src/test/java/com/baeldung/commons/collections/MapUtilsTest.java @@ -63,19 +63,7 @@ public class MapUtilsTest { @Test public void whenVerbosePrintMap_thenMustPrintFormattedMap() { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - PrintStream outPrint = new PrintStream(out); - - outPrint.println("Optional Label = "); - outPrint.println("{"); - outPrint.println(" RED = #FF0000"); - outPrint.println(" BLUE = #0000FF"); - outPrint.println(" GREEN = #00FF00"); - outPrint.println("}"); - - out.reset(); - - MapUtils.verbosePrint(outPrint, "Optional Label", this.colorMap); + MapUtils.verbosePrint(System.out, "Optional Label", this.colorMap); } @Test From b4d3e23c3e568e8e25c8786c5de6337bc84035f1 Mon Sep 17 00:00:00 2001 From: Danil Kornishev Date: Sat, 15 Jul 2017 17:53:57 -0400 Subject: [PATCH 36/89] JMH (#2222) * JMH * JMH --- jmh/pom.xml | 100 ++++++++++-------- .../main/java/com/baeldung/Application.java | 14 --- jmh/src/main/java/com/baeldung/BenchMark.java | 46 +++++++- .../java/com/baeldung/BenchmarkRunner.java | 9 ++ jmh/src/test/java/com/baeldung/AppTest.java | 38 ------- 5 files changed, 104 insertions(+), 103 deletions(-) delete mode 100644 jmh/src/main/java/com/baeldung/Application.java create mode 100644 jmh/src/main/java/com/baeldung/BenchmarkRunner.java delete mode 100644 jmh/src/test/java/com/baeldung/AppTest.java diff --git a/jmh/pom.xml b/jmh/pom.xml index 8ecfaa9651..ef5c3f1bbf 100644 --- a/jmh/pom.xml +++ b/jmh/pom.xml @@ -1,52 +1,60 @@ - 4.0.0 - com.baeldung - jmh - jar - 1.0-SNAPSHOT - jmh - http://maven.apache.org + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + 4.0.0 + com.baeldung + jmh + jar + 1.0-SNAPSHOT + jmh + http://maven.apache.org - - UTF-8 - UTF-8 - 1.8 - + + UTF-8 + UTF-8 + 1.8 + 1.6 + 1.6 + - - - org.openjdk.jmh - jmh-core - 1.19 - - - org.openjdk.jmh - jmh-generator-annprocess - 1.19 - - - junit - junit - 3.8.1 - test - - + + + org.openjdk.jmh + jmh-core + 1.19 + + + org.openjdk.jmh + jmh-generator-annprocess + 1.19 + + + junit + junit + 3.8.1 + test + - - - - org.apache.maven.plugins - maven-jar-plugin - - - - com.baeldung.Application - - - - - - + + com.google.guava + guava + 21.0 + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + com.baeldung.BenchmarkRunner + + + + + + \ No newline at end of file diff --git a/jmh/src/main/java/com/baeldung/Application.java b/jmh/src/main/java/com/baeldung/Application.java deleted file mode 100644 index 28e70740e0..0000000000 --- a/jmh/src/main/java/com/baeldung/Application.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.baeldung; - -import java.io.IOException; - -import org.openjdk.jmh.Main; -import org.openjdk.jmh.runner.RunnerException; - -public class Application { - - public static void main(String[] args) throws RunnerException, IOException { - Main.main(args); - } - -} diff --git a/jmh/src/main/java/com/baeldung/BenchMark.java b/jmh/src/main/java/com/baeldung/BenchMark.java index f2b984d211..b0e1caf4dc 100644 --- a/jmh/src/main/java/com/baeldung/BenchMark.java +++ b/jmh/src/main/java/com/baeldung/BenchMark.java @@ -1,12 +1,48 @@ package com.baeldung; -import org.openjdk.jmh.annotations.Benchmark; +import com.google.common.hash.HashFunction; +import com.google.common.hash.Hasher; +import com.google.common.hash.Hashing; +import org.openjdk.jmh.annotations.*; + +import java.nio.charset.Charset; public class BenchMark { - @Benchmark - public void init() { - - } + @State(Scope.Benchmark) + public static class ExecutionPlan { + + @Param({ "100", "200", "300", "500", "1000" }) + public int iterations; + + public Hasher murmur3; + + public String password = "4v3rys3kur3p455w0rd"; + + @Setup(Level.Invocation) + public void setUp() { + murmur3 = Hashing.murmur3_128().newHasher(); + } + } + + @Fork(value = 1, warmups = 1) + @Benchmark + @BenchmarkMode(Mode.Throughput) + @Warmup(iterations = 5) + public void benchMurmur3_128(ExecutionPlan plan) { + + for (int i = plan.iterations; i > 0; i--) { + plan.murmur3.putString(plan.password, Charset.defaultCharset()); + } + + plan.murmur3.hash(); + } + + @Benchmark + @Fork(value = 1, warmups = 1) + @BenchmarkMode(Mode.Throughput) + public void init() { + // Do nothing + } } diff --git a/jmh/src/main/java/com/baeldung/BenchmarkRunner.java b/jmh/src/main/java/com/baeldung/BenchmarkRunner.java new file mode 100644 index 0000000000..ed6a5bb617 --- /dev/null +++ b/jmh/src/main/java/com/baeldung/BenchmarkRunner.java @@ -0,0 +1,9 @@ +package com.baeldung; + +public class BenchmarkRunner { + + public static void main(String[] args) throws Exception { + org.openjdk.jmh.Main.main(args); + } + +} diff --git a/jmh/src/test/java/com/baeldung/AppTest.java b/jmh/src/test/java/com/baeldung/AppTest.java deleted file mode 100644 index c9f61455bd..0000000000 --- a/jmh/src/test/java/com/baeldung/AppTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.baeldung; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Unit test for simple App. - */ -public class AppTest - extends TestCase -{ - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) - { - super( testName ); - } - - /** - * @return the suite of tests being tested - */ - public static Test suite() - { - return new TestSuite( AppTest.class ); - } - - /** - * Rigourous Test :-) - */ - public void testApp() - { - assertTrue( true ); - } -} From dc0d802cd905d6c15632524ab2e4ebc3e6bb561f Mon Sep 17 00:00:00 2001 From: dhruba619 Date: Sun, 16 Jul 2017 12:36:17 +0530 Subject: [PATCH 37/89] BAEL-982 Spring-boot mustache initial commit --- spring-mustache/.gitignore | 24 ++++++++ spring-mustache/pom.xml | 60 +++++++++++++++++++ .../SpringMustacheApplication.java | 34 +++++++++++ .../controller/ArticleController.java | 50 ++++++++++++++++ .../springmustache/model/Article.java | 41 +++++++++++++ .../src/main/resources/application.properties | 0 .../main/resources/templates/error/error.html | 9 +++ .../src/main/resources/templates/index.html | 9 +++ .../resources/templates/layout/article.html | 8 +++ .../resources/templates/layout/footer.html | 2 + .../resources/templates/layout/header.html | 11 ++++ .../SpringMustacheApplicationTests.java | 32 ++++++++++ 12 files changed, 280 insertions(+) create mode 100644 spring-mustache/.gitignore create mode 100644 spring-mustache/pom.xml create mode 100644 spring-mustache/src/main/java/com/baeldung/springmustache/SpringMustacheApplication.java create mode 100644 spring-mustache/src/main/java/com/baeldung/springmustache/controller/ArticleController.java create mode 100644 spring-mustache/src/main/java/com/baeldung/springmustache/model/Article.java create mode 100644 spring-mustache/src/main/resources/application.properties create mode 100644 spring-mustache/src/main/resources/templates/error/error.html create mode 100644 spring-mustache/src/main/resources/templates/index.html create mode 100644 spring-mustache/src/main/resources/templates/layout/article.html create mode 100644 spring-mustache/src/main/resources/templates/layout/footer.html create mode 100644 spring-mustache/src/main/resources/templates/layout/header.html create mode 100644 spring-mustache/src/test/java/com/baeldung/springmustache/SpringMustacheApplicationTests.java diff --git a/spring-mustache/.gitignore b/spring-mustache/.gitignore new file mode 100644 index 0000000000..2af7cefb0a --- /dev/null +++ b/spring-mustache/.gitignore @@ -0,0 +1,24 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +nbproject/private/ +build/ +nbbuild/ +dist/ +nbdist/ +.nb-gradle/ \ No newline at end of file diff --git a/spring-mustache/pom.xml b/spring-mustache/pom.xml new file mode 100644 index 0000000000..e671672b72 --- /dev/null +++ b/spring-mustache/pom.xml @@ -0,0 +1,60 @@ + + + 4.0.0 + + com.baeldung + spring-mustache + 0.0.1-SNAPSHOT + jar + + spring-mustache + Demo project for Spring Boot + + + org.springframework.boot + spring-boot-starter-parent + 1.5.4.RELEASE + + + + + UTF-8 + UTF-8 + 1.8 + + + + + org.springframework.boot + spring-boot-starter-mustache + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.webjars + bootstrap + 3.3.7 + + + org.fluttercode.datafactory + datafactory + 0.8 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + diff --git a/spring-mustache/src/main/java/com/baeldung/springmustache/SpringMustacheApplication.java b/spring-mustache/src/main/java/com/baeldung/springmustache/SpringMustacheApplication.java new file mode 100644 index 0000000000..d4338ffd7d --- /dev/null +++ b/spring-mustache/src/main/java/com/baeldung/springmustache/SpringMustacheApplication.java @@ -0,0 +1,34 @@ +package com.baeldung.springmustache; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.mustache.MustacheEnvironmentCollector; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.core.env.Environment; + +import com.samskivert.mustache.Mustache; + +@SpringBootApplication +@ComponentScan(basePackages = { "com.baeldung" }) +public class SpringMustacheApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringMustacheApplication.class, args); + } + + @Bean + public Mustache.Compiler mustacheCompiler(Mustache.TemplateLoader templateLoader, Environment environment) { + + MustacheEnvironmentCollector collector = new MustacheEnvironmentCollector(); + collector.setEnvironment(environment); + + Mustache.Compiler compiler = Mustache.compiler() + .defaultValue("Some Default Value") + .withLoader(templateLoader) + .withCollector(collector); + return compiler; + + } +} + diff --git a/spring-mustache/src/main/java/com/baeldung/springmustache/controller/ArticleController.java b/spring-mustache/src/main/java/com/baeldung/springmustache/controller/ArticleController.java new file mode 100644 index 0000000000..e0db127d66 --- /dev/null +++ b/spring-mustache/src/main/java/com/baeldung/springmustache/controller/ArticleController.java @@ -0,0 +1,50 @@ +package com.baeldung.springmustache.controller; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; +import java.util.stream.IntStream; + +import org.fluttercode.datafactory.impl.DataFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.ModelAndView; + +import com.baeldung.springmustache.model.Article; + +@Controller +public class ArticleController { + + @RequestMapping("/article") + public ModelAndView displayArticle(Map model) { + + List
articles = new LinkedList<>(); + IntStream.range(0, 10) + .forEach(count -> { + articles.add(generateArticle("Article Title "+count)); + }); + + Map modelMap = new HashMap<>(); + modelMap.put("articles", articles); + + return new ModelAndView("index", modelMap); + } + + private Article generateArticle(String title) { + Article article = new Article(); + DataFactory factory = new DataFactory(); + article.setTitle(title); + article.setBody( + "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur faucibus tempor diam. In molestie arcu eget ante facilisis sodales. Maecenas porta tellus sapien, eget rutrum nisi blandit in. Mauris tempor auctor ante, ut blandit velit venenatis id. Ut varius, augue aliquet feugiat congue, arcu ipsum finibus purus, dapibus semper velit sapien venenatis magna. Nunc quam ex, aliquet at rutrum sed, vestibulum quis libero. In laoreet libero cursus maximus vulputate. Nullam in fermentum sem. Duis aliquam ullamcorper dui, et dictum justo placerat id. Aliquam pretium orci quis sapien convallis, non blandit est tempus."); + article.setPublishDate(factory.getBirthDate() + .toString()); + article.setAuthor(factory.getName()); + return article; + + } +} + + diff --git a/spring-mustache/src/main/java/com/baeldung/springmustache/model/Article.java b/spring-mustache/src/main/java/com/baeldung/springmustache/model/Article.java new file mode 100644 index 0000000000..78b08f877f --- /dev/null +++ b/spring-mustache/src/main/java/com/baeldung/springmustache/model/Article.java @@ -0,0 +1,41 @@ +package com.baeldung.springmustache.model; + +public class Article { + private String title; + private String body; + private String author; + private String publishDate; + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getBody() { + return body; + } + + public void setBody(String body) { + this.body = body; + } + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } + + public String getPublishDate() { + return publishDate; + } + + public void setPublishDate(String publishDate) { + this.publishDate = publishDate; + } + +} diff --git a/spring-mustache/src/main/resources/application.properties b/spring-mustache/src/main/resources/application.properties new file mode 100644 index 0000000000..e69de29bb2 diff --git a/spring-mustache/src/main/resources/templates/error/error.html b/spring-mustache/src/main/resources/templates/error/error.html new file mode 100644 index 0000000000..fa29db41c4 --- /dev/null +++ b/spring-mustache/src/main/resources/templates/error/error.html @@ -0,0 +1,9 @@ + + + + + + Something went wrong: {{status}} {{error}} + + + \ No newline at end of file diff --git a/spring-mustache/src/main/resources/templates/index.html b/spring-mustache/src/main/resources/templates/index.html new file mode 100644 index 0000000000..bda60f9d8f --- /dev/null +++ b/spring-mustache/src/main/resources/templates/index.html @@ -0,0 +1,9 @@ +{{>layout/header}} + +
{{>layout/article}}
+ + + + +{{>layout/footer}} diff --git a/spring-mustache/src/main/resources/templates/layout/article.html b/spring-mustache/src/main/resources/templates/layout/article.html new file mode 100644 index 0000000000..9d573580d3 --- /dev/null +++ b/spring-mustache/src/main/resources/templates/layout/article.html @@ -0,0 +1,8 @@ +
+ {{#articles}} +

{{title}}

+

{{publishDate}}

+

{{author}}

+

{{body}}

+ {{/articles}} +
\ No newline at end of file diff --git a/spring-mustache/src/main/resources/templates/layout/footer.html b/spring-mustache/src/main/resources/templates/layout/footer.html new file mode 100644 index 0000000000..04f34cac54 --- /dev/null +++ b/spring-mustache/src/main/resources/templates/layout/footer.html @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/spring-mustache/src/main/resources/templates/layout/header.html b/spring-mustache/src/main/resources/templates/layout/header.html new file mode 100644 index 0000000000..d203ef800b --- /dev/null +++ b/spring-mustache/src/main/resources/templates/layout/header.html @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/spring-mustache/src/test/java/com/baeldung/springmustache/SpringMustacheApplicationTests.java b/spring-mustache/src/test/java/com/baeldung/springmustache/SpringMustacheApplicationTests.java new file mode 100644 index 0000000000..4a72d4156e --- /dev/null +++ b/spring-mustache/src/test/java/com/baeldung/springmustache/SpringMustacheApplicationTests.java @@ -0,0 +1,32 @@ +package com.baeldung.springmustache; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +public class SpringMustacheApplicationTests { + + @Autowired + private TestRestTemplate restTemplate; + + @Test + public void givenIndexPageWhenContainsArticleThenTrue() { + + ResponseEntity entity = this.restTemplate.getForEntity("/article", String.class); + Assert.assertTrue(entity.getStatusCode() + .equals(HttpStatus.OK)); + Assert.assertTrue(entity.getBody() + .contains("Article Title 0")); + + } + +} From f05345112f95e9e282dc4ce169787fbf941d676b Mon Sep 17 00:00:00 2001 From: Sarf Khan Date: Sun, 16 Jul 2017 21:39:35 +0530 Subject: [PATCH 38/89] Spring rest logging Log incoming request --- spring-rest-logging/pom.xml | 64 +++++++++++++++++++ .../baeldung/rest/log/app/Application.java | 18 ++++++ .../log/app/TaxiFareRequestInterceptor.java | 27 ++++++++ .../config/RequestLoggingFilterConfig.java | 23 +++++++ .../rest/log/config/TaxiFareMVCConfig.java | 20 ++++++ .../log/controller/TaxiFareController.java | 40 ++++++++++++ .../com/baeldung/rest/log/data/RateCard.java | 28 ++++++++ .../com/baeldung/rest/log/data/TaxiRide.java | 32 ++++++++++ .../service/TaxiFareCalculatorService.java | 20 ++++++ .../src/main/resources/application.properties | 2 + .../src/main/resources/logback.xml | 21 ++++++ .../controller/TestTaxiFareController.java | 33 ++++++++++ 12 files changed, 328 insertions(+) create mode 100644 spring-rest-logging/pom.xml create mode 100644 spring-rest-logging/src/main/java/com/baeldung/rest/log/app/Application.java create mode 100644 spring-rest-logging/src/main/java/com/baeldung/rest/log/app/TaxiFareRequestInterceptor.java create mode 100644 spring-rest-logging/src/main/java/com/baeldung/rest/log/config/RequestLoggingFilterConfig.java create mode 100644 spring-rest-logging/src/main/java/com/baeldung/rest/log/config/TaxiFareMVCConfig.java create mode 100644 spring-rest-logging/src/main/java/com/baeldung/rest/log/controller/TaxiFareController.java create mode 100644 spring-rest-logging/src/main/java/com/baeldung/rest/log/data/RateCard.java create mode 100644 spring-rest-logging/src/main/java/com/baeldung/rest/log/data/TaxiRide.java create mode 100644 spring-rest-logging/src/main/java/com/baeldung/rest/log/service/TaxiFareCalculatorService.java create mode 100644 spring-rest-logging/src/main/resources/application.properties create mode 100644 spring-rest-logging/src/main/resources/logback.xml create mode 100644 spring-rest-logging/src/test/java/com/baeldung/rest/log/controller/TestTaxiFareController.java diff --git a/spring-rest-logging/pom.xml b/spring-rest-logging/pom.xml new file mode 100644 index 0000000000..5924650e5f --- /dev/null +++ b/spring-rest-logging/pom.xml @@ -0,0 +1,64 @@ + + 4.0.0 + com.baeldung + spring-rest-logging + 0.1-SNAPSHOT + spring-rest-logging + war + + + org.springframework.boot + spring-boot-starter-parent + 1.4.3.RELEASE + + + + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + + + org.springframework.boot + spring-boot-test + + + + + org.springframework + spring-web + + + commons-logging + commons-logging + + + + + org.springframework + spring-webmvc + + + + + + javax.servlet + javax.servlet-api + provided + + + + junit + junit + test + + + + org.springframework + spring-test + + + diff --git a/spring-rest-logging/src/main/java/com/baeldung/rest/log/app/Application.java b/spring-rest-logging/src/main/java/com/baeldung/rest/log/app/Application.java new file mode 100644 index 0000000000..9eb79ee1b1 --- /dev/null +++ b/spring-rest-logging/src/main/java/com/baeldung/rest/log/app/Application.java @@ -0,0 +1,18 @@ +package com.baeldung.rest.log.app; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.support.SpringBootServletInitializer; +import org.springframework.context.annotation.ComponentScan; + +@EnableAutoConfiguration +@ComponentScan("com.baeldung") +@SpringBootApplication +public class Application extends SpringBootServletInitializer { + + public static void main(final String[] args) { + SpringApplication.run(Application.class, args); + } + +} \ No newline at end of file diff --git a/spring-rest-logging/src/main/java/com/baeldung/rest/log/app/TaxiFareRequestInterceptor.java b/spring-rest-logging/src/main/java/com/baeldung/rest/log/app/TaxiFareRequestInterceptor.java new file mode 100644 index 0000000000..bc011a4db7 --- /dev/null +++ b/spring-rest-logging/src/main/java/com/baeldung/rest/log/app/TaxiFareRequestInterceptor.java @@ -0,0 +1,27 @@ +package com.baeldung.rest.log.app; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; + +@Component +public class TaxiFareRequestInterceptor extends HandlerInterceptorAdapter { + + Logger LOGGER = LoggerFactory.getLogger(TaxiFareRequestInterceptor.class); + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + LOGGER.info("REQUEST URI: " + request.getRequestURI()); + return true; + } + + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { + LOGGER.info("RESPONSE: " + response.getStatus()); + } + +} diff --git a/spring-rest-logging/src/main/java/com/baeldung/rest/log/config/RequestLoggingFilterConfig.java b/spring-rest-logging/src/main/java/com/baeldung/rest/log/config/RequestLoggingFilterConfig.java new file mode 100644 index 0000000000..158ba51f77 --- /dev/null +++ b/spring-rest-logging/src/main/java/com/baeldung/rest/log/config/RequestLoggingFilterConfig.java @@ -0,0 +1,23 @@ +package com.baeldung.rest.log.config; + +import javax.servlet.annotation.WebFilter; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.filter.CommonsRequestLoggingFilter; + +@Configuration +@WebFilter +public class RequestLoggingFilterConfig { + + @Bean + public CommonsRequestLoggingFilter logFilter() { + CommonsRequestLoggingFilter filter = new CommonsRequestLoggingFilter(); + filter.setIncludeQueryString(true); + filter.setIncludePayload(true); + filter.setMaxPayloadLength(10000); + filter.setIncludeHeaders(false); + filter.setAfterMessagePrefix("REQUEST DATA : "); + return filter; + } +} diff --git a/spring-rest-logging/src/main/java/com/baeldung/rest/log/config/TaxiFareMVCConfig.java b/spring-rest-logging/src/main/java/com/baeldung/rest/log/config/TaxiFareMVCConfig.java new file mode 100644 index 0000000000..71d0fd379f --- /dev/null +++ b/spring-rest-logging/src/main/java/com/baeldung/rest/log/config/TaxiFareMVCConfig.java @@ -0,0 +1,20 @@ +package com.baeldung.rest.log.config; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +import com.baeldung.rest.log.app.TaxiFareRequestInterceptor; + +@Configuration +public class TaxiFareMVCConfig extends WebMvcConfigurerAdapter { + + @Autowired + private TaxiFareRequestInterceptor taxiFareRequestInterceptor; + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(taxiFareRequestInterceptor).addPathPatterns("/**/taxifare/**/"); + } +} diff --git a/spring-rest-logging/src/main/java/com/baeldung/rest/log/controller/TaxiFareController.java b/spring-rest-logging/src/main/java/com/baeldung/rest/log/controller/TaxiFareController.java new file mode 100644 index 0000000000..0d8e4dafa4 --- /dev/null +++ b/spring-rest-logging/src/main/java/com/baeldung/rest/log/controller/TaxiFareController.java @@ -0,0 +1,40 @@ +package com.baeldung.rest.log.controller; + +import javax.validation.Valid; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +import com.baeldung.rest.log.data.RateCard; +import com.baeldung.rest.log.data.TaxiRide; +import com.baeldung.rest.log.service.TaxiFareCalculatorService; + +@Controller +public class TaxiFareController { + + @Autowired + private TaxiFareCalculatorService taxiFareCalculatorService; + + private static final Logger LOGGER = LoggerFactory.getLogger(TaxiFareController.class); + + @RequestMapping(method = RequestMethod.GET, value = "/taxifare/get/") + @ResponseBody + public RateCard getTaxiFare() { + LOGGER.debug("getTaxiFare() - START"); + return new RateCard(); + } + + @RequestMapping(method = RequestMethod.POST, value = "/taxifare/calculate/") + @ResponseBody + public String calculateTaxiFare(@RequestBody @Valid TaxiRide taxiRide) { + LOGGER.debug("calculateTaxiFare() - START"); + return taxiFareCalculatorService.calculateFare(taxiRide); + } + +} diff --git a/spring-rest-logging/src/main/java/com/baeldung/rest/log/data/RateCard.java b/spring-rest-logging/src/main/java/com/baeldung/rest/log/data/RateCard.java new file mode 100644 index 0000000000..6e0c6d0e38 --- /dev/null +++ b/spring-rest-logging/src/main/java/com/baeldung/rest/log/data/RateCard.java @@ -0,0 +1,28 @@ +package com.baeldung.rest.log.data; + +public class RateCard { + + private String nightSurcharge; + private String ratePerMile; + + public RateCard(){ + nightSurcharge="Extra $ 100"; + ratePerMile="$ 10 Per Mile"; + } + + + public String getNightSurcharge() { + return nightSurcharge; + } + public void setNightSurcharge(String nightSurcharge) { + this.nightSurcharge = nightSurcharge; + } + public String getRatePerMile() { + return ratePerMile; + } + public void setRatePerMile(String ratePerMile) { + this.ratePerMile = ratePerMile; + } + + +} diff --git a/spring-rest-logging/src/main/java/com/baeldung/rest/log/data/TaxiRide.java b/spring-rest-logging/src/main/java/com/baeldung/rest/log/data/TaxiRide.java new file mode 100644 index 0000000000..bcf102e49d --- /dev/null +++ b/spring-rest-logging/src/main/java/com/baeldung/rest/log/data/TaxiRide.java @@ -0,0 +1,32 @@ +package com.baeldung.rest.log.data; + +public class TaxiRide { + + private Boolean isNightSurcharge; + private Long distanceInMile; + + public TaxiRide(){} + + public TaxiRide(Boolean isNightSurcharge, Long distanceInMile){ + this.isNightSurcharge = isNightSurcharge; + this.distanceInMile = distanceInMile; + } + + + public Boolean getIsNightSurcharge() { + return isNightSurcharge; + } + + public void setIsNightSurcharge(Boolean isNightSurcharge) { + this.isNightSurcharge = isNightSurcharge; + } + + public Long getDistanceInMile() { + return distanceInMile; + } + + public void setDistanceInMile(Long distanceInMile) { + this.distanceInMile = distanceInMile; + } + +} diff --git a/spring-rest-logging/src/main/java/com/baeldung/rest/log/service/TaxiFareCalculatorService.java b/spring-rest-logging/src/main/java/com/baeldung/rest/log/service/TaxiFareCalculatorService.java new file mode 100644 index 0000000000..31dfd7ac50 --- /dev/null +++ b/spring-rest-logging/src/main/java/com/baeldung/rest/log/service/TaxiFareCalculatorService.java @@ -0,0 +1,20 @@ +package com.baeldung.rest.log.service; + +import org.springframework.stereotype.Service; + +import com.baeldung.rest.log.data.TaxiRide; + +@Service +public class TaxiFareCalculatorService { + + public String calculateFare(TaxiRide taxiRide) { + Long fare = 0l; + if (taxiRide.getIsNightSurcharge()) { + fare = taxiRide.getDistanceInMile() * 10 + 100; + } else { + fare = taxiRide.getDistanceInMile() * 10; + } + return String.valueOf(fare); + } + +} diff --git a/spring-rest-logging/src/main/resources/application.properties b/spring-rest-logging/src/main/resources/application.properties new file mode 100644 index 0000000000..ff8a818e66 --- /dev/null +++ b/spring-rest-logging/src/main/resources/application.properties @@ -0,0 +1,2 @@ +server.port= 9090 +server.context-path=/rest-log diff --git a/spring-rest-logging/src/main/resources/logback.xml b/spring-rest-logging/src/main/resources/logback.xml new file mode 100644 index 0000000000..08117752c7 --- /dev/null +++ b/spring-rest-logging/src/main/resources/logback.xml @@ -0,0 +1,21 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-rest-logging/src/test/java/com/baeldung/rest/log/controller/TestTaxiFareController.java b/spring-rest-logging/src/test/java/com/baeldung/rest/log/controller/TestTaxiFareController.java new file mode 100644 index 0000000000..61d279a0c5 --- /dev/null +++ b/spring-rest-logging/src/test/java/com/baeldung/rest/log/controller/TestTaxiFareController.java @@ -0,0 +1,33 @@ +package com.baeldung.rest.log.controller; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.Test; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; + +import com.baeldung.rest.log.data.TaxiRide; + +public class TestTaxiFareController { + + private static final String URL = "http://localhost:" + 9090 + "/rest-log/taxifare/"; + + @Test + public void given_taxi_fare_get() { + TestRestTemplate testRestTemplate = new TestRestTemplate(); + ResponseEntity response = testRestTemplate.getForEntity(URL + "get/", String.class); + assertThat(response.getStatusCode(), equalTo(HttpStatus.OK)); + } + + @Test + public void given_taxi_ride_get_fare() { + TestRestTemplate testRestTemplate = new TestRestTemplate(); + TaxiRide taxiRide = new TaxiRide(true,10l); + String fare = testRestTemplate.postForObject(URL + "calculate/", taxiRide,String.class); + assertThat(fare, equalTo("200")); + } + + +} From fb7d3fe8f49a896fc10af06f9ea2a095c85161c1 Mon Sep 17 00:00:00 2001 From: Tomasz Lelek Date: Mon, 17 Jul 2017 06:10:55 +0200 Subject: [PATCH 39/89] Bael 1010 hll (#2274) * BAEL-1010 HLL article code * BAEL-1010 moved tolerated difference to a variable * Merge branch 'master' of https://github.com/eugenp/tutorials into BAEL-1010_hll # Conflicts: # libraries/pom.xml * BAEL-1010 clearer code * use isCloseTo --- .../java/com/baeldung/hll/HLLUnitTest.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/libraries/src/test/java/com/baeldung/hll/HLLUnitTest.java b/libraries/src/test/java/com/baeldung/hll/HLLUnitTest.java index 2745e1e681..8d09c99f0f 100644 --- a/libraries/src/test/java/com/baeldung/hll/HLLUnitTest.java +++ b/libraries/src/test/java/com/baeldung/hll/HLLUnitTest.java @@ -4,6 +4,7 @@ package com.baeldung.hll; import com.google.common.hash.HashFunction; import com.google.common.hash.Hashing; import net.agkn.hll.HLL; +import org.assertj.core.data.Offset; import org.junit.Test; import java.util.stream.LongStream; @@ -15,8 +16,8 @@ public class HLLUnitTest { @Test public void givenHLL_whenAddHugeAmountOfNumbers_thenShouldReturnEstimatedCardinality() { //given - int numberOfElements = 100_000_000; - int toleratedDifference = 1_000_000; + long numberOfElements = 100_000_000; + long toleratedDifference = 1_000_000; HashFunction hashFunction = Hashing.murmur3_128(); HLL hll = new HLL(14, 5); @@ -29,14 +30,14 @@ public class HLLUnitTest { //then long cardinality = hll.cardinality(); - assertThat(isSimilarTo(cardinality, numberOfElements, toleratedDifference)).isTrue(); + assertThat(cardinality).isCloseTo(numberOfElements, Offset.offset(toleratedDifference)); } @Test public void givenTwoHLLs_whenAddHugeAmountOfNumbers_thenShouldReturnEstimatedCardinalityForUnionOfHLLs() { //given - int numberOfElements = 100_000_000; - int toleratedDifference = 1_000_000; + long numberOfElements = 100_000_000; + long toleratedDifference = 1_000_000; HashFunction hashFunction = Hashing.murmur3_128(); HLL firstHll = new HLL(15, 5); HLL secondHLL = new HLL(15, 5); @@ -57,12 +58,6 @@ public class HLLUnitTest { //then firstHll.union(secondHLL); long cardinality = firstHll.cardinality(); - assertThat(isSimilarTo(cardinality, numberOfElements * 2, - toleratedDifference * 2)).isTrue(); - } - - private boolean isSimilarTo(long cardinality, int numberOfElements, int maxToleratedDifference) { - System.out.println(cardinality); - return Math.abs(cardinality - numberOfElements) <= maxToleratedDifference; + assertThat(cardinality).isCloseTo(numberOfElements * 2, Offset.offset(toleratedDifference * 2)); } } From fe39bc6c3d7a6da466d913d6ff1919883a3b20b2 Mon Sep 17 00:00:00 2001 From: baljeet20 Date: Mon, 17 Jul 2017 20:13:22 +0530 Subject: [PATCH 40/89] BAEL-1024 Introduction to MockServer (#2275) --- mockserver/pom.xml | 41 ++++ .../server/ExpectationCallbackHandler.java | 23 +++ .../baeldung/mock/server/TestMockServer.java | 178 ++++++++++++++++++ pom.xml | 1 + 4 files changed, 243 insertions(+) create mode 100644 mockserver/pom.xml create mode 100644 mockserver/src/main/java/com/baeldung/mock/server/ExpectationCallbackHandler.java create mode 100644 mockserver/src/test/java/com/baeldung/mock/server/TestMockServer.java diff --git a/mockserver/pom.xml b/mockserver/pom.xml new file mode 100644 index 0000000000..a3ca5459c9 --- /dev/null +++ b/mockserver/pom.xml @@ -0,0 +1,41 @@ + + + 4.0.0 + + com.baeldung + mockserver + 1.0.0-SNAPSHOT + + 3.10.8 + 4.4.1 + + + + + org.mock-server + mockserver-netty + ${mock-sever-netty-version} + + + + org.mock-server + mockserver-client-java + ${mock-sever-netty-version} + + + + org.apache.httpcomponents + httpclient + ${apche-http-version} + + + org.apache.httpcomponents + httpcore + ${apche-http-version} + + + + + \ No newline at end of file diff --git a/mockserver/src/main/java/com/baeldung/mock/server/ExpectationCallbackHandler.java b/mockserver/src/main/java/com/baeldung/mock/server/ExpectationCallbackHandler.java new file mode 100644 index 0000000000..a74dca28da --- /dev/null +++ b/mockserver/src/main/java/com/baeldung/mock/server/ExpectationCallbackHandler.java @@ -0,0 +1,23 @@ +package com.baeldung.mock.server; + +import org.mockserver.mock.action.ExpectationCallback; +import org.mockserver.model.HttpRequest; +import org.mockserver.model.HttpResponse; + +import static org.mockserver.model.HttpResponse.notFoundResponse; +import static org.mockserver.model.HttpResponse.response; + + +public class ExpectationCallbackHandler implements ExpectationCallback { + + public HttpResponse handle(HttpRequest httpRequest) { + if (httpRequest.getPath().getValue().endsWith("/callback")) { + return httpResponse; + } else { + return notFoundResponse(); + } + } + + public static HttpResponse httpResponse = response() + .withStatusCode(200); +} diff --git a/mockserver/src/test/java/com/baeldung/mock/server/TestMockServer.java b/mockserver/src/test/java/com/baeldung/mock/server/TestMockServer.java new file mode 100644 index 0000000000..aea1b8b278 --- /dev/null +++ b/mockserver/src/test/java/com/baeldung/mock/server/TestMockServer.java @@ -0,0 +1,178 @@ +package com.baeldung.mock.server; + +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.HttpClientBuilder; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockserver.client.server.MockServerClient; +import org.mockserver.integration.ClientAndProxy; +import org.mockserver.integration.ClientAndServer; +import org.mockserver.model.Header; +import org.mockserver.model.HttpForward; +import org.mockserver.verify.VerificationTimes; + +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +import static junit.framework.Assert.assertEquals; +import static org.mockserver.integration.ClientAndProxy.startClientAndProxy; +import static org.mockserver.integration.ClientAndServer.startClientAndServer; +import static org.mockserver.matchers.Times.exactly; +import static org.mockserver.model.HttpClassCallback.callback; +import static org.mockserver.model.HttpForward.forward; +import static org.mockserver.model.HttpRequest.request; +import static org.mockserver.model.HttpResponse.response; +import static org.mockserver.model.StringBody.exact; + +public class TestMockServer { + + private ClientAndProxy proxy; + private ClientAndServer mockServer; + + @Before + public void startProxy() { + mockServer = startClientAndServer(1080); + proxy = startClientAndProxy(1090); + } + + + @Test + public void whenPostRequestMockServer_thenServerReceived(){ + createExpectationForInvalidAuth(); + hitTheServerWithPostRequest(); + verifyPostRequest(); + } + + @Test + public void whenPostRequestForInvalidAuth_then401Received(){ + createExpectationForInvalidAuth(); + org.apache.http.HttpResponse response = hitTheServerWithPostRequest(); + assertEquals(401, response.getStatusLine().getStatusCode()); + } + + @Test + public void whenGetRequest_ThenForward(){ + createExpectationForForward(); + hitTheServerWithGetRequest("index.html"); + verifyGetRequest(); + + } + + @Test + public void whenCallbackRequest_ThenCallbackMethodCalled(){ + createExpectationForCallBack(); + org.apache.http.HttpResponse response= hitTheServerWithGetRequest("/callback"); + assertEquals(200,response.getStatusLine().getStatusCode()); + } + + private void verifyPostRequest() { + new MockServerClient("localhost", 1080).verify( + request() + .withMethod("POST") + .withPath("/validate") + .withBody(exact("{username: 'foo', password: 'bar'}")), + VerificationTimes.exactly(1) + ); + } + private void verifyGetRequest() { + new MockServerClient("localhost", 1080).verify( + request() + .withMethod("GET") + .withPath("/index.html"), + VerificationTimes.exactly(1) + ); + } + + private org.apache.http.HttpResponse hitTheServerWithPostRequest() { + String url = "http://127.0.0.1:1080/validate"; + HttpClient client = HttpClientBuilder.create().build(); + HttpPost post = new HttpPost(url); + post.setHeader("Content-type", "application/json"); + org.apache.http.HttpResponse response=null; + + try { + StringEntity stringEntity = new StringEntity("{username: 'foo', password: 'bar'}"); + post.getRequestLine(); + post.setEntity(stringEntity); + response=client.execute(post); + + } catch (Exception e) { + throw new RuntimeException(e); + } + return response; + } + + private org.apache.http.HttpResponse hitTheServerWithGetRequest(String page) { + String url = "http://127.0.0.1:1080/"+page; + HttpClient client = HttpClientBuilder.create().build(); + org.apache.http.HttpResponse response=null; + HttpGet get = new HttpGet(url); + try { + response=client.execute(get); + } catch (IOException e) { + throw new RuntimeException(e); + } + + return response; + } + + private void createExpectationForInvalidAuth() { + new MockServerClient("127.0.0.1", 1080) + .when( + request() + .withMethod("POST") + .withPath("/validate") + .withHeader("\"Content-type\", \"application/json\"") + .withBody(exact("{username: 'foo', password: 'bar'}")), + exactly(1) + ) + .respond( + response() + .withStatusCode(401) + .withHeaders( + new Header("Content-Type", "application/json; charset=utf-8"), + new Header("Cache-Control", "public, max-age=86400") + ) + .withBody("{ message: 'incorrect username and password combination' }") + .withDelay(TimeUnit.SECONDS,1) + ); + } + + private void createExpectationForForward(){ + new MockServerClient("127.0.0.1", 1080) + .when( + request() + .withMethod("GET") + .withPath("/index.html"), + exactly(1) + ) + .forward( + forward() + .withHost("www.mock-server.com") + .withPort(80) + .withScheme(HttpForward.Scheme.HTTP) + ); + } + + private void createExpectationForCallBack(){ + mockServer + .when( + request() + .withPath("/callback") + ) + .callback( + callback() + .withCallbackClass("com.baeldung.mock.server.ExpectationCallbackHandler") + ); + } + + @After + public void stopProxy() { + proxy.stop(); + mockServer.stop(); + } +} diff --git a/pom.xml b/pom.xml index d01134fb30..f0a331e3bd 100644 --- a/pom.xml +++ b/pom.xml @@ -230,6 +230,7 @@ drools liquibase spring-boot-property-exp + mockserver From 59cb7db53e660ac324411476fd18213098d5db88 Mon Sep 17 00:00:00 2001 From: slavisa-baeldung Date: Mon, 17 Jul 2017 19:12:24 +0100 Subject: [PATCH 41/89] BAEL-982 - reformatting --- spring-mustache/pom.xml | 97 ++++++++++--------- .../SpringMustacheApplication.java | 8 +- .../controller/ArticleController.java | 12 +-- .../SpringMustacheApplicationTests.java | 6 +- 4 files changed, 60 insertions(+), 63 deletions(-) diff --git a/spring-mustache/pom.xml b/spring-mustache/pom.xml index e671672b72..45fee6b10e 100644 --- a/spring-mustache/pom.xml +++ b/spring-mustache/pom.xml @@ -1,60 +1,61 @@ - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - com.baeldung - spring-mustache - 0.0.1-SNAPSHOT - jar + com.baeldung + spring-mustache + 0.0.1-SNAPSHOT + jar - spring-mustache - Demo project for Spring Boot + spring-mustache + Demo project for Spring Boot - - org.springframework.boot - spring-boot-starter-parent - 1.5.4.RELEASE - - + + org.springframework.boot + spring-boot-starter-parent + 1.5.4.RELEASE + + + - - UTF-8 - UTF-8 - 1.8 - + + UTF-8 + UTF-8 + 1.8 + - - - org.springframework.boot - spring-boot-starter-mustache - + + + org.springframework.boot + spring-boot-starter-mustache + - - org.springframework.boot - spring-boot-starter-test - test - - - org.webjars - bootstrap - 3.3.7 - - - org.fluttercode.datafactory - datafactory - 0.8 - - + + org.springframework.boot + spring-boot-starter-test + test + + + org.webjars + bootstrap + 3.3.7 + + + org.fluttercode.datafactory + datafactory + 0.8 + + - - - - org.springframework.boot - spring-boot-maven-plugin - - - + + + + org.springframework.boot + spring-boot-maven-plugin + + + diff --git a/spring-mustache/src/main/java/com/baeldung/springmustache/SpringMustacheApplication.java b/spring-mustache/src/main/java/com/baeldung/springmustache/SpringMustacheApplication.java index d4338ffd7d..addd1fa088 100644 --- a/spring-mustache/src/main/java/com/baeldung/springmustache/SpringMustacheApplication.java +++ b/spring-mustache/src/main/java/com/baeldung/springmustache/SpringMustacheApplication.java @@ -10,7 +10,7 @@ import org.springframework.core.env.Environment; import com.samskivert.mustache.Mustache; @SpringBootApplication -@ComponentScan(basePackages = { "com.baeldung" }) +@ComponentScan(basePackages = {"com.baeldung"}) public class SpringMustacheApplication { public static void main(String[] args) { @@ -24,9 +24,9 @@ public class SpringMustacheApplication { collector.setEnvironment(environment); Mustache.Compiler compiler = Mustache.compiler() - .defaultValue("Some Default Value") - .withLoader(templateLoader) - .withCollector(collector); + .defaultValue("Some Default Value") + .withLoader(templateLoader) + .withCollector(collector); return compiler; } diff --git a/spring-mustache/src/main/java/com/baeldung/springmustache/controller/ArticleController.java b/spring-mustache/src/main/java/com/baeldung/springmustache/controller/ArticleController.java index e0db127d66..b24625e7d5 100644 --- a/spring-mustache/src/main/java/com/baeldung/springmustache/controller/ArticleController.java +++ b/spring-mustache/src/main/java/com/baeldung/springmustache/controller/ArticleController.java @@ -23,9 +23,9 @@ public class ArticleController { List
articles = new LinkedList<>(); IntStream.range(0, 10) - .forEach(count -> { - articles.add(generateArticle("Article Title "+count)); - }); + .forEach(count -> { + articles.add(generateArticle("Article Title " + count)); + }); Map modelMap = new HashMap<>(); modelMap.put("articles", articles); @@ -38,12 +38,10 @@ public class ArticleController { DataFactory factory = new DataFactory(); article.setTitle(title); article.setBody( - "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur faucibus tempor diam. In molestie arcu eget ante facilisis sodales. Maecenas porta tellus sapien, eget rutrum nisi blandit in. Mauris tempor auctor ante, ut blandit velit venenatis id. Ut varius, augue aliquet feugiat congue, arcu ipsum finibus purus, dapibus semper velit sapien venenatis magna. Nunc quam ex, aliquet at rutrum sed, vestibulum quis libero. In laoreet libero cursus maximus vulputate. Nullam in fermentum sem. Duis aliquam ullamcorper dui, et dictum justo placerat id. Aliquam pretium orci quis sapien convallis, non blandit est tempus."); - article.setPublishDate(factory.getBirthDate() - .toString()); + "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur faucibus tempor diam. In molestie arcu eget ante facilisis sodales. Maecenas porta tellus sapien, eget rutrum nisi blandit in. Mauris tempor auctor ante, ut blandit velit venenatis id. Ut varius, augue aliquet feugiat congue, arcu ipsum finibus purus, dapibus semper velit sapien venenatis magna. Nunc quam ex, aliquet at rutrum sed, vestibulum quis libero. In laoreet libero cursus maximus vulputate. Nullam in fermentum sem. Duis aliquam ullamcorper dui, et dictum justo placerat id. Aliquam pretium orci quis sapien convallis, non blandit est tempus."); + article.setPublishDate(factory.getBirthDate().toString()); article.setAuthor(factory.getName()); return article; - } } diff --git a/spring-mustache/src/test/java/com/baeldung/springmustache/SpringMustacheApplicationTests.java b/spring-mustache/src/test/java/com/baeldung/springmustache/SpringMustacheApplicationTests.java index 4a72d4156e..9138dfe92b 100644 --- a/spring-mustache/src/test/java/com/baeldung/springmustache/SpringMustacheApplicationTests.java +++ b/spring-mustache/src/test/java/com/baeldung/springmustache/SpringMustacheApplicationTests.java @@ -22,11 +22,9 @@ public class SpringMustacheApplicationTests { public void givenIndexPageWhenContainsArticleThenTrue() { ResponseEntity entity = this.restTemplate.getForEntity("/article", String.class); - Assert.assertTrue(entity.getStatusCode() - .equals(HttpStatus.OK)); - Assert.assertTrue(entity.getBody() - .contains("Article Title 0")); + Assert.assertTrue(entity.getStatusCode().equals(HttpStatus.OK)); + Assert.assertTrue(entity.getBody().contains("Article Title 0")); } } From 3671427d5e377fb684b97833a9fac719531b5936 Mon Sep 17 00:00:00 2001 From: Mohit Sinha Date: Tue, 18 Jul 2017 01:53:03 +0530 Subject: [PATCH 42/89] BAEL-969 Apache Commons Chain (#2228) * BAEL 969 Apache Commons Chain - Example with testcase * Made changes for Apache Commons Chain as per recommendation --- libraries/pom.xml | 8 ++- .../chain/AbstractDenominationDispenser.java | 23 ++++++++ .../baeldung/commons/chain/AtmCatalog.java | 13 +++++ .../baeldung/commons/chain/AtmConstants.java | 10 ++++ .../commons/chain/AtmRequestContext.java | 52 +++++++++++++++++++ .../commons/chain/AtmWithdrawalChain.java | 14 +++++ .../baeldung/commons/chain/AuditFilter.java | 18 +++++++ .../chain/FiftyDenominationDispenser.java | 15 ++++++ .../chain/HundredDenominationDispenser.java | 15 ++++++ .../chain/TenDenominationDispenser.java | 15 ++++++ .../baeldung/commons/chain/AtmChainTest.java | 37 +++++++++++++ 11 files changed, 219 insertions(+), 1 deletion(-) create mode 100644 libraries/src/main/java/com/baeldung/commons/chain/AbstractDenominationDispenser.java create mode 100644 libraries/src/main/java/com/baeldung/commons/chain/AtmCatalog.java create mode 100644 libraries/src/main/java/com/baeldung/commons/chain/AtmConstants.java create mode 100644 libraries/src/main/java/com/baeldung/commons/chain/AtmRequestContext.java create mode 100644 libraries/src/main/java/com/baeldung/commons/chain/AtmWithdrawalChain.java create mode 100644 libraries/src/main/java/com/baeldung/commons/chain/AuditFilter.java create mode 100644 libraries/src/main/java/com/baeldung/commons/chain/FiftyDenominationDispenser.java create mode 100644 libraries/src/main/java/com/baeldung/commons/chain/HundredDenominationDispenser.java create mode 100644 libraries/src/main/java/com/baeldung/commons/chain/TenDenominationDispenser.java create mode 100644 libraries/src/test/java/com/baeldung/commons/chain/AtmChainTest.java diff --git a/libraries/pom.xml b/libraries/pom.xml index 9093a2db03..6be4980b93 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -227,11 +227,16 @@ commons-io ${commons.io.version} + + commons-chain + commons-chain + ${commons-chain.version} + commons-dbutils commons-dbutils ${commons.dbutils.version} - + org.apache.flink flink-core @@ -532,6 +537,7 @@ 3.5 1.1 1.9.3 + 1.2 1.9.2 1.2 3.21.0-GA diff --git a/libraries/src/main/java/com/baeldung/commons/chain/AbstractDenominationDispenser.java b/libraries/src/main/java/com/baeldung/commons/chain/AbstractDenominationDispenser.java new file mode 100644 index 0000000000..cbcf03c7d4 --- /dev/null +++ b/libraries/src/main/java/com/baeldung/commons/chain/AbstractDenominationDispenser.java @@ -0,0 +1,23 @@ +package com.baeldung.commons.chain; + +import org.apache.commons.chain.Command; +import org.apache.commons.chain.Context; + +import static com.baeldung.commons.chain.AtmConstants.AMOUNT_LEFT_TO_BE_WITHDRAWN; + +public abstract class AbstractDenominationDispenser implements Command { + + @Override + public boolean execute(Context context) throws Exception { + int amountLeftToBeWithdrawn = (int) context.get(AMOUNT_LEFT_TO_BE_WITHDRAWN); + if (amountLeftToBeWithdrawn >= getDenominationValue()) { + context.put(getDenominationString(), amountLeftToBeWithdrawn / getDenominationValue()); + context.put(AMOUNT_LEFT_TO_BE_WITHDRAWN, amountLeftToBeWithdrawn % getDenominationValue()); + } + return false; + } + + protected abstract String getDenominationString(); + + protected abstract int getDenominationValue(); +} \ No newline at end of file diff --git a/libraries/src/main/java/com/baeldung/commons/chain/AtmCatalog.java b/libraries/src/main/java/com/baeldung/commons/chain/AtmCatalog.java new file mode 100644 index 0000000000..768517e19a --- /dev/null +++ b/libraries/src/main/java/com/baeldung/commons/chain/AtmCatalog.java @@ -0,0 +1,13 @@ +package com.baeldung.commons.chain; + +import org.apache.commons.chain.impl.CatalogBase; + +import static com.baeldung.commons.chain.AtmConstants.ATM_WITHDRAWAL_CHAIN; + +public class AtmCatalog extends CatalogBase { + + public AtmCatalog() { + super(); + addCommand(ATM_WITHDRAWAL_CHAIN, new AtmWithdrawalChain()); + } +} \ No newline at end of file diff --git a/libraries/src/main/java/com/baeldung/commons/chain/AtmConstants.java b/libraries/src/main/java/com/baeldung/commons/chain/AtmConstants.java new file mode 100644 index 0000000000..d9425fcfac --- /dev/null +++ b/libraries/src/main/java/com/baeldung/commons/chain/AtmConstants.java @@ -0,0 +1,10 @@ +package com.baeldung.commons.chain; + +public class AtmConstants { + public static final String TOTAL_AMOUNT_TO_BE_WITHDRAWN = "totalAmountToBeWithdrawn"; + public static final String AMOUNT_LEFT_TO_BE_WITHDRAWN = "amountLeftToBeWithdrawn"; + public static final String NO_OF_HUNDREDS_DISPENSED = "noOfHundredsDispensed"; + public static final String NO_OF_FIFTIES_DISPENSED = "noOfFiftiesDispensed"; + public static final String NO_OF_TENS_DISPENSED = "noOfTensDispensed"; + public static final String ATM_WITHDRAWAL_CHAIN = "atmWithdrawalChain"; +} \ No newline at end of file diff --git a/libraries/src/main/java/com/baeldung/commons/chain/AtmRequestContext.java b/libraries/src/main/java/com/baeldung/commons/chain/AtmRequestContext.java new file mode 100644 index 0000000000..ee089705ad --- /dev/null +++ b/libraries/src/main/java/com/baeldung/commons/chain/AtmRequestContext.java @@ -0,0 +1,52 @@ +package com.baeldung.commons.chain; + +import org.apache.commons.chain.impl.ContextBase; + +public class AtmRequestContext extends ContextBase { + + int totalAmountToBeWithdrawn; + int noOfHundredsDispensed; + int noOfFiftiesDispensed; + int noOfTensDispensed; + int amountLeftToBeWithdrawn; + + public int getTotalAmountToBeWithdrawn() { + return totalAmountToBeWithdrawn; + } + + public void setTotalAmountToBeWithdrawn(int totalAmountToBeWithdrawn) { + this.totalAmountToBeWithdrawn = totalAmountToBeWithdrawn; + } + + public int getNoOfHundredsDispensed() { + return noOfHundredsDispensed; + } + + public void setNoOfHundredsDispensed(int noOfHundredsDispensed) { + this.noOfHundredsDispensed = noOfHundredsDispensed; + } + + public int getNoOfFiftiesDispensed() { + return noOfFiftiesDispensed; + } + + public void setNoOfFiftiesDispensed(int noOfFiftiesDispensed) { + this.noOfFiftiesDispensed = noOfFiftiesDispensed; + } + + public int getNoOfTensDispensed() { + return noOfTensDispensed; + } + + public void setNoOfTensDispensed(int noOfTensDispensed) { + this.noOfTensDispensed = noOfTensDispensed; + } + + public int getAmountLeftToBeWithdrawn() { + return amountLeftToBeWithdrawn; + } + + public void setAmountLeftToBeWithdrawn(int amountLeftToBeWithdrawn) { + this.amountLeftToBeWithdrawn = amountLeftToBeWithdrawn; + } +} diff --git a/libraries/src/main/java/com/baeldung/commons/chain/AtmWithdrawalChain.java b/libraries/src/main/java/com/baeldung/commons/chain/AtmWithdrawalChain.java new file mode 100644 index 0000000000..fdea5e5744 --- /dev/null +++ b/libraries/src/main/java/com/baeldung/commons/chain/AtmWithdrawalChain.java @@ -0,0 +1,14 @@ +package com.baeldung.commons.chain; + +import org.apache.commons.chain.impl.ChainBase; + +public class AtmWithdrawalChain extends ChainBase { + + public AtmWithdrawalChain() { + super(); + addCommand(new HundredDenominationDispenser()); + addCommand(new FiftyDenominationDispenser()); + addCommand(new TenDenominationDispenser()); + addCommand(new AuditFilter()); + } +} \ No newline at end of file diff --git a/libraries/src/main/java/com/baeldung/commons/chain/AuditFilter.java b/libraries/src/main/java/com/baeldung/commons/chain/AuditFilter.java new file mode 100644 index 0000000000..973e2d498e --- /dev/null +++ b/libraries/src/main/java/com/baeldung/commons/chain/AuditFilter.java @@ -0,0 +1,18 @@ +package com.baeldung.commons.chain; + +import org.apache.commons.chain.Context; +import org.apache.commons.chain.Filter; + +public class AuditFilter implements Filter { + + @Override + public boolean postprocess(Context context, Exception exception) { + // Send notification to customer & bank. + return false; + } + + @Override + public boolean execute(Context context) throws Exception { + return false; + } +} \ No newline at end of file diff --git a/libraries/src/main/java/com/baeldung/commons/chain/FiftyDenominationDispenser.java b/libraries/src/main/java/com/baeldung/commons/chain/FiftyDenominationDispenser.java new file mode 100644 index 0000000000..f0f5959764 --- /dev/null +++ b/libraries/src/main/java/com/baeldung/commons/chain/FiftyDenominationDispenser.java @@ -0,0 +1,15 @@ +package com.baeldung.commons.chain; + +import static com.baeldung.commons.chain.AtmConstants.NO_OF_FIFTIES_DISPENSED; + +public class FiftyDenominationDispenser extends AbstractDenominationDispenser { + @Override + protected String getDenominationString() { + return NO_OF_FIFTIES_DISPENSED; + } + + @Override + protected int getDenominationValue() { + return 50; + } +} \ No newline at end of file diff --git a/libraries/src/main/java/com/baeldung/commons/chain/HundredDenominationDispenser.java b/libraries/src/main/java/com/baeldung/commons/chain/HundredDenominationDispenser.java new file mode 100644 index 0000000000..e65d0d34c9 --- /dev/null +++ b/libraries/src/main/java/com/baeldung/commons/chain/HundredDenominationDispenser.java @@ -0,0 +1,15 @@ +package com.baeldung.commons.chain; + +import static com.baeldung.commons.chain.AtmConstants.NO_OF_HUNDREDS_DISPENSED; + +public class HundredDenominationDispenser extends AbstractDenominationDispenser { + @Override + protected String getDenominationString() { + return NO_OF_HUNDREDS_DISPENSED; + } + + @Override + protected int getDenominationValue() { + return 100; + } +} \ No newline at end of file diff --git a/libraries/src/main/java/com/baeldung/commons/chain/TenDenominationDispenser.java b/libraries/src/main/java/com/baeldung/commons/chain/TenDenominationDispenser.java new file mode 100644 index 0000000000..423440bc4d --- /dev/null +++ b/libraries/src/main/java/com/baeldung/commons/chain/TenDenominationDispenser.java @@ -0,0 +1,15 @@ +package com.baeldung.commons.chain; + +import static com.baeldung.commons.chain.AtmConstants.NO_OF_TENS_DISPENSED; + +public class TenDenominationDispenser extends AbstractDenominationDispenser { + @Override + protected String getDenominationString() { + return NO_OF_TENS_DISPENSED; + } + + @Override + protected int getDenominationValue() { + return 10; + } +} \ No newline at end of file diff --git a/libraries/src/test/java/com/baeldung/commons/chain/AtmChainTest.java b/libraries/src/test/java/com/baeldung/commons/chain/AtmChainTest.java new file mode 100644 index 0000000000..cd9a7baaf3 --- /dev/null +++ b/libraries/src/test/java/com/baeldung/commons/chain/AtmChainTest.java @@ -0,0 +1,37 @@ +package com.baeldung.commons.chain; + +import org.apache.commons.chain.Catalog; +import org.apache.commons.chain.Command; +import org.apache.commons.chain.Context; +import org.junit.Assert; +import org.junit.Test; + +import static com.baeldung.commons.chain.AtmConstants.*; + +public class AtmChainTest { + + public static final int EXPECTED_TOTAL_AMOUNT_TO_BE_WITHDRAWN = 460; + public static final int EXPECTED_AMOUNT_LEFT_TO_BE_WITHDRAWN = 0; + public static final int EXPECTED_NO_OF_HUNDREDS_DISPENSED = 4; + public static final int EXPECTED_NO_OF_FIFTIES_DISPENSED = 1; + public static final int EXPECTED_NO_OF_TENS_DISPENSED = 1; + + @Test + public void givenInputsToContext_whenAppliedChain_thenExpectedContext() { + Context context = new AtmRequestContext(); + context.put(TOTAL_AMOUNT_TO_BE_WITHDRAWN, 460); + context.put(AMOUNT_LEFT_TO_BE_WITHDRAWN, 460); + Catalog catalog = new AtmCatalog(); + Command atmWithdrawalChain = catalog.getCommand(ATM_WITHDRAWAL_CHAIN); + try { + atmWithdrawalChain.execute(context); + } catch (Exception e) { + e.printStackTrace(); + } + Assert.assertEquals(EXPECTED_TOTAL_AMOUNT_TO_BE_WITHDRAWN, (int) context.get(TOTAL_AMOUNT_TO_BE_WITHDRAWN)); + Assert.assertEquals(EXPECTED_AMOUNT_LEFT_TO_BE_WITHDRAWN, (int) context.get(AMOUNT_LEFT_TO_BE_WITHDRAWN)); + Assert.assertEquals(EXPECTED_NO_OF_HUNDREDS_DISPENSED, (int) context.get(NO_OF_HUNDREDS_DISPENSED)); + Assert.assertEquals(EXPECTED_NO_OF_FIFTIES_DISPENSED, (int) context.get(NO_OF_FIFTIES_DISPENSED)); + Assert.assertEquals(EXPECTED_NO_OF_TENS_DISPENSED, (int) context.get(NO_OF_TENS_DISPENSED)); + } +} \ No newline at end of file From 2ce547d4cdab1a5e4c707d852ca7500c83eff2ae Mon Sep 17 00:00:00 2001 From: Seun Matt Date: Mon, 17 Jul 2017 23:44:10 +0100 Subject: [PATCH 43/89] Complete Example Code for BAEL-782 (#2270) * added updated example codes * updated example code StringToCharStream * deleted StringToCharStream.java locally * removed redundant file * added code for apache commons collection SetUtils * refactored example code * added example code for bytebuddy --- libraries/pom.xml | 11 +++ .../main/java/com/baeldung/bytebuddy/Bar.java | 16 ++++ .../main/java/com/baeldung/bytebuddy/Foo.java | 7 ++ .../baeldung/bytebuddy/ByteBuddyUnitTest.java | 89 +++++++++++++++++++ 4 files changed, 123 insertions(+) create mode 100644 libraries/src/main/java/com/baeldung/bytebuddy/Bar.java create mode 100644 libraries/src/main/java/com/baeldung/bytebuddy/Foo.java create mode 100644 libraries/src/test/java/com/baeldung/bytebuddy/ByteBuddyUnitTest.java diff --git a/libraries/pom.xml b/libraries/pom.xml index 6be4980b93..c23b6ef912 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -530,6 +530,16 @@ hll ${hll.version} + + net.bytebuddy + byte-buddy + ${bytebuddy.version} + + + net.bytebuddy + byte-buddy-agent + ${bytebuddy.version} + 0.7.0 @@ -572,6 +582,7 @@ mytheme 1.6.0 + 1.7.1 diff --git a/libraries/src/main/java/com/baeldung/bytebuddy/Bar.java b/libraries/src/main/java/com/baeldung/bytebuddy/Bar.java new file mode 100644 index 0000000000..d0362a6c92 --- /dev/null +++ b/libraries/src/main/java/com/baeldung/bytebuddy/Bar.java @@ -0,0 +1,16 @@ +package com.baeldung.bytebuddy; + +import net.bytebuddy.implementation.bind.annotation.BindingPriority; + +public class Bar { + + @BindingPriority(3) + public static String sayHelloBar() { return "Holla in Bar!"; } + + @BindingPriority(2) + public static String sayBar() { return "bar"; } + + public String bar() { return Bar.class.getSimpleName() + " - Bar"; } + + +} diff --git a/libraries/src/main/java/com/baeldung/bytebuddy/Foo.java b/libraries/src/main/java/com/baeldung/bytebuddy/Foo.java new file mode 100644 index 0000000000..4be06785b1 --- /dev/null +++ b/libraries/src/main/java/com/baeldung/bytebuddy/Foo.java @@ -0,0 +1,7 @@ +package com.baeldung.bytebuddy; + +public class Foo { + + public String sayHelloFoo() { return "Hello in Foo!"; } + +} diff --git a/libraries/src/test/java/com/baeldung/bytebuddy/ByteBuddyUnitTest.java b/libraries/src/test/java/com/baeldung/bytebuddy/ByteBuddyUnitTest.java new file mode 100644 index 0000000000..6b7364a0a5 --- /dev/null +++ b/libraries/src/test/java/com/baeldung/bytebuddy/ByteBuddyUnitTest.java @@ -0,0 +1,89 @@ +package com.baeldung.bytebuddy; + +import net.bytebuddy.ByteBuddy; +import net.bytebuddy.agent.ByteBuddyAgent; +import net.bytebuddy.dynamic.DynamicType; +import net.bytebuddy.dynamic.loading.ClassLoadingStrategy; +import net.bytebuddy.dynamic.loading.ClassReloadingStrategy; +import net.bytebuddy.implementation.FixedValue; +import net.bytebuddy.implementation.MethodDelegation; +import net.bytebuddy.matcher.ElementMatchers; +import org.junit.Test; + +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; + +import static net.bytebuddy.matcher.ElementMatchers.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class ByteBuddyUnitTest { + + @Test + public void givenObject_whenToString_thenReturnHelloWorldString() throws InstantiationException, IllegalAccessException { + DynamicType.Unloaded unloadedType = new ByteBuddy() + .subclass(Object.class) + .method(ElementMatchers.isToString()) + .intercept(FixedValue.value("Hello World ByteBuddy!")) + .make(); + + Class dynamicType = unloadedType.load(getClass().getClassLoader()) + .getLoaded(); + + assertEquals(dynamicType.newInstance().toString(), "Hello World ByteBuddy!"); + } + + @Test + public void givenFoo_whenRedefined_thenReturnFooRedefined() throws Exception { + ByteBuddyAgent.install(); + new ByteBuddy() + .redefine(Foo.class) + .method(named("sayHelloFoo")) + .intercept(FixedValue.value("Hello Foo Redefined")) + .make() + .load(Foo.class.getClassLoader(), ClassReloadingStrategy.fromInstalledAgent()); + Foo f = new Foo(); + assertEquals(f.sayHelloFoo(), "Hello Foo Redefined"); + } + + @Test + public void givenSayHelloFoo_whenMethodDelegation_thenSayHelloBar() throws IllegalAccessException, InstantiationException { + + String r = new ByteBuddy() + .subclass(Foo.class) + .method( + named("sayHelloFoo") + .and(isDeclaredBy(Foo.class) + .and(returns(String.class))) + ) + .intercept(MethodDelegation.to(Bar.class)) + .make() + .load(getClass().getClassLoader()) + .getLoaded() + .newInstance() + .sayHelloFoo(); + + assertEquals(r, Bar.sayHelloBar()); + } + + @Test + public void givenMethodName_whenDefineMethod_thenCreateMethod() throws Exception { + Class type = new ByteBuddy() + .subclass(Object.class) + .name("MyClassName") + .defineMethod("custom", String.class, Modifier.PUBLIC) + .intercept(MethodDelegation.to(Bar.class)) + .defineField("x", String.class, Modifier.PUBLIC) + .make() + .load(getClass().getClassLoader(), ClassLoadingStrategy.Default.WRAPPER) + .getLoaded(); + + Method m = type.getDeclaredMethod("custom", null); + + assertEquals(m.invoke(type.newInstance()), Bar.sayHelloBar()); + assertNotNull(type.getDeclaredField("x")); + + } + + +} From afa82c0d28c63703ad977c3a3defb662a8ea48ce Mon Sep 17 00:00:00 2001 From: deep20jain Date: Tue, 18 Jul 2017 09:38:19 +0530 Subject: [PATCH 44/89] BAEL-1029 - deep20jain@gmail.com - An Introduction to Atomic Variables in Java (#2269) * Adding test classes for java atomic variables * Updating counter with atomic integer * Adding reason for ignoring test --- .../atomic/SafeCounterWithLock.java | 13 +++++ .../atomic/SafeCounterWithoutLock.java | 21 +++++++ .../concurrent/atomic/UnsafeCounter.java | 13 +++++ .../concurrent/atomic/CounterTest.java | 58 +++++++++++++++++++ 4 files changed, 105 insertions(+) create mode 100644 core-java/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithLock.java create mode 100644 core-java/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithoutLock.java create mode 100644 core-java/src/main/java/com/baeldung/concurrent/atomic/UnsafeCounter.java create mode 100644 core-java/src/test/java/com/baeldung/concurrent/atomic/CounterTest.java diff --git a/core-java/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithLock.java b/core-java/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithLock.java new file mode 100644 index 0000000000..b2502018bb --- /dev/null +++ b/core-java/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithLock.java @@ -0,0 +1,13 @@ +package com.baeldung.concurrent.atomic; + +public class SafeCounterWithLock { + int counter; + + public int getValue() { + return counter; + } + + public synchronized void increment() { + counter++; + } +} diff --git a/core-java/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithoutLock.java b/core-java/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithoutLock.java new file mode 100644 index 0000000000..55226f4f13 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithoutLock.java @@ -0,0 +1,21 @@ +package com.baeldung.concurrent.atomic; + +import java.util.concurrent.atomic.AtomicInteger; + +public class SafeCounterWithoutLock { + AtomicInteger counter = new AtomicInteger(0); + + public int getValue() { + return counter.get(); + } + + public void increment() { + while(true) { + int existingValue = getValue(); + int newValue = existingValue + 1; + if(counter.compareAndSet(existingValue, newValue)) { + return; + } + } + } +} diff --git a/core-java/src/main/java/com/baeldung/concurrent/atomic/UnsafeCounter.java b/core-java/src/main/java/com/baeldung/concurrent/atomic/UnsafeCounter.java new file mode 100644 index 0000000000..8a72788842 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/concurrent/atomic/UnsafeCounter.java @@ -0,0 +1,13 @@ +package com.baeldung.concurrent.atomic; + +public class UnsafeCounter { + int counter; + + public int getValue() { + return counter; + } + + public void increment() { + counter++; + } +} diff --git a/core-java/src/test/java/com/baeldung/concurrent/atomic/CounterTest.java b/core-java/src/test/java/com/baeldung/concurrent/atomic/CounterTest.java new file mode 100644 index 0000000000..1612c62513 --- /dev/null +++ b/core-java/src/test/java/com/baeldung/concurrent/atomic/CounterTest.java @@ -0,0 +1,58 @@ +package com.baeldung.concurrent.atomic; + +import static org.junit.Assert.assertEquals; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.stream.IntStream; + +import org.junit.Ignore; +import org.junit.Test; + +public class CounterTest { + + /** + * This test shows the behaviour of a thread-unsafe class in a multithreaded scenario. We are calling + * the increment methods 1000 times from a pool of 3 threads. In most of the cases, the counter will + * less than 1000, because of lost updates, however, occasionally it may reach 1000, when no threads + * called the method simultaneously. This may cause the build to fail occasionally. Hence excluding this + * test by adding Ignore annotation. + */ + @Test + @Ignore + public void givenMultiThread_whenUnsafeCounterIncrement() throws InterruptedException { + ExecutorService service = Executors.newFixedThreadPool(3); + UnsafeCounter unsafeCounter = new UnsafeCounter(); + + IntStream.range(0, 1000) + .forEach(count -> service.submit(unsafeCounter::increment)); + service.awaitTermination(100, TimeUnit.MILLISECONDS); + + assertEquals(1000, unsafeCounter.getValue()); + } + + @Test + public void givenMultiThread_whenSafeCounterWithLockIncrement() throws InterruptedException { + ExecutorService service = Executors.newFixedThreadPool(3); + SafeCounterWithLock safeCounter = new SafeCounterWithLock(); + + IntStream.range(0, 1000) + .forEach(count -> service.submit(safeCounter::increment)); + service.awaitTermination(100, TimeUnit.MILLISECONDS); + + assertEquals(1000, safeCounter.getValue()); + } + + @Test + public void givenMultiThread_whenSafeCounterWithoutLockIncrement() throws InterruptedException { + ExecutorService service = Executors.newFixedThreadPool(3); + SafeCounterWithoutLock safeCounter = new SafeCounterWithoutLock(); + + IntStream.range(0, 1000) + .forEach(count -> service.submit(safeCounter::increment)); + service.awaitTermination(100, TimeUnit.MILLISECONDS); + + assertEquals(1000, safeCounter.getValue()); + } +} From aba59e88d9e2101a7050b85af3e20112bc2c6888 Mon Sep 17 00:00:00 2001 From: KevinGilmore Date: Tue, 18 Jul 2017 18:34:06 -0500 Subject: [PATCH 45/89] BAEL-1010: README (#2284) * BAEL-886: Updated README * BAEL-917 Testing with Google Truth Updated README * BAEL-936: adding akka-streams module to parent * BAEL-936: Update README * BAEL-918: Update README * BAEL-980: Update README * BAEL-967: Update README * BAEL-509: Using @GetMapping instead of @RequestMapping with method=GET * BAEL-1005: Update README * BAEL-509: Security and WebSockets (README) * BAEL-861: Intro to Awaitility (README) * BAEL-1010: Guide to the HyperLogLog Algorithm (README) --- libraries/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/README.md b/libraries/README.md index 30f02e5c5a..7970c0e99e 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -25,7 +25,7 @@ - [Apache Commons Collections OrderedMap](http://www.baeldung.com/apache-commons-ordered-map) - [A Guide to Apache Commons DbUtils](http://www.baeldung.com/apache-commons-dbutils) - [Introduction to Awaitility](http://www.baeldung.com/awaitlity-testing) - +- [Guide to the HyperLogLog Algorithm](http://www.baeldung.com/java-hyperloglog) The libraries module contains examples related to small libraries that are relatively easy to use and does not require any separate module of its own. From a24e442731b82235ca18451d8eafe44ce58cda02 Mon Sep 17 00:00:00 2001 From: Jesus Boadas Date: Tue, 18 Jul 2017 19:46:02 -0400 Subject: [PATCH 46/89] Vaadin server-push, data binding and validators (#2283) --- libraries/pom.xml | 4 + .../java/com/baeldung/vaadin/BindData.java | 20 ++++ .../java/com/baeldung/vaadin/VaadinUI.java | 102 +++++++++++++++--- 3 files changed, 112 insertions(+), 14 deletions(-) create mode 100644 libraries/src/main/java/com/baeldung/vaadin/BindData.java diff --git a/libraries/pom.xml b/libraries/pom.xml index c23b6ef912..16f70cb171 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -476,6 +476,10 @@ com.vaadin vaadin-themes + + com.vaadin + vaadin-push + org.seleniumhq.selenium selenium-java diff --git a/libraries/src/main/java/com/baeldung/vaadin/BindData.java b/libraries/src/main/java/com/baeldung/vaadin/BindData.java new file mode 100644 index 0000000000..bcdc4eee71 --- /dev/null +++ b/libraries/src/main/java/com/baeldung/vaadin/BindData.java @@ -0,0 +1,20 @@ +package com.baeldung.vaadin; + +public class BindData { + + private String bindName; + + public BindData(String bindName){ + this.bindName = bindName; + } + + public String getBindName() { + return bindName; + } + + public void setBindName(String bindName) { + this.bindName = bindName; + } + + +} diff --git a/libraries/src/main/java/com/baeldung/vaadin/VaadinUI.java b/libraries/src/main/java/com/baeldung/vaadin/VaadinUI.java index e134b501c8..8343d38f6a 100644 --- a/libraries/src/main/java/com/baeldung/vaadin/VaadinUI.java +++ b/libraries/src/main/java/com/baeldung/vaadin/VaadinUI.java @@ -1,7 +1,18 @@ package com.baeldung.vaadin; +import java.time.Instant; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.servlet.annotation.WebServlet; + +import com.vaadin.annotations.Push; import com.vaadin.annotations.Theme; import com.vaadin.annotations.VaadinServletConfiguration; +import com.vaadin.data.Validator.InvalidValueException; +import com.vaadin.data.fieldgroup.BeanFieldGroup; +import com.vaadin.data.validator.StringLengthValidator; import com.vaadin.server.ExternalResource; import com.vaadin.server.FontAwesome; import com.vaadin.server.VaadinRequest; @@ -29,14 +40,14 @@ import com.vaadin.ui.TwinColSelect; import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; -import javax.servlet.annotation.WebServlet; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - +@SuppressWarnings("serial") +@Push @Theme("mytheme") public class VaadinUI extends UI { + private Label currentTime; + + @SuppressWarnings({ "rawtypes", "unchecked" }) @Override protected void init(VaadinRequest vaadinRequest) { final VerticalLayout verticalLayout = new VerticalLayout(); @@ -61,8 +72,7 @@ public class VaadinUI extends UI { label.setCaption("Label"); gridLayout.addComponent(label); - final Link link = new Link("Baeldung", - new ExternalResource("http://www.baeldung.com/")); + final Link link = new Link("Baeldung", new ExternalResource("http://www.baeldung.com/")); link.setId("Link"); link.setTargetName("_blank"); gridLayout.addComponent(link); @@ -118,28 +128,23 @@ public class VaadinUI extends UI { smallButton.addStyleName("small"); buttonLayout.addComponent(smallButton); - Button largeButton = new Button("Large Button"); largeButton.addStyleName("large"); buttonLayout.addComponent(largeButton); - Button hugeButton = new Button("Huge Button"); hugeButton.addStyleName("huge"); buttonLayout.addComponent(hugeButton); - Button disabledButton = new Button("Disabled Button"); disabledButton.setDescription("This button cannot be clicked"); disabledButton.setEnabled(false); buttonLayout.addComponent(disabledButton); - Button dangerButton = new Button("Danger Button"); dangerButton.addStyleName("danger"); buttonLayout.addComponent(dangerButton); - Button friendlyButton = new Button("Friendly Button"); friendlyButton.addStyleName("friendly"); buttonLayout.addComponent(friendlyButton); @@ -171,8 +176,7 @@ public class VaadinUI extends UI { final CheckBox checkbox = new CheckBox("CheckBox"); checkbox.setValue(true); - checkbox.addValueChangeListener(e -> - checkbox.setValue(!checkbox.getValue())); + checkbox.addValueChangeListener(e -> checkbox.setValue(!checkbox.getValue())); formLayout.addComponent(checkbox); List numbers = new ArrayList(); @@ -204,12 +208,62 @@ public class VaadinUI extends UI { panel.setContent(grid); panel.setSizeUndefined(); + Panel serverPushPanel = new Panel("Server Push"); + FormLayout timeLayout = new FormLayout(); + timeLayout.setSpacing(true); + timeLayout.setMargin(true); + currentTime = new Label("No TIME..."); + timeLayout.addComponent(currentTime); + serverPushPanel.setContent(timeLayout); + serverPushPanel.setSizeUndefined(); + new ServerPushThread().start(); + + FormLayout dataBindingLayout = new FormLayout(); + dataBindingLayout.setSpacing(true); + dataBindingLayout.setMargin(true); + + BindData bindData = new BindData("BindData"); + BeanFieldGroup beanFieldGroup = new BeanFieldGroup(BindData.class); + beanFieldGroup.setItemDataSource(bindData); + TextField bindedTextField = (TextField) beanFieldGroup.buildAndBind("BindName", "bindName"); + bindedTextField.setWidth("250px"); + dataBindingLayout.addComponent(bindedTextField); + + FormLayout validatorLayout = new FormLayout(); + validatorLayout.setSpacing(true); + validatorLayout.setMargin(true); + + HorizontalLayout textValidatorLayout = new HorizontalLayout(); + textValidatorLayout.setSpacing(true); + textValidatorLayout.setMargin(true); + + TextField stringValidator = new TextField(); + stringValidator.setNullSettingAllowed(true); + stringValidator.setNullRepresentation(""); + stringValidator.addValidator(new StringLengthValidator("String must have 2-5 characters lenght", 2, 5, true)); + stringValidator.setValidationVisible(false); + textValidatorLayout.addComponent(stringValidator); + Button buttonStringValidator = new Button("Validate String"); + buttonStringValidator.addClickListener(e -> { + try { + stringValidator.setValidationVisible(false); + stringValidator.validate(); + } catch (InvalidValueException err) { + stringValidator.setValidationVisible(true); + } + }); + textValidatorLayout.addComponent(buttonStringValidator); + + validatorLayout.addComponent(textValidatorLayout); verticalLayout.addComponent(gridLayout); verticalLayout.addComponent(richTextPanel); verticalLayout.addComponent(horizontalLayout); verticalLayout.addComponent(formLayout); verticalLayout.addComponent(twinColSelect); verticalLayout.addComponent(panel); + verticalLayout.addComponent(serverPushPanel); + verticalLayout.addComponent(dataBindingLayout); + verticalLayout.addComponent(validatorLayout); setContent(verticalLayout); } @@ -217,4 +271,24 @@ public class VaadinUI extends UI { @VaadinServletConfiguration(ui = VaadinUI.class, productionMode = false) public static class MyUIServlet extends VaadinServlet { } + + class ServerPushThread extends Thread { + @Override + public void run() { + try { + while (true) { + Thread.sleep(1000); + access(new Runnable() { + @Override + public void run() { + currentTime.setValue("Current Time : " + Instant.now()); + } + }); + } + + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } } \ No newline at end of file From 5004fd96a35741bdf036f50ffbdede3d58a5abb5 Mon Sep 17 00:00:00 2001 From: yetanotherallisonf Date: Wed, 19 Jul 2017 03:15:51 -0500 Subject: [PATCH 47/89] Update README.md (#2258) --- vavr/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/vavr/README.md b/vavr/README.md index d95e026bde..c4155c2680 100644 --- a/vavr/README.md +++ b/vavr/README.md @@ -4,3 +4,4 @@ - [Guide to Pattern Matching in Vavr](http://www.baeldung.com/javaslang-pattern-matching) - [Property Testing Example With Vavr](http://www.baeldung.com/javaslang-property-testing) - [Exceptions in Lambda Expression Using Vavr](http://www.baeldung.com/exceptions-using-vavr) +- [Vavr (ex-Javaslang) Support in Spring Data](http://www.baeldung.com/spring-vavr) From 14456eb92d1afd289ab92fe129a18bac7f442b65 Mon Sep 17 00:00:00 2001 From: Abhinab Kanrar Date: Wed, 19 Jul 2017 13:46:22 +0530 Subject: [PATCH 48/89] concurrent package description (#2265) * moving jmh into libraries module * refactoring jmh * Update pom.xml * manual algorightm * with BM result * fix for space issue * Fixed indentation * change as per suggestion * vavr either * adding unit test and othe rutilities * adding concurrent module * concurrent package description * concurrent package description * Update EitherUnitTest.java --- .../ScheduledExecutorServiceDemo.java | 46 ++++++++++++++++++ .../cyclicbarrier/CyclicBarrierExample.java | 27 +++++++++++ .../concurrent/cyclicbarrier/Task.java | 25 ++++++++++ .../concurrent/executor/ExecutorDemo.java | 17 +++++++ .../baeldung/concurrent/executor/Invoker.java | 12 +++++ .../executorservice/ExecutorServiceDemo.java | 32 +++++++++++++ .../concurrent/executorservice/Task.java | 10 ++++ .../concurrent/future/FutureDemo.java | 47 +++++++++++++++++++ .../concurrent/semaphore/SemaPhoreDemo.java | 22 +++++++++ .../threadfactory/BaeldungThreadFactory.java | 23 +++++++++ .../concurrent/threadfactory/Demo.java | 13 +++++ .../concurrent/threadfactory/Task.java | 10 ++++ 12 files changed, 284 insertions(+) create mode 100644 core-java/src/main/java/com/baeldung/concurrent/Scheduledexecutorservice/ScheduledExecutorServiceDemo.java create mode 100644 core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierExample.java create mode 100644 core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/Task.java create mode 100644 core-java/src/main/java/com/baeldung/concurrent/executor/ExecutorDemo.java create mode 100644 core-java/src/main/java/com/baeldung/concurrent/executor/Invoker.java create mode 100644 core-java/src/main/java/com/baeldung/concurrent/executorservice/ExecutorServiceDemo.java create mode 100644 core-java/src/main/java/com/baeldung/concurrent/executorservice/Task.java create mode 100644 core-java/src/main/java/com/baeldung/concurrent/future/FutureDemo.java create mode 100644 core-java/src/main/java/com/baeldung/concurrent/semaphore/SemaPhoreDemo.java create mode 100644 core-java/src/main/java/com/baeldung/concurrent/threadfactory/BaeldungThreadFactory.java create mode 100644 core-java/src/main/java/com/baeldung/concurrent/threadfactory/Demo.java create mode 100644 core-java/src/main/java/com/baeldung/concurrent/threadfactory/Task.java diff --git a/core-java/src/main/java/com/baeldung/concurrent/Scheduledexecutorservice/ScheduledExecutorServiceDemo.java b/core-java/src/main/java/com/baeldung/concurrent/Scheduledexecutorservice/ScheduledExecutorServiceDemo.java new file mode 100644 index 0000000000..171f308c16 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/concurrent/Scheduledexecutorservice/ScheduledExecutorServiceDemo.java @@ -0,0 +1,46 @@ +package com.baeldung.concurrent.Scheduledexecutorservice; + +import java.util.concurrent.Callable; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; + +public class ScheduledExecutorServiceDemo { + + public void execute() { + ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor(); + + ScheduledFuture scheduledFuture = executorService.schedule(new Runnable() { + @Override + public void run() { + // task details + } + }, 1, TimeUnit.SECONDS); + + executorService.scheduleAtFixedRate(new Runnable() { + @Override + public void run() { + // task details + } + }, 1, 10, TimeUnit.SECONDS); + + executorService.scheduleWithFixedDelay(new Runnable() { + @Override + public void run() { + // task details + } + }, 1, 10, TimeUnit.SECONDS); + + Future future = executorService.schedule(new Callable() { + @Override + public String call() throws Exception { + return "Hello World"; + } + }, 1, TimeUnit.SECONDS); + + executorService.shutdown(); + } + +} diff --git a/core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierExample.java b/core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierExample.java new file mode 100644 index 0000000000..e6075c933e --- /dev/null +++ b/core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierExample.java @@ -0,0 +1,27 @@ +package com.baeldung.concurrent.cyclicbarrier; + +import java.util.concurrent.CyclicBarrier; + +public class CyclicBarrierExample { + + public void start() { + CyclicBarrier cyclicBarrier = new CyclicBarrier(3, new Runnable() { + @Override + public void run() { + System.out.println("All previous tasks are completed"); + } + }); + + Thread t1 = new Thread(new Task(cyclicBarrier), "T1"); + Thread t2 = new Thread(new Task(cyclicBarrier), "T2"); + Thread t3 = new Thread(new Task(cyclicBarrier), "T3"); + + if (!cyclicBarrier.isBroken()) { + t1.start(); + t2.start(); + t3.start(); + } + + } + +} diff --git a/core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/Task.java b/core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/Task.java new file mode 100644 index 0000000000..4f7801e8c5 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/Task.java @@ -0,0 +1,25 @@ +package com.baeldung.concurrent.cyclicbarrier; + +import java.util.concurrent.BrokenBarrierException; +import java.util.concurrent.CyclicBarrier; + +public class Task implements Runnable { + + private CyclicBarrier barrier; + + public Task(CyclicBarrier barrier) { + this.barrier = barrier; + } + + @Override + public void run() { + try { + System.out.println("Thread : "+ Thread.currentThread().getName() + " is waiting"); + barrier.await(); + System.out.println("Thread : "+ Thread.currentThread().getName() + " is released"); + } catch (InterruptedException | BrokenBarrierException e) { + e.printStackTrace(); + } + } + +} diff --git a/core-java/src/main/java/com/baeldung/concurrent/executor/ExecutorDemo.java b/core-java/src/main/java/com/baeldung/concurrent/executor/ExecutorDemo.java new file mode 100644 index 0000000000..9392134bfb --- /dev/null +++ b/core-java/src/main/java/com/baeldung/concurrent/executor/ExecutorDemo.java @@ -0,0 +1,17 @@ +package com.baeldung.concurrent.executor; + +import java.util.concurrent.Executor; + +public class ExecutorDemo { + + public void execute() { + Executor executor = new Invoker(); + executor.execute(new Runnable() { + @Override + public void run() { + // task to be performed + } + }); + } + +} diff --git a/core-java/src/main/java/com/baeldung/concurrent/executor/Invoker.java b/core-java/src/main/java/com/baeldung/concurrent/executor/Invoker.java new file mode 100644 index 0000000000..d9f11986d6 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/concurrent/executor/Invoker.java @@ -0,0 +1,12 @@ +package com.baeldung.concurrent.executor; + +import java.util.concurrent.Executor; + +public class Invoker implements Executor { + + @Override + public void execute(Runnable r) { + r.run(); + } + +} diff --git a/core-java/src/main/java/com/baeldung/concurrent/executorservice/ExecutorServiceDemo.java b/core-java/src/main/java/com/baeldung/concurrent/executorservice/ExecutorServiceDemo.java new file mode 100644 index 0000000000..631ae140ab --- /dev/null +++ b/core-java/src/main/java/com/baeldung/concurrent/executorservice/ExecutorServiceDemo.java @@ -0,0 +1,32 @@ +package com.baeldung.concurrent.executorservice; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +public class ExecutorServiceDemo { + + ExecutorService executor = Executors.newFixedThreadPool(10); + + public void execute() { + + executor.execute(new Runnable() { + @Override + public void run() { + // task details + } + }); + + executor.submit(new Task()); + + executor.shutdown(); + executor.shutdownNow(); + try { + executor.awaitTermination(20l, TimeUnit.NANOSECONDS); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + } + +} diff --git a/core-java/src/main/java/com/baeldung/concurrent/executorservice/Task.java b/core-java/src/main/java/com/baeldung/concurrent/executorservice/Task.java new file mode 100644 index 0000000000..9a21bca80c --- /dev/null +++ b/core-java/src/main/java/com/baeldung/concurrent/executorservice/Task.java @@ -0,0 +1,10 @@ +package com.baeldung.concurrent.executorservice; + +public class Task implements Runnable { + + @Override + public void run() { + // task details + } + +} diff --git a/core-java/src/main/java/com/baeldung/concurrent/future/FutureDemo.java b/core-java/src/main/java/com/baeldung/concurrent/future/FutureDemo.java new file mode 100644 index 0000000000..89ce1a0a41 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/concurrent/future/FutureDemo.java @@ -0,0 +1,47 @@ +package com.baeldung.concurrent.future; + +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +public class FutureDemo { + + public String invoke() { + + String str = null; + + ExecutorService executorService = Executors.newFixedThreadPool(10); + + Future future = executorService.submit(new Callable() { + @Override + public String call() throws Exception { + Thread.sleep(10000l); + return "Hello World"; + } + }); + + future.cancel(false); + + try { + future.get(20, TimeUnit.SECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e1) { + e1.printStackTrace(); + } + + if (future.isDone() && !future.isCancelled()) { + try { + str = future.get(); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + + return str; + + } + +} diff --git a/core-java/src/main/java/com/baeldung/concurrent/semaphore/SemaPhoreDemo.java b/core-java/src/main/java/com/baeldung/concurrent/semaphore/SemaPhoreDemo.java new file mode 100644 index 0000000000..3a1d8555d3 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/concurrent/semaphore/SemaPhoreDemo.java @@ -0,0 +1,22 @@ +package com.baeldung.concurrent.semaphore; + +import java.util.concurrent.Semaphore; + +public class SemaPhoreDemo { + + static Semaphore semaphore = new Semaphore(10); + + public void execute() throws InterruptedException { + + System.out.println("Available permit : " + semaphore.availablePermits()); + System.out.println("Number of threads waiting to acquire: " + semaphore.getQueueLength()); + + if (semaphore.tryAcquire()) { + semaphore.acquire(); + // perform some critical operations + semaphore.release(); + } + + } + +} diff --git a/core-java/src/main/java/com/baeldung/concurrent/threadfactory/BaeldungThreadFactory.java b/core-java/src/main/java/com/baeldung/concurrent/threadfactory/BaeldungThreadFactory.java new file mode 100644 index 0000000000..8744027e40 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/concurrent/threadfactory/BaeldungThreadFactory.java @@ -0,0 +1,23 @@ +package com.baeldung.concurrent.threadfactory; + +import java.util.concurrent.ThreadFactory; + +public class BaeldungThreadFactory implements ThreadFactory { + + private int threadId; + private String name; + + public BaeldungThreadFactory(String name) { + threadId = 1; + this.name = name; + } + + @Override + public Thread newThread(Runnable r) { + Thread t = new Thread(r, name + "-Thread_" + threadId); + System.out.println("created new thread with id : " + threadId + " and name : " + t.getName()); + threadId++; + return t; + } + +} diff --git a/core-java/src/main/java/com/baeldung/concurrent/threadfactory/Demo.java b/core-java/src/main/java/com/baeldung/concurrent/threadfactory/Demo.java new file mode 100644 index 0000000000..d2af97b761 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/concurrent/threadfactory/Demo.java @@ -0,0 +1,13 @@ +package com.baeldung.concurrent.threadfactory; + +public class Demo { + + public void execute() { + BaeldungThreadFactory factory = new BaeldungThreadFactory("BaeldungThreadFactory"); + for (int i = 0; i < 10; i++) { + Thread t = factory.newThread(new Task()); + t.start(); + } + } + +} diff --git a/core-java/src/main/java/com/baeldung/concurrent/threadfactory/Task.java b/core-java/src/main/java/com/baeldung/concurrent/threadfactory/Task.java new file mode 100644 index 0000000000..04ba62d457 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/concurrent/threadfactory/Task.java @@ -0,0 +1,10 @@ +package com.baeldung.concurrent.threadfactory; + +public class Task implements Runnable { + + @Override + public void run() { + // task details + } + +} From ffd66faa7d4f04946fad20f3fd8991649c82aa3d Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Wed, 19 Jul 2017 11:16:44 +0300 Subject: [PATCH 49/89] Refactor HttpClient (#2272) --- .../httpclient/HttpAsyncClientLiveTest.java | 9 +- .../httpclient/HttpClientHeadersLiveTest.java | 23 +---- .../HttpClientMultipartLiveTest.java | 87 +++++++++---------- .../httpclient/HttpClientPostingLiveTest.java | 40 ++++----- .../HttpClientRedirectLiveTest.java | 50 ++++------- .../httpclient/HttpClientTimeoutLiveTest.java | 35 +++----- .../httpclient/HttpsClientSslLiveTest.java | 17 ++-- .../httpclient/ProgressEntityWrapper.java | 6 +- .../org/baeldung/httpclient/ResponseUtil.java | 26 ++++++ ...tAdvancedConfigurationIntegrationTest.java | 43 +++++---- .../base/HttpClientBasicLiveTest.java | 29 ++----- .../base/HttpClientBasicPostLiveTest.java | 28 ++---- .../httpclient/base/HttpClientLiveTest.java | 16 +--- .../base/HttpClientSandboxLiveTest.java | 18 +--- ...ttpClientConnectionManagementLiveTest.java | 20 ++--- .../conn/IdleConnectionMonitorThread.java | 4 +- .../conn/MultiHttpClientConnThread.java | 10 +-- ...sterVersion_MultiHttpClientConnThread.java | 4 +- .../rare/HttpClientUnshortenLiveTest.java | 32 ++++--- .../sec/HttpClientAuthLiveTest.java | 47 ++++------ .../sec/HttpClientCookieLiveTest.java | 36 +++----- 21 files changed, 230 insertions(+), 350 deletions(-) create mode 100644 httpclient/src/test/java/org/baeldung/httpclient/ResponseUtil.java diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpAsyncClientLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpAsyncClientLiveTest.java index f2086f2633..d39697c0a9 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpAsyncClientLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpAsyncClientLiveTest.java @@ -101,12 +101,7 @@ public class HttpAsyncClientLiveTest { @Test public void whenUseSSLWithHttpAsyncClient_thenCorrect() throws Exception { - final TrustStrategy acceptingTrustStrategy = new TrustStrategy() { - @Override - public final boolean isTrusted(final X509Certificate[] certificate, final String authType) { - return true; - } - }; + final TrustStrategy acceptingTrustStrategy = (certificate, authType) -> true; final SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build(); final CloseableHttpAsyncClient client = HttpAsyncClients.custom().setSSLHostnameVerifier(SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER).setSSLContext(sslContext).build(); @@ -160,7 +155,7 @@ public class HttpAsyncClientLiveTest { private final HttpContext context; private final HttpGet request; - public GetThread(final CloseableHttpAsyncClient client, final HttpGet request) { + GetThread(final CloseableHttpAsyncClient client, final HttpGet request) { this.client = client; context = HttpClientContext.create(); this.request = request; diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientHeadersLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientHeadersLiveTest.java index ebd67512e4..51c3817da5 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientHeadersLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientHeadersLiveTest.java @@ -1,11 +1,7 @@ package org.baeldung.httpclient; -import java.io.IOException; -import java.io.InputStream; -import java.util.List; - +import com.google.common.collect.Lists; import org.apache.http.Header; -import org.apache.http.HttpEntity; import org.apache.http.HttpHeaders; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.CloseableHttpResponse; @@ -20,7 +16,8 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import com.google.common.collect.Lists; +import java.io.IOException; +import java.util.List; public class HttpClientHeadersLiveTest { @@ -37,19 +34,7 @@ public class HttpClientHeadersLiveTest { @After public final void after() throws IllegalStateException, IOException { - if (response == null) { - return; - } - - try { - final HttpEntity entity = response.getEntity(); - if (entity != null) { - final InputStream instream = entity.getContent(); - instream.close(); - } - } finally { - response.close(); - } + ResponseUtil.closeResponse(response); } // tests - headers - deprecated diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartLiveTest.java index 954236a56f..9912e73c2b 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientMultipartLiveTest.java @@ -1,22 +1,7 @@ package org.baeldung.httpclient; -import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.util.logging.Level; -import java.util.logging.Logger; - import org.apache.http.HttpEntity; import org.apache.http.HttpStatus; -import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; @@ -30,6 +15,20 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.logging.Level; +import java.util.logging.Logger; + +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + public class HttpClientMultipartLiveTest { // No longer available @@ -48,7 +47,7 @@ public class HttpClientMultipartLiveTest { @Before public final void before() { client = HttpClientBuilder.create() - .build(); + .build(); post = new HttpPost(SERVER); } @@ -67,15 +66,7 @@ public class HttpClientMultipartLiveTest { LOGGER.log(Level.SEVERE, e.getMessage(), e); throw e; } - try { - final HttpEntity entity = response.getEntity(); - if (entity != null) { - final InputStream instream = entity.getContent(); - instream.close(); - } - } finally { - response.close(); - } + ResponseUtil.closeResponse(response); } // tests @@ -83,8 +74,8 @@ public class HttpClientMultipartLiveTest { @Test public final void givenFileandMultipleTextParts_whenUploadwithAddPart_thenNoExceptions() throws IOException { final URL url = Thread.currentThread() - .getContextClassLoader() - .getResource("uploads/" + TEXTFILENAME); + .getContextClassLoader() + .getResource("uploads/" + TEXTFILENAME); final File file = new File(url.getPath()); final FileBody fileBody = new FileBody(file, ContentType.DEFAULT_BINARY); @@ -102,7 +93,7 @@ public class HttpClientMultipartLiveTest { response = client.execute(post); final int statusCode = response.getStatusLine() - .getStatusCode(); + .getStatusCode(); final String responseString = getContent(); final String contentTypeInHeader = getContentTypeHeader(); assertThat(statusCode, equalTo(HttpStatus.SC_OK)); @@ -113,10 +104,10 @@ public class HttpClientMultipartLiveTest { } @Test - public final void givenFileandTextPart_whenUploadwithAddBinaryBodyandAddTextBody_ThenNoExeption() throws ClientProtocolException, IOException { + public final void givenFileandTextPart_whenUploadwithAddBinaryBodyandAddTextBody_ThenNoExeption() throws IOException { final URL url = Thread.currentThread() - .getContextClassLoader() - .getResource("uploads/" + TEXTFILENAME); + .getContextClassLoader() + .getResource("uploads/" + TEXTFILENAME); final File file = new File(url.getPath()); final String message = "This is a multipart post"; final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); @@ -127,7 +118,7 @@ public class HttpClientMultipartLiveTest { post.setEntity(entity); response = client.execute(post); final int statusCode = response.getStatusLine() - .getStatusCode(); + .getStatusCode(); final String responseString = getContent(); final String contentTypeInHeader = getContentTypeHeader(); assertThat(statusCode, equalTo(HttpStatus.SC_OK)); @@ -138,13 +129,13 @@ public class HttpClientMultipartLiveTest { } @Test - public final void givenFileAndInputStreamandText_whenUploadwithAddBinaryBodyandAddTextBody_ThenNoException() throws ClientProtocolException, IOException { + public final void givenFileAndInputStreamandText_whenUploadwithAddBinaryBodyandAddTextBody_ThenNoException() throws IOException { final URL url = Thread.currentThread() - .getContextClassLoader() - .getResource("uploads/" + ZIPFILENAME); + .getContextClassLoader() + .getResource("uploads/" + ZIPFILENAME); final URL url2 = Thread.currentThread() - .getContextClassLoader() - .getResource("uploads/" + IMAGEFILENAME); + .getContextClassLoader() + .getResource("uploads/" + IMAGEFILENAME); final InputStream inputStream = new FileInputStream(url.getPath()); final File file = new File(url2.getPath()); final String message = "This is a multipart post"; @@ -157,7 +148,7 @@ public class HttpClientMultipartLiveTest { post.setEntity(entity); response = client.execute(post); final int statusCode = response.getStatusLine() - .getStatusCode(); + .getStatusCode(); final String responseString = getContent(); final String contentTypeInHeader = getContentTypeHeader(); assertThat(statusCode, equalTo(HttpStatus.SC_OK)); @@ -169,7 +160,7 @@ public class HttpClientMultipartLiveTest { } @Test - public final void givenCharArrayandText_whenUploadwithAddBinaryBodyandAddTextBody_ThenNoException() throws ClientProtocolException, IOException { + public final void givenCharArrayandText_whenUploadwithAddBinaryBodyandAddTextBody_ThenNoException() throws IOException { final String message = "This is a multipart post"; final byte[] bytes = "binary code".getBytes(); final MultipartEntityBuilder builder = MultipartEntityBuilder.create(); @@ -180,7 +171,7 @@ public class HttpClientMultipartLiveTest { post.setEntity(entity); response = client.execute(post); final int statusCode = response.getStatusLine() - .getStatusCode(); + .getStatusCode(); final String responseString = getContent(); final String contentTypeInHeader = getContentTypeHeader(); assertThat(statusCode, equalTo(HttpStatus.SC_OK)); @@ -192,21 +183,21 @@ public class HttpClientMultipartLiveTest { // UTIL - final String getContent() throws IOException { + private String getContent() throws IOException { rd = new BufferedReader(new InputStreamReader(response.getEntity() - .getContent())); + .getContent())); String body = ""; - String content = ""; + StringBuilder content = new StringBuilder(); while ((body = rd.readLine()) != null) { - content += body + "\n"; + content.append(body).append("\n"); } - return content.trim(); + return content.toString().trim(); } - final String getContentTypeHeader() throws IOException { + private String getContentTypeHeader() throws IOException { return post.getEntity() - .getContentType() - .toString(); + .getContentType() + .toString(); } } diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientPostingLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientPostingLiveTest.java index ad173f9cd8..39ed8f09ef 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientPostingLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientPostingLiveTest.java @@ -1,20 +1,10 @@ package org.baeldung.httpclient; -import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.auth.AuthenticationException; import org.apache.http.auth.UsernamePasswordCredentials; -import org.apache.http.client.ClientProtocolException; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.fluent.Form; import org.apache.http.client.fluent.Request; @@ -29,6 +19,15 @@ import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicNameValuePair; import org.junit.Test; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThat; + /* * NOTE : Need module spring-rest to be running */ @@ -39,7 +38,7 @@ public class HttpClientPostingLiveTest { private static final String DEFAULT_PASS = "test"; @Test - public void whenSendPostRequestUsingHttpClient_thenCorrect() throws ClientProtocolException, IOException { + public void whenSendPostRequestUsingHttpClient_thenCorrect() throws IOException { final CloseableHttpClient client = HttpClients.createDefault(); final HttpPost httpPost = new HttpPost(SAMPLE_URL); @@ -54,7 +53,7 @@ public class HttpClientPostingLiveTest { } @Test - public void whenSendPostRequestWithAuthorizationUsingHttpClient_thenCorrect() throws ClientProtocolException, IOException, AuthenticationException { + public void whenSendPostRequestWithAuthorizationUsingHttpClient_thenCorrect() throws IOException, AuthenticationException { final CloseableHttpClient client = HttpClients.createDefault(); final HttpPost httpPost = new HttpPost(URL_SECURED_BY_BASIC_AUTHENTICATION); @@ -68,7 +67,7 @@ public class HttpClientPostingLiveTest { } @Test - public void whenPostJsonUsingHttpClient_thenCorrect() throws ClientProtocolException, IOException { + public void whenPostJsonUsingHttpClient_thenCorrect() throws IOException { final CloseableHttpClient client = HttpClients.createDefault(); final HttpPost httpPost = new HttpPost(SAMPLE_URL + "/detail"); @@ -84,14 +83,14 @@ public class HttpClientPostingLiveTest { } @Test - public void whenPostFormUsingHttpClientFluentAPI_thenCorrect() throws ClientProtocolException, IOException { + public void whenPostFormUsingHttpClientFluentAPI_thenCorrect() throws IOException { final HttpResponse response = Request.Post(SAMPLE_URL).bodyForm(Form.form().add("username", DEFAULT_USER).add("password", DEFAULT_PASS).build()).execute().returnResponse(); assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); } @Test - public void whenSendMultipartRequestUsingHttpClient_thenCorrect() throws ClientProtocolException, IOException { + public void whenSendMultipartRequestUsingHttpClient_thenCorrect() throws IOException { final CloseableHttpClient client = HttpClients.createDefault(); final HttpPost httpPost = new HttpPost(SAMPLE_URL + "/multipart"); @@ -109,7 +108,7 @@ public class HttpClientPostingLiveTest { } @Test - public void whenUploadFileUsingHttpClient_thenCorrect() throws ClientProtocolException, IOException { + public void whenUploadFileUsingHttpClient_thenCorrect() throws IOException { final CloseableHttpClient client = HttpClients.createDefault(); final HttpPost httpPost = new HttpPost(SAMPLE_URL + "/upload"); @@ -125,7 +124,7 @@ public class HttpClientPostingLiveTest { } @Test - public void whenGetUploadFileProgressUsingHttpClient_thenCorrect() throws ClientProtocolException, IOException { + public void whenGetUploadFileProgressUsingHttpClient_thenCorrect() throws IOException { final CloseableHttpClient client = HttpClients.createDefault(); final HttpPost httpPost = new HttpPost(SAMPLE_URL + "/upload"); @@ -133,12 +132,7 @@ public class HttpClientPostingLiveTest { builder.addBinaryBody("file", new File("src/test/resources/test.in"), ContentType.APPLICATION_OCTET_STREAM, "file.ext"); final HttpEntity multipart = builder.build(); - final ProgressEntityWrapper.ProgressListener pListener = new ProgressEntityWrapper.ProgressListener() { - @Override - public void progress(final float percentage) { - assertFalse(Float.compare(percentage, 100) > 0); - } - }; + final ProgressEntityWrapper.ProgressListener pListener = percentage -> assertFalse(Float.compare(percentage, 100) > 0); httpPost.setEntity(new ProgressEntityWrapper(multipart, pListener)); diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientRedirectLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientRedirectLiveTest.java index 3cb02dc767..a501367a6b 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientRedirectLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientRedirectLiveTest.java @@ -1,13 +1,5 @@ package org.baeldung.httpclient; -import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; - -import java.io.IOException; -import java.io.InputStream; - -import org.apache.http.HttpEntity; -import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpHead; @@ -21,6 +13,12 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import java.io.IOException; +import java.util.Arrays; + +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; + public class HttpClientRedirectLiveTest { private CloseableHttpClient instance; @@ -34,25 +32,13 @@ public class HttpClientRedirectLiveTest { @After public final void after() throws IllegalStateException, IOException { - if (response == null) { - return; - } - - try { - final HttpEntity entity = response.getEntity(); - if (entity != null) { - final InputStream instream = entity.getContent(); - instream.close(); - } - } finally { - response.close(); - } + ResponseUtil.closeResponse(response); } // tests @Test - public final void givenRedirectsAreDisabledViaNewApi_whenConsumingUrlWhichRedirects_thenNotRedirected() throws ClientProtocolException, IOException { + public final void givenRedirectsAreDisabledViaNewApi_whenConsumingUrlWhichRedirects_thenNotRedirected() throws IOException { instance = HttpClients.custom().disableRedirectHandling().build(); final HttpGet httpGet = new HttpGet("http://t.co/I5YYd9tddw"); @@ -62,7 +48,7 @@ public class HttpClientRedirectLiveTest { } @Test - public final void givenRedirectsAreDisabled_whenConsumingUrlWhichRedirects_thenNotRedirected() throws ClientProtocolException, IOException { + public final void givenRedirectsAreDisabled_whenConsumingUrlWhichRedirects_thenNotRedirected() throws IOException { instance = HttpClientBuilder.create().disableRedirectHandling().build(); response = instance.execute(new HttpGet("http://t.co/I5YYd9tddw")); assertThat(response.getStatusLine().getStatusCode(), equalTo(301)); @@ -71,26 +57,22 @@ public class HttpClientRedirectLiveTest { // redirect with POST @Test - public final void givenPostRequest_whenConsumingUrlWhichRedirects_thenNotRedirected() throws ClientProtocolException, IOException { + public final void givenPostRequest_whenConsumingUrlWhichRedirects_thenNotRedirected() throws IOException { instance = HttpClientBuilder.create().build(); response = instance.execute(new HttpPost("http://t.co/I5YYd9tddw")); assertThat(response.getStatusLine().getStatusCode(), equalTo(301)); } @Test - public final void givenRedirectingPOSTViaPost4_2Api_whenConsumingUrlWhichRedirectsWithPOST_thenRedirected() throws ClientProtocolException, IOException { + public final void givenRedirectingPOSTViaPost4_2Api_whenConsumingUrlWhichRedirectsWithPOST_thenRedirected() throws IOException { final CloseableHttpClient client = HttpClients.custom().setRedirectStrategy(new DefaultRedirectStrategy() { /** Redirectable methods. */ - private final String[] REDIRECT_METHODS = new String[] { HttpGet.METHOD_NAME, HttpPost.METHOD_NAME, HttpHead.METHOD_NAME }; + private final String[] REDIRECT_METHODS = new String[]{HttpGet.METHOD_NAME, HttpPost.METHOD_NAME, HttpHead.METHOD_NAME}; @Override protected boolean isRedirectable(final String method) { - for (final String m : REDIRECT_METHODS) { - if (m.equalsIgnoreCase(method)) { - return true; - } - } - return false; + return Arrays.stream(REDIRECT_METHODS) + .anyMatch(m -> m.equalsIgnoreCase(method)); } }).build(); @@ -99,7 +81,7 @@ public class HttpClientRedirectLiveTest { } @Test - public final void givenRedirectingPOSTVia4_2Api_whenConsumingUrlWhichRedirectsWithPOST_thenRedirected() throws ClientProtocolException, IOException { + public final void givenRedirectingPOSTVia4_2Api_whenConsumingUrlWhichRedirectsWithPOST_thenRedirected() throws IOException { final CloseableHttpClient client = HttpClients.custom().setRedirectStrategy(new LaxRedirectStrategy()).build(); response = client.execute(new HttpPost("http://t.co/I5YYd9tddw")); @@ -107,7 +89,7 @@ public class HttpClientRedirectLiveTest { } @Test - public final void givenRedirectingPOST_whenConsumingUrlWhichRedirectsWithPOST_thenRedirected() throws ClientProtocolException, IOException { + public final void givenRedirectingPOST_whenConsumingUrlWhichRedirectsWithPOST_thenRedirected() throws IOException { instance = HttpClientBuilder.create().setRedirectStrategy(new LaxRedirectStrategy()).build(); response = instance.execute(new HttpPost("http://t.co/I5YYd9tddw")); assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientTimeoutLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientTimeoutLiveTest.java index 7e7dbe2146..74255e416c 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpClientTimeoutLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpClientTimeoutLiveTest.java @@ -1,13 +1,5 @@ package org.baeldung.httpclient; -import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; - -import java.io.IOException; -import java.io.InputStream; - -import org.apache.http.HttpEntity; -import org.apache.http.client.ClientProtocolException; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; @@ -18,31 +10,24 @@ import org.apache.http.impl.client.HttpClientBuilder; import org.junit.After; import org.junit.Test; +import java.io.IOException; + +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; + public class HttpClientTimeoutLiveTest { private CloseableHttpResponse response; @After public final void after() throws IllegalStateException, IOException { - if (response == null) { - return; - } - - try { - final HttpEntity entity = response.getEntity(); - if (entity != null) { - final InputStream instream = entity.getContent(); - instream.close(); - } - } finally { - response.close(); - } + ResponseUtil.closeResponse(response); } // tests @Test - public final void givenUsingNewApi_whenSettingTimeoutViaRequestConfig_thenCorrect() throws ClientProtocolException, IOException { + public final void givenUsingNewApi_whenSettingTimeoutViaRequestConfig_thenCorrect() throws IOException { final int timeout = 2; final RequestConfig config = RequestConfig.custom().setConnectTimeout(timeout * 1000).setConnectionRequestTimeout(timeout * 1000).setSocketTimeout(timeout * 1000).build(); final CloseableHttpClient client = HttpClientBuilder.create().setDefaultRequestConfig(config).build(); @@ -56,7 +41,7 @@ public class HttpClientTimeoutLiveTest { } @Test - public final void givenUsingNewApi_whenSettingTimeoutViaSocketConfig_thenCorrect() throws ClientProtocolException, IOException { + public final void givenUsingNewApi_whenSettingTimeoutViaSocketConfig_thenCorrect() throws IOException { final int timeout = 2; final SocketConfig config = SocketConfig.custom().setSoTimeout(timeout * 1000).build(); @@ -70,7 +55,7 @@ public class HttpClientTimeoutLiveTest { } @Test - public final void givenUsingNewApi_whenSettingTimeoutViaHighLevelApi_thenCorrect() throws ClientProtocolException, IOException { + public final void givenUsingNewApi_whenSettingTimeoutViaHighLevelApi_thenCorrect() throws IOException { final int timeout = 5; final RequestConfig config = RequestConfig.custom().setConnectTimeout(timeout * 1000).setConnectionRequestTimeout(timeout * 1000).setSocketTimeout(timeout * 1000).build(); @@ -87,7 +72,7 @@ public class HttpClientTimeoutLiveTest { * This simulates a timeout against a domain with multiple routes/IPs to it (not a single raw IP) */ @Test(expected = HttpHostConnectException.class) - public final void givenTimeoutIsConfigured_whenTimingOut_thenTimeoutException() throws ClientProtocolException, IOException { + public final void givenTimeoutIsConfigured_whenTimingOut_thenTimeoutException() throws IOException { final int timeout = 3; final RequestConfig config = RequestConfig.custom().setConnectTimeout(timeout * 1000).setConnectionRequestTimeout(timeout * 1000).setSocketTimeout(timeout * 1000).build(); diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java index 5dfecb85aa..4eadfe24d5 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java @@ -1,14 +1,5 @@ package org.baeldung.httpclient; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -import java.io.IOException; -import java.security.GeneralSecurityException; - -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLHandshakeException; - import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.conn.ClientConnectionManager; @@ -28,6 +19,14 @@ import org.apache.http.ssl.SSLContextBuilder; import org.apache.http.ssl.SSLContexts; import org.junit.Test; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLHandshakeException; +import java.io.IOException; +import java.security.GeneralSecurityException; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + /** * This test requires a localhost server over HTTPS
* It should only be manually run, not part of the automated build diff --git a/httpclient/src/test/java/org/baeldung/httpclient/ProgressEntityWrapper.java b/httpclient/src/test/java/org/baeldung/httpclient/ProgressEntityWrapper.java index f0b7e0e559..cd00d8711a 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/ProgressEntityWrapper.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/ProgressEntityWrapper.java @@ -10,7 +10,7 @@ import org.apache.http.entity.HttpEntityWrapper; public class ProgressEntityWrapper extends HttpEntityWrapper { private final ProgressListener listener; - public ProgressEntityWrapper(final HttpEntity entity, final ProgressListener listener) { + ProgressEntityWrapper(final HttpEntity entity, final ProgressListener listener) { super(entity); this.listener = listener; } @@ -20,7 +20,7 @@ public class ProgressEntityWrapper extends HttpEntityWrapper { super.writeTo(new CountingOutputStream(outstream, listener, getContentLength())); } - public static interface ProgressListener { + public interface ProgressListener { void progress(float percentage); } @@ -30,7 +30,7 @@ public class ProgressEntityWrapper extends HttpEntityWrapper { private long transferred; private long totalBytes; - public CountingOutputStream(final OutputStream out, final ProgressListener listener, final long totalBytes) { + CountingOutputStream(final OutputStream out, final ProgressListener listener, final long totalBytes) { super(out); this.listener = listener; transferred = 0; diff --git a/httpclient/src/test/java/org/baeldung/httpclient/ResponseUtil.java b/httpclient/src/test/java/org/baeldung/httpclient/ResponseUtil.java new file mode 100644 index 0000000000..fd38b95cbe --- /dev/null +++ b/httpclient/src/test/java/org/baeldung/httpclient/ResponseUtil.java @@ -0,0 +1,26 @@ +package org.baeldung.httpclient; + +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; + +import java.io.IOException; + +public final class ResponseUtil { + private ResponseUtil() { + } + + public static void closeResponse(CloseableHttpResponse response) throws IOException { + if (response == null) { + return; + } + + try { + final HttpEntity entity = response.getEntity(); + if (entity != null) { + entity.getContent().close(); + } + } finally { + response.close(); + } + } +} diff --git a/httpclient/src/test/java/org/baeldung/httpclient/advancedconfig/HttpClientAdvancedConfigurationIntegrationTest.java b/httpclient/src/test/java/org/baeldung/httpclient/advancedconfig/HttpClientAdvancedConfigurationIntegrationTest.java index b5a76241d1..77d5a298c1 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/advancedconfig/HttpClientAdvancedConfigurationIntegrationTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/advancedconfig/HttpClientAdvancedConfigurationIntegrationTest.java @@ -24,7 +24,14 @@ import org.junit.Test; import java.io.IOException; -import static com.github.tomakehurst.wiremock.client.WireMock.*; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.containing; +import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; import static org.junit.Assert.assertEquals; public class HttpClientAdvancedConfigurationIntegrationTest { @@ -40,9 +47,9 @@ public class HttpClientAdvancedConfigurationIntegrationTest { //given String userAgent = "BaeldungAgent/1.0"; serviceMock.stubFor(get(urlEqualTo("/detail")) - .withHeader("User-Agent", equalTo(userAgent)) - .willReturn(aResponse() - .withStatus(200))); + .withHeader("User-Agent", equalTo(userAgent)) + .willReturn(aResponse() + .withStatus(200))); HttpClient httpClient = HttpClients.createDefault(); HttpGet httpGet = new HttpGet("http://localhost:8089/detail"); @@ -60,10 +67,10 @@ public class HttpClientAdvancedConfigurationIntegrationTest { //given String xmlBody = "1"; serviceMock.stubFor(post(urlEqualTo("/person")) - .withHeader("Content-Type", equalTo("application/xml")) - .withRequestBody(equalTo(xmlBody)) - .willReturn(aResponse() - .withStatus(200))); + .withHeader("Content-Type", equalTo("application/xml")) + .withRequestBody(equalTo(xmlBody)) + .willReturn(aResponse() + .withStatus(200))); HttpClient httpClient = HttpClients.createDefault(); HttpPost httpPost = new HttpPost("http://localhost:8089/person"); @@ -83,17 +90,17 @@ public class HttpClientAdvancedConfigurationIntegrationTest { public void givenServerThatIsBehindProxy_whenClientIsConfiguredToSendRequestViaProxy_shouldReturn200() throws IOException { //given proxyMock.stubFor(get(urlMatching(".*")) - .willReturn(aResponse().proxiedFrom("http://localhost:8089/"))); + .willReturn(aResponse().proxiedFrom("http://localhost:8089/"))); serviceMock.stubFor(get(urlEqualTo("/private")) - .willReturn(aResponse().withStatus(200))); + .willReturn(aResponse().withStatus(200))); HttpHost proxy = new HttpHost("localhost", 8090); DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy); HttpClient httpclient = HttpClients.custom() - .setRoutePlanner(routePlanner) - .build(); + .setRoutePlanner(routePlanner) + .build(); //when final HttpGet httpGet = new HttpGet("http://localhost:8089/private"); @@ -109,9 +116,9 @@ public class HttpClientAdvancedConfigurationIntegrationTest { public void givenServerThatIsBehindAuthorizationProxy_whenClientSendRequest_shouldAuthorizeProperly() throws IOException { //given proxyMock.stubFor(get(urlMatching("/private")) - .willReturn(aResponse().proxiedFrom("http://localhost:8089/"))); + .willReturn(aResponse().proxiedFrom("http://localhost:8089/"))); serviceMock.stubFor(get(urlEqualTo("/private")) - .willReturn(aResponse().withStatus(200))); + .willReturn(aResponse().withStatus(200))); HttpHost proxy = new HttpHost("localhost", 8090); @@ -120,7 +127,7 @@ public class HttpClientAdvancedConfigurationIntegrationTest { // Client credentials CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); credentialsProvider.setCredentials(new AuthScope(proxy), - new UsernamePasswordCredentials("username_admin", "secret_password")); + new UsernamePasswordCredentials("username_admin", "secret_password")); // Create AuthCache instance @@ -135,9 +142,9 @@ public class HttpClientAdvancedConfigurationIntegrationTest { HttpClient httpclient = HttpClients.custom() - .setRoutePlanner(routePlanner) - .setDefaultCredentialsProvider(credentialsProvider) - .build(); + .setRoutePlanner(routePlanner) + .setDefaultCredentialsProvider(credentialsProvider) + .build(); //when diff --git a/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientBasicLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientBasicLiveTest.java index 2a101ec816..fee9dc4343 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientBasicLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientBasicLiveTest.java @@ -1,13 +1,5 @@ package org.baeldung.httpclient.base; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.notNullValue; -import static org.junit.Assert.assertThat; - -import java.io.IOException; -import java.io.InputStream; - -import org.apache.http.HttpEntity; import org.apache.http.HttpStatus; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.CloseableHttpResponse; @@ -16,10 +8,17 @@ import org.apache.http.entity.ContentType; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; +import org.baeldung.httpclient.ResponseUtil; import org.junit.After; import org.junit.Before; import org.junit.Test; +import java.io.IOException; + +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.notNullValue; +import static org.junit.Assert.assertThat; + public class HttpClientBasicLiveTest { private static final String SAMPLE_URL = "http://www.github.com"; @@ -35,19 +34,7 @@ public class HttpClientBasicLiveTest { @After public final void after() throws IllegalStateException, IOException { - if (response == null) { - return; - } - - try { - final HttpEntity entity = response.getEntity(); - if (entity != null) { - final InputStream instream = entity.getContent(); - instream.close(); - } - } finally { - response.close(); - } + ResponseUtil.closeResponse(response); } // tests diff --git a/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientBasicPostLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientBasicPostLiveTest.java index 7eb078b18b..fe275be082 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientBasicPostLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientBasicPostLiveTest.java @@ -1,22 +1,20 @@ package org.baeldung.httpclient.base; -import java.io.IOException; -import java.io.InputStream; - -import org.apache.http.HttpEntity; import org.apache.http.auth.AuthenticationException; import org.apache.http.auth.UsernamePasswordCredentials; -import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.auth.BasicScheme; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; +import org.baeldung.httpclient.ResponseUtil; import org.junit.After; import org.junit.Before; import org.junit.Test; +import java.io.IOException; + public class HttpClientBasicPostLiveTest { private static final String SAMPLE_URL = "http://www.github.com"; @@ -32,37 +30,25 @@ public class HttpClientBasicPostLiveTest { @After public final void after() throws IllegalStateException, IOException { - if (response == null) { - return; - } - - try { - final HttpEntity entity = response.getEntity(); - if (entity != null) { - final InputStream instream = entity.getContent(); - instream.close(); - } - } finally { - response.close(); - } + ResponseUtil.closeResponse(response); } // tests - non-GET @Test - public final void whenExecutingPostRequest_thenNoExceptions() throws ClientProtocolException, IOException { + public final void whenExecutingPostRequest_thenNoExceptions() throws IOException { instance.execute(new HttpPost(SAMPLE_URL)); } @Test - public final void whenExecutingPostRequestWithBody_thenNoExceptions() throws ClientProtocolException, IOException { + public final void whenExecutingPostRequestWithBody_thenNoExceptions() throws IOException { final HttpPost request = new HttpPost(SAMPLE_URL); request.setEntity(new StringEntity("in the body of the POST")); instance.execute(request); } @Test - public final void givenAuth_whenExecutingPostRequestWithBody_thenNoExceptions() throws ClientProtocolException, IOException, AuthenticationException { + public final void givenAuth_whenExecutingPostRequestWithBody_thenNoExceptions() throws IOException, AuthenticationException { final HttpPost request = new HttpPost(SAMPLE_URL); request.setEntity(new StringEntity("in the body of the POST")); final UsernamePasswordCredentials creds = new UsernamePasswordCredentials("username", "password"); diff --git a/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientLiveTest.java index 878d220f67..78097227e7 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientLiveTest.java @@ -11,12 +11,12 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.conn.BasicHttpClientConnectionManager; +import org.baeldung.httpclient.ResponseUtil; import org.junit.After; import org.junit.Before; import org.junit.Test; import java.io.IOException; -import java.io.InputStream; import static org.hamcrest.Matchers.emptyArray; import static org.hamcrest.Matchers.not; @@ -37,19 +37,7 @@ public class HttpClientLiveTest { @After public final void after() throws IllegalStateException, IOException { - if (response == null) { - return; - } - - try { - final HttpEntity entity = response.getEntity(); - if (entity != null) { - final InputStream instream = entity.getContent(); - instream.close(); - } - } finally { - response.close(); - } + ResponseUtil.closeResponse(response); } // tests diff --git a/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientSandboxLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientSandboxLiveTest.java index 40216a70a5..d945d075f2 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientSandboxLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientSandboxLiveTest.java @@ -1,9 +1,5 @@ package org.baeldung.httpclient.base; -import java.io.IOException; -import java.io.InputStream; - -import org.apache.http.HttpEntity; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.CredentialsProvider; @@ -12,8 +8,11 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; +import org.baeldung.httpclient.ResponseUtil; import org.junit.Test; +import java.io.IOException; + /* * NOTE : Need module spring-security-rest-basic-auth to be running */ @@ -32,15 +31,6 @@ public class HttpClientSandboxLiveTest { System.out.println(response.getStatusLine()); - try { - final HttpEntity entity = response.getEntity(); - if (entity != null) { - // EntityUtils.consume(entity); - final InputStream instream = entity.getContent(); - instream.close(); - } - } finally { - response.close(); - } + ResponseUtil.closeResponse(response); } } diff --git a/httpclient/src/test/java/org/baeldung/httpclient/conn/HttpClientConnectionManagementLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/conn/HttpClientConnectionManagementLiveTest.java index e04cd32d65..0f8ebefe6c 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/conn/HttpClientConnectionManagementLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/conn/HttpClientConnectionManagementLiveTest.java @@ -1,11 +1,5 @@ package org.baeldung.httpclient.conn; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; - import org.apache.http.HeaderElement; import org.apache.http.HeaderElementIterator; import org.apache.http.HttpClientConnection; @@ -36,6 +30,12 @@ import org.junit.Before; import org.junit.Ignore; import org.junit.Test; +import java.io.IOException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertTrue; + public class HttpClientConnectionManagementLiveTest { private static final String SERVER1 = "http://www.petrikainulainen.net/"; private static final String SERVER7 = "http://www.baeldung.com/"; @@ -129,7 +129,7 @@ public class HttpClientConnectionManagementLiveTest { @Test // @Ignore // Example 3.2. TESTER VERSION - /*tester*/public final void whenTwoConnectionsForTwoRequests_thenTwoConnectionsAreLeased() throws InterruptedException { + /*tester*/ public final void whenTwoConnectionsForTwoRequests_thenTwoConnectionsAreLeased() throws InterruptedException { poolingConnManager = new PoolingHttpClientConnectionManager(); final CloseableHttpClient client1 = HttpClients.custom().setConnectionManager(poolingConnManager).build(); final CloseableHttpClient client2 = HttpClients.custom().setConnectionManager(poolingConnManager).build(); @@ -173,7 +173,7 @@ public class HttpClientConnectionManagementLiveTest { @Test // @Ignore // 4.2 Tester Version - /*tester*/public final void whenExecutingSameRequestsInDifferentThreads_thenUseDefaultConnLimit() throws InterruptedException, IOException { + /*tester*/ public final void whenExecutingSameRequestsInDifferentThreads_thenUseDefaultConnLimit() throws InterruptedException, IOException { poolingConnManager = new PoolingHttpClientConnectionManager(); client = HttpClients.custom().setConnectionManager(poolingConnManager).build(); final TesterVersion_MultiHttpClientConnThread thread1 = new TesterVersion_MultiHttpClientConnThread(client, new HttpGet("http://www.google.com"), poolingConnManager); @@ -266,7 +266,7 @@ public class HttpClientConnectionManagementLiveTest { @Test // @Ignore // 6.2 TESTER VERSION - /*tester*/public final void whenConnectionsNeededGreaterThanMaxTotal_thenReuseConnections() throws InterruptedException { + /*tester*/ public final void whenConnectionsNeededGreaterThanMaxTotal_thenReuseConnections() throws InterruptedException { poolingConnManager = new PoolingHttpClientConnectionManager(); poolingConnManager.setDefaultMaxPerRoute(5); poolingConnManager.setMaxTotal(5); @@ -333,7 +333,7 @@ public class HttpClientConnectionManagementLiveTest { @Test @Ignore("Very Long Running") // 8.2 TESTER VERSION - /*tester*/public final void whenCustomizedIdleConnMonitor_thenEliminateIdleConns() throws InterruptedException, IOException { + /*tester*/ public final void whenCustomizedIdleConnMonitor_thenEliminateIdleConns() throws InterruptedException, IOException { poolingConnManager = new PoolingHttpClientConnectionManager(); client = HttpClients.custom().setConnectionManager(poolingConnManager).build(); final IdleConnectionMonitorThread staleMonitor = new IdleConnectionMonitorThread(poolingConnManager); diff --git a/httpclient/src/test/java/org/baeldung/httpclient/conn/IdleConnectionMonitorThread.java b/httpclient/src/test/java/org/baeldung/httpclient/conn/IdleConnectionMonitorThread.java index 2a1c419e41..ffe4155a78 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/conn/IdleConnectionMonitorThread.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/conn/IdleConnectionMonitorThread.java @@ -9,7 +9,7 @@ public class IdleConnectionMonitorThread extends Thread { private final HttpClientConnectionManager connMgr; private volatile boolean shutdown; - public IdleConnectionMonitorThread(final PoolingHttpClientConnectionManager connMgr) { + IdleConnectionMonitorThread(final PoolingHttpClientConnectionManager connMgr) { super(); this.connMgr = connMgr; } @@ -31,7 +31,7 @@ public class IdleConnectionMonitorThread extends Thread { } } - public final void shutdown() { + private void shutdown() { shutdown = true; synchronized (this) { notifyAll(); diff --git a/httpclient/src/test/java/org/baeldung/httpclient/conn/MultiHttpClientConnThread.java b/httpclient/src/test/java/org/baeldung/httpclient/conn/MultiHttpClientConnThread.java index 071b964710..3794943f02 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/conn/MultiHttpClientConnThread.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/conn/MultiHttpClientConnThread.java @@ -18,23 +18,23 @@ public class MultiHttpClientConnThread extends Thread { private final HttpGet get; private PoolingHttpClientConnectionManager connManager; - public int leasedConn; + private int leasedConn; - public MultiHttpClientConnThread(final CloseableHttpClient client, final HttpGet get, final PoolingHttpClientConnectionManager connManager) { + MultiHttpClientConnThread(final CloseableHttpClient client, final HttpGet get, final PoolingHttpClientConnectionManager connManager) { this.client = client; this.get = get; this.connManager = connManager; leasedConn = 0; } - public MultiHttpClientConnThread(final CloseableHttpClient client, final HttpGet get) { + MultiHttpClientConnThread(final CloseableHttpClient client, final HttpGet get) { this.client = client; this.get = get; } // API - public final int getLeasedConn() { + final int getLeasedConn() { return leasedConn; } @@ -61,8 +61,6 @@ public class MultiHttpClientConnThread extends Thread { } EntityUtils.consume(response.getEntity()); - } catch (final ClientProtocolException ex) { - logger.error("", ex); } catch (final IOException ex) { logger.error("", ex); } diff --git a/httpclient/src/test/java/org/baeldung/httpclient/conn/TesterVersion_MultiHttpClientConnThread.java b/httpclient/src/test/java/org/baeldung/httpclient/conn/TesterVersion_MultiHttpClientConnThread.java index 62cd466596..9cc6480e74 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/conn/TesterVersion_MultiHttpClientConnThread.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/conn/TesterVersion_MultiHttpClientConnThread.java @@ -18,7 +18,7 @@ public class TesterVersion_MultiHttpClientConnThread extends Thread { private final HttpGet get; private PoolingHttpClientConnectionManager connManager; - public TesterVersion_MultiHttpClientConnThread(final CloseableHttpClient client, final HttpGet get, final PoolingHttpClientConnectionManager connManager) { + TesterVersion_MultiHttpClientConnThread(final CloseableHttpClient client, final HttpGet get, final PoolingHttpClientConnectionManager connManager) { this.client = client; this.get = get; this.connManager = Preconditions.checkNotNull(connManager); @@ -38,8 +38,6 @@ public class TesterVersion_MultiHttpClientConnThread extends Thread { logger.info("After - Leased Connections = " + connManager.getTotalStats().getLeased()); logger.info("After - Available Connections = " + connManager.getTotalStats().getAvailable()); - } catch (final ClientProtocolException ex) { - logger.error("", ex); } catch (final IOException ex) { logger.error("", ex); } diff --git a/httpclient/src/test/java/org/baeldung/httpclient/rare/HttpClientUnshortenLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/rare/HttpClientUnshortenLiveTest.java index a185e99639..8fc79baed9 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/rare/HttpClientUnshortenLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/rare/HttpClientUnshortenLiveTest.java @@ -1,12 +1,7 @@ package org.baeldung.httpclient.rare; -import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; - -import java.io.IOException; -import java.io.InputStream; -import java.util.List; - +import com.google.common.base.Preconditions; +import com.google.common.collect.Lists; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; import org.apache.http.Header; @@ -20,8 +15,12 @@ import org.apache.http.util.EntityUtils; import org.junit.Before; import org.junit.Test; -import com.google.common.base.Preconditions; -import com.google.common.collect.Lists; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; + +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; public class HttpClientUnshortenLiveTest { @@ -52,7 +51,7 @@ public class HttpClientUnshortenLiveTest { // API - final String expand(final String urlArg) throws IOException { + private String expand(final String urlArg) throws IOException { String originalUrl = urlArg; String newUrl = expandSingleLevel(originalUrl); while (!originalUrl.equals(newUrl)) { @@ -81,7 +80,7 @@ public class HttpClientUnshortenLiveTest { return newUrl; } - final Pair expandSingleLevelSafe(final String url) throws IOException { + private Pair expandSingleLevelSafe(final String url) throws IOException { HttpHead request = null; HttpEntity httpEntity = null; InputStream entityContentStream = null; @@ -95,15 +94,15 @@ public class HttpClientUnshortenLiveTest { final int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != 301 && statusCode != 302) { - return new ImmutablePair(statusCode, url); + return new ImmutablePair<>(statusCode, url); } final Header[] headers = httpResponse.getHeaders(HttpHeaders.LOCATION); Preconditions.checkState(headers.length == 1); final String newUrl = headers[0].getValue(); - return new ImmutablePair(statusCode, newUrl); + return new ImmutablePair<>(statusCode, newUrl); } catch (final IllegalArgumentException uriEx) { - return new ImmutablePair(500, url); + return new ImmutablePair<>(500, url); } finally { if (request != null) { request.releaseConnection(); @@ -117,7 +116,7 @@ public class HttpClientUnshortenLiveTest { } } - final String expandSingleLevel(final String url) throws IOException { + private String expandSingleLevel(final String url) throws IOException { HttpHead request = null; try { @@ -130,9 +129,8 @@ public class HttpClientUnshortenLiveTest { } final Header[] headers = httpResponse.getHeaders(HttpHeaders.LOCATION); Preconditions.checkState(headers.length == 1); - final String newUrl = headers[0].getValue(); - return newUrl; + return headers[0].getValue(); } catch (final IllegalArgumentException uriEx) { return url; } finally { diff --git a/httpclient/src/test/java/org/baeldung/httpclient/sec/HttpClientAuthLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/sec/HttpClientAuthLiveTest.java index e98dd4d14f..7a75729ea5 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/sec/HttpClientAuthLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/sec/HttpClientAuthLiveTest.java @@ -1,21 +1,12 @@ package org.baeldung.httpclient.sec; -import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; - -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.Charset; - import org.apache.commons.codec.binary.Base64; -import org.apache.http.HttpEntity; import org.apache.http.HttpHeaders; import org.apache.http.HttpHost; import org.apache.http.HttpStatus; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.AuthCache; -import org.apache.http.client.ClientProtocolException; import org.apache.http.client.CredentialsProvider; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; @@ -26,10 +17,17 @@ import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.protocol.HttpContext; +import org.baeldung.httpclient.ResponseUtil; import org.junit.After; import org.junit.Before; import org.junit.Test; +import java.io.IOException; +import java.nio.charset.Charset; + +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; + /* * NOTE : Need module spring-security-rest-basic-auth to be running */ @@ -51,25 +49,13 @@ public class HttpClientAuthLiveTest { @After public final void after() throws IllegalStateException, IOException { - if (response == null) { - return; - } - - try { - final HttpEntity entity = response.getEntity(); - if (entity != null) { - final InputStream instream = entity.getContent(); - instream.close(); - } - } finally { - response.close(); - } + ResponseUtil.closeResponse(response); } // tests @Test - public final void whenExecutingBasicGetRequestWithBasicAuthenticationEnabled_thenSuccess() throws ClientProtocolException, IOException { + public final void whenExecutingBasicGetRequestWithBasicAuthenticationEnabled_thenSuccess() throws IOException { client = HttpClientBuilder.create().setDefaultCredentialsProvider(provider()).build(); response = client.execute(new HttpGet(URL_SECURED_BY_BASIC_AUTHENTICATION)); @@ -79,7 +65,7 @@ public class HttpClientAuthLiveTest { } @Test - public final void givenAuthenticationIsPreemptive_whenExecutingBasicGetRequestWithBasicAuthenticationEnabled_thenSuccess() throws ClientProtocolException, IOException { + public final void givenAuthenticationIsPreemptive_whenExecutingBasicGetRequestWithBasicAuthenticationEnabled_thenSuccess() throws IOException { client = HttpClientBuilder.create().build(); response = client.execute(new HttpGet(URL_SECURED_BY_BASIC_AUTHENTICATION), context()); @@ -88,7 +74,7 @@ public class HttpClientAuthLiveTest { } @Test - public final void givenAuthorizationHeaderIsSetManually_whenExecutingGetRequest_thenSuccess() throws ClientProtocolException, IOException { + public final void givenAuthorizationHeaderIsSetManually_whenExecutingGetRequest_thenSuccess() throws IOException { client = HttpClientBuilder.create().build(); final HttpGet request = new HttpGet(URL_SECURED_BY_BASIC_AUTHENTICATION); @@ -100,7 +86,7 @@ public class HttpClientAuthLiveTest { } @Test - public final void givenAuthorizationHeaderIsSetManually_whenExecutingGetRequest_thenSuccess2() throws ClientProtocolException, IOException { + public final void givenAuthorizationHeaderIsSetManually_whenExecutingGetRequest_thenSuccess2() throws IOException { final HttpGet request = new HttpGet(URL_SECURED_BY_BASIC_AUTHENTICATION); final String auth = DEFAULT_USER + ":" + DEFAULT_PASS; final byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("ISO-8859-1"))); @@ -116,14 +102,14 @@ public class HttpClientAuthLiveTest { // UTILS - private final CredentialsProvider provider() { + private CredentialsProvider provider() { final CredentialsProvider provider = new BasicCredentialsProvider(); final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(DEFAULT_USER, DEFAULT_PASS); provider.setCredentials(AuthScope.ANY, credentials); return provider; } - private final HttpContext context() { + private HttpContext context() { final HttpHost targetHost = new HttpHost("localhost", 8080, "http"); final CredentialsProvider credsProvider = new BasicCredentialsProvider(); credsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(DEFAULT_USER, DEFAULT_PASS)); @@ -141,12 +127,11 @@ public class HttpClientAuthLiveTest { return context; } - private final String authorizationHeader(final String username, final String password) { + private String authorizationHeader(final String username, final String password) { final String auth = username + ":" + password; final byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("ISO-8859-1"))); - final String authHeader = "Basic " + new String(encodedAuth); - return authHeader; + return "Basic " + new String(encodedAuth); } } diff --git a/httpclient/src/test/java/org/baeldung/httpclient/sec/HttpClientCookieLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/sec/HttpClientCookieLiveTest.java index 7da9ad04e4..ba27aca08d 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/sec/HttpClientCookieLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/sec/HttpClientCookieLiveTest.java @@ -1,13 +1,5 @@ package org.baeldung.httpclient.sec; -import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; - -import java.io.IOException; -import java.io.InputStream; - -import org.apache.http.HttpEntity; -import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; @@ -18,10 +10,16 @@ import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.cookie.BasicClientCookie; import org.apache.http.protocol.BasicHttpContext; import org.apache.http.protocol.HttpContext; +import org.baeldung.httpclient.ResponseUtil; import org.junit.After; import org.junit.Before; import org.junit.Test; +import java.io.IOException; + +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; + public class HttpClientCookieLiveTest { private CloseableHttpClient instance; @@ -35,25 +33,13 @@ public class HttpClientCookieLiveTest { @After public final void after() throws IllegalStateException, IOException { - if (response == null) { - return; - } - - try { - final HttpEntity entity = response.getEntity(); - if (entity != null) { - final InputStream instream = entity.getContent(); - instream.close(); - } - } finally { - response.close(); - } + ResponseUtil.closeResponse(response); } // tests @Test - public final void whenSettingCookiesOnARequest_thenCorrect() throws ClientProtocolException, IOException { + public final void whenSettingCookiesOnARequest_thenCorrect() throws IOException { instance = HttpClientBuilder.create().build(); final HttpGet request = new HttpGet("http://www.github.com"); request.setHeader("Cookie", "JSESSIONID=1234"); @@ -64,7 +50,7 @@ public class HttpClientCookieLiveTest { } @Test - public final void givenUsingDeprecatedApi_whenSettingCookiesOnTheHttpClient_thenCorrect() throws ClientProtocolException, IOException { + public final void givenUsingDeprecatedApi_whenSettingCookiesOnTheHttpClient_thenCorrect() throws IOException { final BasicCookieStore cookieStore = new BasicCookieStore(); final BasicClientCookie cookie = new BasicClientCookie("JSESSIONID", "1234"); cookie.setDomain(".github.com"); @@ -80,7 +66,7 @@ public class HttpClientCookieLiveTest { } @Test - public final void whenSettingCookiesOnTheHttpClient_thenCookieSentCorrectly() throws ClientProtocolException, IOException { + public final void whenSettingCookiesOnTheHttpClient_thenCookieSentCorrectly() throws IOException { final BasicCookieStore cookieStore = new BasicCookieStore(); final BasicClientCookie cookie = new BasicClientCookie("JSESSIONID", "1234"); cookie.setDomain(".github.com"); @@ -96,7 +82,7 @@ public class HttpClientCookieLiveTest { } @Test - public final void whenSettingCookiesOnTheRequest_thenCookieSentCorrectly() throws ClientProtocolException, IOException { + public final void whenSettingCookiesOnTheRequest_thenCookieSentCorrectly() throws IOException { final BasicCookieStore cookieStore = new BasicCookieStore(); final BasicClientCookie cookie = new BasicClientCookie("JSESSIONID", "1234"); cookie.setDomain(".github.com"); From 600d610ddfef9390ff90b8532c76ff3e4c7867db Mon Sep 17 00:00:00 2001 From: lor6 Date: Wed, 19 Jul 2017 23:46:42 +0300 Subject: [PATCH 50/89] add libs repo (#2288) --- vavr/pom.xml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/vavr/pom.xml b/vavr/pom.xml index cbf2a37ec9..d35a408389 100644 --- a/vavr/pom.xml +++ b/vavr/pom.xml @@ -51,8 +51,20 @@ true + + snapshots + libs-snapshot + https://repo.spring.io/libs-snapshot + - + + + + spring-snapshots + http://repo.spring.io/snapshot + + + 1.8 0.9.0 From b558adec06cf97a63a4474e63c57b651b003abbe Mon Sep 17 00:00:00 2001 From: Nikhil Khatwani Date: Thu, 20 Jul 2017 08:24:43 +0530 Subject: [PATCH 51/89] Changes for BAEL-1050: Added new field (#2282) --- .../com/baeldung/deserialization/AppleProduct.java | 10 +++++++--- .../deserialization/DeserializationUtility.java | 3 ++- .../deserialization/SerializationUtility.java | 1 + .../deserialization/DeserializationUnitTest.java | 13 +++++++------ 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/core-java/src/main/java/com/baeldung/deserialization/AppleProduct.java b/core-java/src/main/java/com/baeldung/deserialization/AppleProduct.java index d672b9a4f5..a10499b362 100644 --- a/core-java/src/main/java/com/baeldung/deserialization/AppleProduct.java +++ b/core-java/src/main/java/com/baeldung/deserialization/AppleProduct.java @@ -4,12 +4,12 @@ import java.io.Serializable; public class AppleProduct implements Serializable { - private static final long serialVersionUID = 1234567L; // user-defined (i.e. not default or generated) -// private static final long serialVersionUID = 7654321L; // user-defined (i.e. not default or generated) + private static final long serialVersionUID = 1234567L; // user-defined (i.e. not default or generated) + // private static final long serialVersionUID = 7654321L; // user-defined (i.e. not default or generated) public String headphonePort; public String thunderboltPort; - public String lighteningPort; + public String lightningPort; public String getHeadphonePort() { return headphonePort; @@ -23,4 +23,8 @@ public class AppleProduct implements Serializable { return serialVersionUID; } + public String getLightningPort() { + return lightningPort; + } + } \ No newline at end of file diff --git a/core-java/src/main/java/com/baeldung/deserialization/DeserializationUtility.java b/core-java/src/main/java/com/baeldung/deserialization/DeserializationUtility.java index 3ed2b8be1d..ad8e929898 100644 --- a/core-java/src/main/java/com/baeldung/deserialization/DeserializationUtility.java +++ b/core-java/src/main/java/com/baeldung/deserialization/DeserializationUtility.java @@ -9,11 +9,12 @@ public class DeserializationUtility { public static void main(String[] args) throws ClassNotFoundException, IOException { - String serializedObj = "rO0ABXNyACljb20uYmFlbGR1bmcuZGVzZXJpYWxpemF0aW9uLkFwcGxlUHJvZHVjdAAAAAAAEtaHAgADTAANaGVhZHBob25lUG9ydHQAEkxqYXZhL2xhbmcvU3RyaW5nO0wADmxpZ2h0ZW5pbmdQb3J0cQB+AAFMAA90aHVuZGVyYm9sdFBvcnRxAH4AAXhwdAARaGVhZHBob25lUG9ydDIwMjBwdAATdGh1bmRlcmJvbHRQb3J0MjAyMA=="; + String serializedObj = "rO0ABXNyACljb20uYmFlbGR1bmcuZGVzZXJpYWxpemF0aW9uLkFwcGxlUHJvZHVjdAAAAAAAEtaHAgADTAANaGVhZHBob25lUG9ydHQAEkxqYXZhL2xhbmcvU3RyaW5nO0wADWxpZ2h0bmluZ1BvcnRxAH4AAUwAD3RodW5kZXJib2x0UG9ydHEAfgABeHB0ABFoZWFkcGhvbmVQb3J0MjAyMHQAEWxpZ2h0bmluZ1BvcnQyMDIwdAATdGh1bmRlcmJvbHRQb3J0MjAyMA=="; System.out.println("Deserializing AppleProduct..."); AppleProduct deserializedObj = (AppleProduct) deSerializeObjectFromString(serializedObj); System.out.println("Headphone port of AppleProduct:" + deserializedObj.getHeadphonePort()); System.out.println("Thunderbolt port of AppleProduct:" + deserializedObj.getThunderboltPort()); + System.out.println("LightningPort port of AppleProduct:" + deserializedObj.getLightningPort()); } public static Object deSerializeObjectFromString(String s) throws IOException, ClassNotFoundException { diff --git a/core-java/src/main/java/com/baeldung/deserialization/SerializationUtility.java b/core-java/src/main/java/com/baeldung/deserialization/SerializationUtility.java index 1dbcc40e6b..aa7f66659a 100644 --- a/core-java/src/main/java/com/baeldung/deserialization/SerializationUtility.java +++ b/core-java/src/main/java/com/baeldung/deserialization/SerializationUtility.java @@ -13,6 +13,7 @@ public class SerializationUtility { AppleProduct macBook = new AppleProduct(); macBook.headphonePort = "headphonePort2020"; macBook.thunderboltPort = "thunderboltPort2020"; + macBook.lightningPort = "lightningPort2020"; String serializedObj = serializeObjectToString(macBook); System.out.println("Serialized AppleProduct object to string:"); diff --git a/core-java/src/test/java/com/baeldung/deserialization/DeserializationUnitTest.java b/core-java/src/test/java/com/baeldung/deserialization/DeserializationUnitTest.java index 887e7e41da..d7c1ee17d4 100644 --- a/core-java/src/test/java/com/baeldung/deserialization/DeserializationUnitTest.java +++ b/core-java/src/test/java/com/baeldung/deserialization/DeserializationUnitTest.java @@ -12,7 +12,7 @@ import org.junit.Test; public class DeserializationUnitTest { - private static final String serializedObj = "rO0ABXNyACljb20uYmFlbGR1bmcuZGVzZXJpYWxpemF0aW9uLkFwcGxlUHJvZHVjdAAAAAAAEtaHAgADTAANaGVhZHBob25lUG9ydHQAEkxqYXZhL2xhbmcvU3RyaW5nO0wADmxpZ2h0ZW5pbmdQb3J0cQB+AAFMAA90aHVuZGVyYm9sdFBvcnRxAH4AAXhwdAARaGVhZHBob25lUG9ydDIwMjBwdAATdGh1bmRlcmJvbHRQb3J0MjAyMA=="; + private static final String serializedObj = "rO0ABXNyACljb20uYmFlbGR1bmcuZGVzZXJpYWxpemF0aW9uLkFwcGxlUHJvZHVjdAAAAAAAdMuxAgADTAANaGVhZHBob25lUG9ydHQAEkxqYXZhL2xhbmcvU3RyaW5nO0wADWxpZ2h0bmluZ1BvcnRxAH4AAUwAD3RodW5kZXJib2x0UG9ydHEAfgABeHB0ABFoZWFkcGhvbmVQb3J0MjAyMHQAEWxpZ2h0bmluZ1BvcnQyMDIwdAATdGh1bmRlcmJvbHRQb3J0MjAyMA"; private static long userDefinedSerialVersionUID = 1234567L; @@ -25,20 +25,22 @@ public class DeserializationUnitTest { public void testDeserializeObj_compatible() throws IOException, ClassNotFoundException { assertEquals(userDefinedSerialVersionUID, AppleProduct.getSerialVersionUID()); - + AppleProduct macBook = new AppleProduct(); macBook.headphonePort = "headphonePort2020"; macBook.thunderboltPort = "thunderboltPort2020"; - + macBook.lightningPort = "lightningPort2020"; + // serializes the "AppleProduct" object String serializedProduct = SerializationUtility.serializeObjectToString(macBook); // deserializes the "AppleProduct" object AppleProduct deserializedProduct = (AppleProduct) DeserializationUtility.deSerializeObjectFromString(serializedProduct); - + assertTrue(deserializedProduct.headphonePort.equalsIgnoreCase(macBook.headphonePort)); assertTrue(deserializedProduct.thunderboltPort.equalsIgnoreCase(macBook.thunderboltPort)); - + assertTrue(deserializedProduct.lightningPort.equalsIgnoreCase(macBook.lightningPort)); + } /** @@ -59,7 +61,6 @@ public class DeserializationUnitTest { public void testDeserializeObj_incompatible() throws ClassNotFoundException, IOException { assertNotEquals(userDefinedSerialVersionUID, AppleProduct.getSerialVersionUID()); - // attempts to deserialize the "AppleProduct" object DeserializationUtility.deSerializeObjectFromString(serializedObj); } From 7d369725709350a7278bee5d119375c5fba9e2dd Mon Sep 17 00:00:00 2001 From: Jesus Boadas Date: Thu, 20 Jul 2017 10:13:42 -0400 Subject: [PATCH 52/89] changed thread for ScheduledExecutorService (#2297) --- .../java/com/baeldung/vaadin/VaadinUI.java | 29 +++++-------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/libraries/src/main/java/com/baeldung/vaadin/VaadinUI.java b/libraries/src/main/java/com/baeldung/vaadin/VaadinUI.java index 8343d38f6a..68e2ca7944 100644 --- a/libraries/src/main/java/com/baeldung/vaadin/VaadinUI.java +++ b/libraries/src/main/java/com/baeldung/vaadin/VaadinUI.java @@ -4,6 +4,9 @@ import java.time.Instant; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; import javax.servlet.annotation.WebServlet; @@ -216,7 +219,11 @@ public class VaadinUI extends UI { timeLayout.addComponent(currentTime); serverPushPanel.setContent(timeLayout); serverPushPanel.setSizeUndefined(); - new ServerPushThread().start(); + ScheduledExecutorService scheduleExecutor = Executors.newScheduledThreadPool(1); + Runnable task = () -> { + currentTime.setValue("Current Time : " + Instant.now()); + }; + scheduleExecutor.scheduleWithFixedDelay(task, 0, 1, TimeUnit.SECONDS); FormLayout dataBindingLayout = new FormLayout(); dataBindingLayout.setSpacing(true); @@ -271,24 +278,4 @@ public class VaadinUI extends UI { @VaadinServletConfiguration(ui = VaadinUI.class, productionMode = false) public static class MyUIServlet extends VaadinServlet { } - - class ServerPushThread extends Thread { - @Override - public void run() { - try { - while (true) { - Thread.sleep(1000); - access(new Runnable() { - @Override - public void run() { - currentTime.setValue("Current Time : " + Instant.now()); - } - }); - } - - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } } \ No newline at end of file From 318d0790f58198475a44efbda4a5ac666f1c0b8a Mon Sep 17 00:00:00 2001 From: amilabanuka Date: Fri, 21 Jul 2017 00:06:28 +0800 Subject: [PATCH 53/89] BAEL-281: Static Analysis tools with Eclipse (#2298) --- .../src/test/java/com/baeldung/pmd/CntTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 static-analysis/src/test/java/com/baeldung/pmd/CntTest.java diff --git a/static-analysis/src/test/java/com/baeldung/pmd/CntTest.java b/static-analysis/src/test/java/com/baeldung/pmd/CntTest.java new file mode 100644 index 0000000000..ed72602f99 --- /dev/null +++ b/static-analysis/src/test/java/com/baeldung/pmd/CntTest.java @@ -0,0 +1,17 @@ +package com.baeldung.pmd; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class CntTest { + + private Cnt service; + + @Test + public void whenSecondParamIsZeroShouldReturnIntMax(){ + service = new Cnt(); + int answer = service.d(100,0); + assertEquals(Integer.MAX_VALUE, answer); + } +} From eab110d0d00d0d713acea2230d2de0715bebb6b6 Mon Sep 17 00:00:00 2001 From: ramansahasi Date: Thu, 20 Jul 2017 21:36:54 +0530 Subject: [PATCH 54/89] BAEL-787 (updated) - AWS S3 with Java (#2296) * Replacing manual handling of stream Replacing manual handling of stream apache commons FileUtils library. * Replacing manual handling of stream Replacing manual handling of stream apache commons FileUtils library. * Update S3Application.java --- .../main/java/com/baeldung/s3/S3Application.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/aws/src/main/java/com/baeldung/s3/S3Application.java b/aws/src/main/java/com/baeldung/s3/S3Application.java index fcbd7811b5..fdfb909f73 100644 --- a/aws/src/main/java/com/baeldung/s3/S3Application.java +++ b/aws/src/main/java/com/baeldung/s3/S3Application.java @@ -1,9 +1,10 @@ package com.baeldung.s3; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; +import org.apache.commons.io.FileUtils; + import com.amazonaws.auth.AWSCredentials; import com.amazonaws.auth.AWSStaticCredentialsProvider; import com.amazonaws.auth.BasicAWSCredentials; @@ -28,7 +29,7 @@ public class S3Application { "", "" ); - } + } public static void main(String[] args) throws IOException { //set-up the client @@ -74,15 +75,7 @@ public class S3Application { //downloading an object S3Object s3object = awsService.getObject(bucketName, "Document/hello.txt"); S3ObjectInputStream inputStream = s3object.getObjectContent(); - FileOutputStream fos = new FileOutputStream(new File("/Users/user/Desktop/hello.txt")); - - int read = 0; - byte[] bytes = new byte[1024]; - while ((read = inputStream.read(bytes)) != -1) { - fos.write(bytes, 0, read); - } - inputStream.close(); - fos.close(); + FileUtils.copyInputStreamToFile(inputStream, new File("/Users/user/Desktop/hello.txt")); //copying an object awsService.copyObject( From c910f2533418fe50d02af484bdcb13f663e0aaff Mon Sep 17 00:00:00 2001 From: baljeet20 Date: Thu, 20 Jul 2017 22:47:55 +0530 Subject: [PATCH 55/89] review changes (#2299) --- mockserver/pom.xml | 13 +++++++++++++ ...MockServer.java => MockServerLiveTest.java} | 18 ++++++++---------- 2 files changed, 21 insertions(+), 10 deletions(-) rename mockserver/src/test/java/com/baeldung/mock/server/{TestMockServer.java => MockServerLiveTest.java} (95%) diff --git a/mockserver/pom.xml b/mockserver/pom.xml index a3ca5459c9..8d3e97f129 100644 --- a/mockserver/pom.xml +++ b/mockserver/pom.xml @@ -37,5 +37,18 @@
+ + + + maven-surefire-plugin + 2.20 + + + **/**LiveTest.java + + + + + \ No newline at end of file diff --git a/mockserver/src/test/java/com/baeldung/mock/server/TestMockServer.java b/mockserver/src/test/java/com/baeldung/mock/server/MockServerLiveTest.java similarity index 95% rename from mockserver/src/test/java/com/baeldung/mock/server/TestMockServer.java rename to mockserver/src/test/java/com/baeldung/mock/server/MockServerLiveTest.java index aea1b8b278..56d354be7f 100644 --- a/mockserver/src/test/java/com/baeldung/mock/server/TestMockServer.java +++ b/mockserver/src/test/java/com/baeldung/mock/server/MockServerLiveTest.java @@ -5,9 +5,7 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.HttpClientBuilder; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.*; import org.mockserver.client.server.MockServerClient; import org.mockserver.integration.ClientAndProxy; import org.mockserver.integration.ClientAndServer; @@ -28,13 +26,13 @@ import static org.mockserver.model.HttpRequest.request; import static org.mockserver.model.HttpResponse.response; import static org.mockserver.model.StringBody.exact; -public class TestMockServer { +public class MockServerLiveTest { - private ClientAndProxy proxy; - private ClientAndServer mockServer; + private static ClientAndProxy proxy; + private static ClientAndServer mockServer; - @Before - public void startProxy() { + @BeforeClass + public static void startProxy() { mockServer = startClientAndServer(1080); proxy = startClientAndProxy(1090); } @@ -170,8 +168,8 @@ public class TestMockServer { ); } - @After - public void stopProxy() { + @AfterClass + public static void stopProxy() { proxy.stop(); mockServer.stop(); } From 292d9f802f685745f5e9972eec2cc5c81254f85a Mon Sep 17 00:00:00 2001 From: Daniel Cassiani Date: Thu, 20 Jul 2017 19:40:13 -0300 Subject: [PATCH 56/89] PR for BAEL-798 - Apache Camel with Spring Boot (#2280) * initial import * simplified to rest only * simplifications * update * Create ExampleServices.java * Update Application.java * simple readme * strip of dependency management * setting Camel versions apart where affected * Update README.md * update comments * Update pom.xml * delete of fabri8 deployment.yml * remove extends --- .../main/java/com/baeldung/camel/Application.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/camel-api/src/main/java/com/baeldung/camel/Application.java b/camel-api/src/main/java/com/baeldung/camel/Application.java index f805385ff9..aadd37a3b4 100644 --- a/camel-api/src/main/java/com/baeldung/camel/Application.java +++ b/camel-api/src/main/java/com/baeldung/camel/Application.java @@ -13,14 +13,13 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.ServletRegistrationBean; -import org.springframework.boot.web.support.SpringBootServletInitializer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.stereotype.Component; @SpringBootApplication @ComponentScan(basePackages="com.baeldung.camel") -public class Application extends SpringBootServletInitializer { +public class Application{ @Value("${server.port}") String serverPort; @@ -62,10 +61,12 @@ public class Application extends SpringBootServletInitializer { .bindingMode(RestBindingMode.json) .dataFormatProperty("prettyPrint", "true"); /** -The Rest DSL supports automatic binding json/xml contents to/from POJOs using Camels Data Format. -By default the binding mode is off, meaning there is no automatic binding happening for incoming and outgoing messages. -You may want to use binding if you develop POJOs that maps to your REST services request and response types. -This allows you, as a developer, to work with the POJOs in Java code. +The Rest DSL supports automatic binding json/xml contents to/from +POJOs using Camels Data Format. +By default the binding mode is off, meaning there is no automatic +binding happening for incoming and outgoing messages. +You may want to use binding if you develop POJOs that maps to +your REST services request and response types. */ rest("/api/").description("Teste REST Service") From 64212862bf2566db43daa44ba0d1c54cf5ac2f9e Mon Sep 17 00:00:00 2001 From: deep20jain Date: Fri, 21 Jul 2017 04:13:49 +0530 Subject: [PATCH 57/89] BAEL-1029 - deep20jain@gmail.com - Addressing review comment (#2294) * Adding test classes for java atomic variables * Updating counter with atomic integer * Adding reason for ignoring test * Removing ignore annotation and moving test to manual test * Removing counter test --- ...erTest.java => ThreadSafeCounterTest.java} | 24 ++------------ .../atomic/ThreadUnsafeCounterManualTest.java | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+), 22 deletions(-) rename core-java/src/test/java/com/baeldung/concurrent/atomic/{CounterTest.java => ThreadSafeCounterTest.java} (53%) create mode 100644 core-java/src/test/java/com/baeldung/concurrent/atomic/ThreadUnsafeCounterManualTest.java diff --git a/core-java/src/test/java/com/baeldung/concurrent/atomic/CounterTest.java b/core-java/src/test/java/com/baeldung/concurrent/atomic/ThreadSafeCounterTest.java similarity index 53% rename from core-java/src/test/java/com/baeldung/concurrent/atomic/CounterTest.java rename to core-java/src/test/java/com/baeldung/concurrent/atomic/ThreadSafeCounterTest.java index 1612c62513..e9b2e164ae 100644 --- a/core-java/src/test/java/com/baeldung/concurrent/atomic/CounterTest.java +++ b/core-java/src/test/java/com/baeldung/concurrent/atomic/ThreadSafeCounterTest.java @@ -7,31 +7,10 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.stream.IntStream; -import org.junit.Ignore; import org.junit.Test; -public class CounterTest { +public class ThreadSafeCounterTest { - /** - * This test shows the behaviour of a thread-unsafe class in a multithreaded scenario. We are calling - * the increment methods 1000 times from a pool of 3 threads. In most of the cases, the counter will - * less than 1000, because of lost updates, however, occasionally it may reach 1000, when no threads - * called the method simultaneously. This may cause the build to fail occasionally. Hence excluding this - * test by adding Ignore annotation. - */ - @Test - @Ignore - public void givenMultiThread_whenUnsafeCounterIncrement() throws InterruptedException { - ExecutorService service = Executors.newFixedThreadPool(3); - UnsafeCounter unsafeCounter = new UnsafeCounter(); - - IntStream.range(0, 1000) - .forEach(count -> service.submit(unsafeCounter::increment)); - service.awaitTermination(100, TimeUnit.MILLISECONDS); - - assertEquals(1000, unsafeCounter.getValue()); - } - @Test public void givenMultiThread_whenSafeCounterWithLockIncrement() throws InterruptedException { ExecutorService service = Executors.newFixedThreadPool(3); @@ -55,4 +34,5 @@ public class CounterTest { assertEquals(1000, safeCounter.getValue()); } + } diff --git a/core-java/src/test/java/com/baeldung/concurrent/atomic/ThreadUnsafeCounterManualTest.java b/core-java/src/test/java/com/baeldung/concurrent/atomic/ThreadUnsafeCounterManualTest.java new file mode 100644 index 0000000000..cc7cc18bb5 --- /dev/null +++ b/core-java/src/test/java/com/baeldung/concurrent/atomic/ThreadUnsafeCounterManualTest.java @@ -0,0 +1,33 @@ +package com.baeldung.concurrent.atomic; + +import static org.junit.Assert.assertEquals; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.stream.IntStream; + +import org.junit.Test; + +/** + * This test shows the behaviour of a thread-unsafe class in a multithreaded scenario. We are calling + * the increment methods 1000 times from a pool of 3 threads. In most of the cases, the counter will + * less than 1000, because of lost updates, however, occasionally it may reach 1000, when no threads + * called the method simultaneously. This may cause the build to fail occasionally. Hence excluding this + * test from build by adding this in manual test + */ +public class ThreadUnsafeCounterManualTest { + + @Test + public void givenMultiThread_whenUnsafeCounterIncrement() throws InterruptedException { + ExecutorService service = Executors.newFixedThreadPool(3); + UnsafeCounter unsafeCounter = new UnsafeCounter(); + + IntStream.range(0, 1000) + .forEach(count -> service.submit(unsafeCounter::increment)); + service.awaitTermination(100, TimeUnit.MILLISECONDS); + + assertEquals(1000, unsafeCounter.getValue()); + } + +} From 4e95722017879aabade12999a1322fbcd4e0effa Mon Sep 17 00:00:00 2001 From: Naresh Babu P B Date: Fri, 21 Jul 2017 04:29:46 +0530 Subject: [PATCH 58/89] BAEL-422 Examples for tutorial on Vavr Collection API (#2293) --- .../collections/CollectionAPIUnitTest.java | 261 ++++++++++++++++++ 1 file changed, 261 insertions(+) create mode 100644 vavr/src/test/java/com/baeldung/vavr/collections/CollectionAPIUnitTest.java diff --git a/vavr/src/test/java/com/baeldung/vavr/collections/CollectionAPIUnitTest.java b/vavr/src/test/java/com/baeldung/vavr/collections/CollectionAPIUnitTest.java new file mode 100644 index 0000000000..48c0cb7305 --- /dev/null +++ b/vavr/src/test/java/com/baeldung/vavr/collections/CollectionAPIUnitTest.java @@ -0,0 +1,261 @@ +package com.baeldung.vavr.collections; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + +import java.util.Comparator; + +import org.junit.Test; + +import io.vavr.Tuple; +import io.vavr.Tuple2; +import io.vavr.collection.Array; +import io.vavr.collection.CharSeq; +import io.vavr.collection.HashSet; +import io.vavr.collection.Iterator; +import io.vavr.collection.List; +import io.vavr.collection.Map; +import io.vavr.collection.Queue; +import io.vavr.collection.Set; +import io.vavr.collection.SortedMap; +import io.vavr.collection.SortedSet; +import io.vavr.collection.Stream; +import io.vavr.collection.TreeMap; +import io.vavr.collection.TreeSet; +import io.vavr.collection.Vector; + +public class CollectionAPIUnitTest { + + @Test + public void givenEmptyList_whenStacked_thenCorrect() { + List intList = List.empty(); + + List anotherList = intList.push(4) + .push(0); + Iterator iterator = anotherList.iterator(); + + assertEquals(new Integer(0), iterator.next()); + assertEquals(new Integer(4), iterator.next()); + } + + @Test + public void givenList_whenPrependTail_thenCorrect() { + List intList = List.of(1, 2, 3); + + List newList = intList.tail() + .prepend(0); + + assertEquals(new Integer(1), intList.get(0)); + assertEquals(new Integer(2), intList.get(1)); + assertEquals(new Integer(3), intList.get(2)); + + assertNotSame(intList.get(0), newList.get(0)); + assertEquals(new Integer(0), newList.get(0)); + assertSame(intList.get(1), newList.get(1)); + assertSame(intList.get(2), newList.get(2)); + } + + @Test + public void givenQueue_whenEnqueued_thenCorrect() { + Queue queue = Queue.of(1, 2, 3); + Queue secondQueue = queue.enqueue(4) + .enqueue(5); + + assertEquals(3, queue.size()); + assertEquals(5, secondQueue.size()); + + secondQueue.dequeue() + .map((k, v) -> { + assertEquals(new Integer(1), k); + return v.dequeue(); + }) + .map((k, v) -> { + assertEquals(new Integer(2), k); + return v.dequeue(); + }) + .map((k, v) -> { + assertEquals(new Integer(3), k); + return v.dequeue(); + }) + .map((k, v) -> { + assertEquals(new Integer(4), k); + return v.dequeue(); + }) + .map((k, v) -> { + assertEquals(new Integer(5), k); + assertTrue(v.isEmpty()); + return null; + }); + } + + @Test + public void givenStream_whenProcessed_thenCorrect() { + Stream intStream = Stream.iterate(0, i -> i + 1) + .take(10); + + assertEquals(10, intStream.size()); + + long evenSum = intStream.filter(i -> i % 2 == 0) + .sum() + .longValue(); + + assertEquals(20L, evenSum); + assertEquals(new Integer(5), intStream.get(5)); + } + + @Test + public void givenArray_whenQueried_thenCorrect() { + Array intArray = Array.of(1, 2, 3); + Array newArray = intArray.removeAt(1); + + assertEquals(3, intArray.size()); + assertEquals(2, newArray.size()); + + assertEquals(new Integer(1), intArray.get(0)); + assertEquals(new Integer(2), intArray.get(1)); + assertEquals(new Integer(3), intArray.get(2)); + assertEquals(new Integer(3), newArray.get(1)); + } + + @Test + public void givenVector_whenQueried_thenCorrect() { + Vector intVector = Vector.range(1, 5); + Vector newVector = intVector.replace(2, 6); + + assertEquals(4, intVector.size()); + assertEquals(4, newVector.size()); + + assertEquals(new Integer(1), intVector.get(0)); + assertEquals(new Integer(2), intVector.get(1)); + assertEquals(new Integer(3), intVector.get(2)); + assertEquals(new Integer(6), newVector.get(1)); + } + + @Test + public void givenCharSeq_whenProcessed_thenCorrect() { + CharSeq chars = CharSeq.of("vavr"); + CharSeq newChars = chars.replace('v', 'V'); + + assertEquals(4, chars.size()); + assertEquals(4, newChars.size()); + + assertEquals('v', chars.charAt(0)); + assertEquals('V', newChars.charAt(0)); + assertEquals("Vavr", newChars.mkString()); + } + + @Test + public void givenHashSet_whenModified_thenCorrect() { + HashSet set = HashSet.of("Red", "Green", "Blue"); + HashSet newSet = set.add("Yellow"); + + assertEquals(3, set.size()); + assertEquals(4, newSet.size()); + assertFalse(set.contains("Yellow")); + assertTrue(newSet.contains("Yellow")); + } + + @Test + public void givenSortedSet_whenIterated_thenCorrect() { + SortedSet set = TreeSet.of("Red", "Green", "Blue"); + + Iterator iterator = set.iterator(); + assertEquals("Blue", iterator.next()); + assertEquals("Green", iterator.next()); + assertEquals("Red", iterator.next()); + } + + @Test + public void givenSortedSet_whenReversed_thenCorrect() { + Comparator reverseCompare = (a, b) -> b.compareTo(a); + SortedSet set = TreeSet.of(reverseCompare, "Green", "Red", "Blue"); + + Iterator iterator = set.iterator(); + assertEquals("Red", iterator.next()); + assertEquals("Green", iterator.next()); + assertEquals("Blue", iterator.next()); + } + + @Test + public void givenMap_whenIterated_thenCorrect() { + Map> map = List.rangeClosed(0, 10) + .groupBy(i -> i % 2); + + assertEquals(2, map.size()); + + Iterator>> iterator = map.iterator(); + assertEquals(6, iterator.next() + ._2() + .size()); + assertEquals(5, iterator.next() + ._2() + .size()); + } + + @Test + public void givenTreeMap_whenIterated_thenCorrect() { + SortedMap map = TreeMap.of(3, "Three", 2, "Two", 4, "Four", 1, "One"); + + Iterator> iterator = map.iterator(); + assertEquals(new Integer(1), iterator.next() + ._1()); + assertEquals(new Integer(2), iterator.next() + ._1()); + assertEquals(new Integer(3), iterator.next() + ._1()); + } + + @Test + public void givenJavaList_whenConverted_thenCorrect() { + java.util.List javaList = java.util.Arrays.asList(1, 2, 3, 4); + List vavrList = List.ofAll(javaList); + + assertTrue(vavrList instanceof io.vavr.collection.List); + + java.util.stream.Stream javaStream = javaList.stream(); + Set vavrSet = HashSet.ofAll(javaStream); + + assertTrue(vavrSet instanceof io.vavr.collection.Set); + } + + @Test + public void givenVavrList_whenConverted_thenCorrect() { + Integer[] array = List.of(1, 2, 3) + .toJavaArray(Integer.class); + assertEquals(3, array.length); + + java.util.Map map = List.of("1", "2", "3") + .toJavaMap(i -> Tuple.of(i, Integer.valueOf(i))); + assertEquals(new Integer(2), map.get("2")); + } + + @Test + public void givenVavrList_whenConvertedView_thenCorrect() { + java.util.List javaList = List.of(1, 2, 3) + .asJavaMutable(); + javaList.add(4); + + assertEquals(new Integer(4), javaList.get(3)); + } + + @Test(expected = UnsupportedOperationException.class) + public void givenVavrList_whenConvertedView_thenException() { + java.util.List javaList = List.of(1, 2, 3) + .asJava(); + + assertEquals(new Integer(3), javaList.get(2)); + javaList.add(4); + } + + @Test + public void givenList_whenSquared_thenCorrect() { + List vavrList = List.of(1, 2, 3); + Number sum = vavrList.map(i -> i * i) + .sum(); + + assertEquals(new Long(14), sum); + } +} From f8bf4038f1dc0a109f1024c7b7b274a3e72b932d Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Fri, 21 Jul 2017 13:37:49 +0300 Subject: [PATCH 59/89] Optimize and refactor (#2302) --- ...otWithServletComponentIntegrationTest.java | 13 ++- ...ithoutServletComponentIntegrationTest.java | 12 +- .../AutoconfigurationIntegrationTest.java | 9 +- .../DisplayBeanIntegrationTest.java | 32 +++-- .../java/com/baeldung/intro/AppLiveTest.java | 10 +- .../toggle/ToggleIntegrationTest.java | 8 +- .../utils/UtilsControllerIntegrationTest.java | 28 +++-- .../MyStompSessionHandlerIntegrationTest.java | 5 - .../EmployeeControllerIntegrationTest.java | 16 +-- .../EmployeeRepositoryIntegrationTest.java | 12 +- ...EmployeeRestControllerIntegrationTest.java | 44 +++---- .../EmployeeServiceImplIntegrationTest.java | 38 +++--- .../org/baeldung/boot/boottest/JsonUtil.java | 4 +- .../ApiDocumentationIntegrationTest.java | 14 ++- ...ngStartedDocumentationIntegrationTest.java | 20 ++-- .../web/AbstractDiscoverabilityLiveTest.java | 2 +- .../csrf/CsrfAbstractIntegrationTest.java | 8 +- .../org/baeldung/test/JacksonMarshaller.java | 12 -- .../test/java/org/baeldung/util/IDUtil.java | 8 +- .../LoggerInterceptorIntegrationTest.java | 1 + .../baeldung/web/util/HTTPLinkHeaderUtil.java | 37 +----- ...ilityObjectsControllerIntegrationTest.java | 2 +- ...ayoutDialectControllerIntegrationTest.java | 2 +- .../csrf/CsrfEnabledIntegrationTest.java | 2 +- .../junitparams/SafeAdditionUtilTest.java | 10 +- .../junitparams/TestDataProvider.java | 4 +- .../calculator/CalculatorIntegrationTest.java | 9 +- .../collections/CollectionAPIUnitTest.java | 110 +++++++++--------- .../jsoncreator/JsonCreatorUnitTest.java | 8 +- .../jsonfilter/JsonFilterUnitTest.java | 2 +- .../jsonformat/JsonFormatUnitTest.java | 4 +- .../jsonproperty/JsonPropertyUnitTest.java | 4 +- 32 files changed, 220 insertions(+), 270 deletions(-) diff --git a/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithServletComponentIntegrationTest.java b/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithServletComponentIntegrationTest.java index 8d5eb56bf4..660b461ab6 100644 --- a/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithServletComponentIntegrationTest.java +++ b/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithServletComponentIntegrationTest.java @@ -14,15 +14,18 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.servlet.FilterRegistration; import javax.servlet.ServletContext; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = SpringBootAnnotatedApp.class) @AutoConfigureMockMvc -@TestPropertySource(properties = { "security.basic.enabled=false" }) +@TestPropertySource(properties = {"security.basic.enabled=false"}) public class SpringBootWithServletComponentIntegrationTest { - @Autowired private ServletContext servletContext; + @Autowired + private ServletContext servletContext; @Test public void givenServletContext_whenAccessAttrs_thenFoundAttrsPutInServletListner() { @@ -42,7 +45,8 @@ public class SpringBootWithServletComponentIntegrationTest { .contains("echo servlet")); } - @Autowired private TestRestTemplate restTemplate; + @Autowired + private TestRestTemplate restTemplate; @Test public void givenServletFilter_whenGetHello_thenRequestFiltered() { @@ -59,7 +63,6 @@ public class SpringBootWithServletComponentIntegrationTest { } - } diff --git a/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithoutServletComponentIntegrationTest.java b/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithoutServletComponentIntegrationTest.java index 64507ad02c..31bb2ab195 100644 --- a/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithoutServletComponentIntegrationTest.java +++ b/spring-boot/src/test/java/com/baeldung/annotation/servletcomponentscan/SpringBootWithoutServletComponentIntegrationTest.java @@ -14,17 +14,21 @@ import org.springframework.test.context.junit4.SpringRunner; import javax.servlet.FilterRegistration; import javax.servlet.ServletContext; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = SpringBootPlainApp.class) @AutoConfigureMockMvc -@TestPropertySource(properties = { "security.basic.enabled=false" }) +@TestPropertySource(properties = {"security.basic.enabled=false"}) public class SpringBootWithoutServletComponentIntegrationTest { - @Autowired private ServletContext servletContext; + @Autowired + private ServletContext servletContext; - @Autowired private TestRestTemplate restTemplate; + @Autowired + private TestRestTemplate restTemplate; @Test public void givenServletContext_whenAccessAttrs_thenNotFound() { diff --git a/spring-boot/src/test/java/com/baeldung/autoconfiguration/AutoconfigurationIntegrationTest.java b/spring-boot/src/test/java/com/baeldung/autoconfiguration/AutoconfigurationIntegrationTest.java index dda9d69edd..e886042c8d 100644 --- a/spring-boot/src/test/java/com/baeldung/autoconfiguration/AutoconfigurationIntegrationTest.java +++ b/spring-boot/src/test/java/com/baeldung/autoconfiguration/AutoconfigurationIntegrationTest.java @@ -1,5 +1,8 @@ package com.baeldung.autoconfiguration; +import com.baeldung.autoconfiguration.example.AutoconfigurationApplication; +import com.baeldung.autoconfiguration.example.MyUser; +import com.baeldung.autoconfiguration.example.MyUserRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -7,13 +10,9 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import com.baeldung.autoconfiguration.example.AutoconfigurationApplication; -import com.baeldung.autoconfiguration.example.MyUser; -import com.baeldung.autoconfiguration.example.MyUserRepository; - @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = AutoconfigurationApplication.class) -@EnableJpaRepositories(basePackages = { "com.baeldung.autoconfiguration.example" }) +@EnableJpaRepositories(basePackages = {"com.baeldung.autoconfiguration.example"}) public class AutoconfigurationIntegrationTest { @Autowired diff --git a/spring-boot/src/test/java/com/baeldung/displayallbeans/DisplayBeanIntegrationTest.java b/spring-boot/src/test/java/com/baeldung/displayallbeans/DisplayBeanIntegrationTest.java index 530b8e9cb3..413f6980ce 100644 --- a/spring-boot/src/test/java/com/baeldung/displayallbeans/DisplayBeanIntegrationTest.java +++ b/spring-boot/src/test/java/com/baeldung/displayallbeans/DisplayBeanIntegrationTest.java @@ -1,15 +1,5 @@ package com.baeldung.displayallbeans; -import static org.assertj.core.api.BDDAssertions.then; -import static org.hamcrest.CoreMatchers.hasItem; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -23,7 +13,15 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.context.WebApplicationContext; -import com.baeldung.displayallbeans.Application; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import static org.assertj.core.api.BDDAssertions.then; +import static org.hamcrest.CoreMatchers.hasItem; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @@ -46,10 +44,10 @@ public class DisplayBeanIntegrationTest { public void givenRestTemplate_whenAccessServerUrl_thenHttpStatusOK() throws Exception { ResponseEntity entity = this.testRestTemplate.getForEntity( "http://localhost:" + this.port + "/displayallbeans", String.class); - + then(entity.getStatusCode()).isEqualTo(HttpStatus.OK); } - + @Test public void givenRestTemplate_whenAccessEndpointUrl_thenHttpStatusOK() throws Exception { @SuppressWarnings("rawtypes") @@ -68,14 +66,14 @@ public class DisplayBeanIntegrationTest { List> allBeans = (List) ((Map) entity.getBody().get(0)).get("beans"); List beanNamesList = allBeans.stream().map(x -> (String) x.get("bean")).collect(Collectors.toList()); - assertThat( beanNamesList, hasItem("fooController")); - assertThat( beanNamesList, hasItem("fooService")); + assertThat(beanNamesList, hasItem("fooController")); + assertThat(beanNamesList, hasItem("fooService")); } - + @Test public void givenWebApplicationContext_whenAccessGetBeanDefinitionNames_thenReturnsBeanNames() throws Exception { String[] beanNames = context.getBeanDefinitionNames(); - + List beanNamesList = Arrays.asList(beanNames); assertTrue(beanNamesList.contains("fooController")); assertTrue(beanNamesList.contains("fooService")); diff --git a/spring-boot/src/test/java/com/baeldung/intro/AppLiveTest.java b/spring-boot/src/test/java/com/baeldung/intro/AppLiveTest.java index af46fe0423..fa05dbab66 100644 --- a/spring-boot/src/test/java/com/baeldung/intro/AppLiveTest.java +++ b/spring-boot/src/test/java/com/baeldung/intro/AppLiveTest.java @@ -18,7 +18,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @RunWith(SpringRunner.class) @SpringBootTest @AutoConfigureMockMvc -@TestPropertySource(properties = { "security.basic.enabled=false" }) +@TestPropertySource(properties = {"security.basic.enabled=false"}) public class AppLiveTest { @Autowired @@ -27,15 +27,15 @@ public class AppLiveTest { @Test public void getIndex() throws Exception { mvc.perform(MockMvcRequestBuilders.get("/").accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(content().string(equalTo("Index Page"))); + .andExpect(status().isOk()) + .andExpect(content().string(equalTo("Index Page"))); } @Test public void getLocal() throws Exception { mvc.perform(MockMvcRequestBuilders.get("/local").accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(content().string(equalTo("/local"))); + .andExpect(status().isOk()) + .andExpect(content().string(equalTo("/local"))); } } \ No newline at end of file diff --git a/spring-boot/src/test/java/com/baeldung/toggle/ToggleIntegrationTest.java b/spring-boot/src/test/java/com/baeldung/toggle/ToggleIntegrationTest.java index e40678603b..ca6230e8f5 100644 --- a/spring-boot/src/test/java/com/baeldung/toggle/ToggleIntegrationTest.java +++ b/spring-boot/src/test/java/com/baeldung/toggle/ToggleIntegrationTest.java @@ -1,9 +1,5 @@ package com.baeldung.toggle; -import static org.junit.Assert.*; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -16,6 +12,10 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; +import static org.junit.Assert.assertEquals; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = ToggleApplication.class) @AutoConfigureMockMvc diff --git a/spring-boot/src/test/java/com/baeldung/utils/UtilsControllerIntegrationTest.java b/spring-boot/src/test/java/com/baeldung/utils/UtilsControllerIntegrationTest.java index 829c0a6ac4..edb40e9a1f 100644 --- a/spring-boot/src/test/java/com/baeldung/utils/UtilsControllerIntegrationTest.java +++ b/spring-boot/src/test/java/com/baeldung/utils/UtilsControllerIntegrationTest.java @@ -1,5 +1,6 @@ package com.baeldung.utils; +import com.baeldung.utils.controller.UtilsController; import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -10,32 +11,29 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import com.baeldung.utils.controller.UtilsController; - public class UtilsControllerIntegrationTest { - @InjectMocks + @InjectMocks private UtilsController utilsController; - + private MockMvc mockMvc; - + @Before public void setup() { MockitoAnnotations.initMocks(this); this.mockMvc = MockMvcBuilders.standaloneSetup(utilsController) - .build(); + .build(); } - + @Test public void givenParameter_setRequestParam_andSetSessionAttribute() throws Exception { - String param = "testparam"; - this.mockMvc.perform( - post("/setParam") - .param("param", param) - .sessionAttr("parameter", param)) - .andExpect(status().isOk()); + String param = "testparam"; + this.mockMvc.perform( + post("/setParam") + .param("param", param) + .sessionAttr("parameter", param)) + .andExpect(status().isOk()); } - + } diff --git a/spring-boot/src/test/java/com/baeldung/websocket/client/MyStompSessionHandlerIntegrationTest.java b/spring-boot/src/test/java/com/baeldung/websocket/client/MyStompSessionHandlerIntegrationTest.java index f30c8ee4e7..b52ab5b1d3 100644 --- a/spring-boot/src/test/java/com/baeldung/websocket/client/MyStompSessionHandlerIntegrationTest.java +++ b/spring-boot/src/test/java/com/baeldung/websocket/client/MyStompSessionHandlerIntegrationTest.java @@ -6,11 +6,6 @@ import org.mockito.Mockito; import org.springframework.messaging.simp.stomp.StompHeaders; import org.springframework.messaging.simp.stomp.StompSession; -/** - * Test class for MyStompSessionHandler - * @author Kalyan - * - */ public class MyStompSessionHandlerIntegrationTest { @Test diff --git a/spring-boot/src/test/java/org/baeldung/boot/boottest/EmployeeControllerIntegrationTest.java b/spring-boot/src/test/java/org/baeldung/boot/boottest/EmployeeControllerIntegrationTest.java index 2146fc09bc..6623a6396f 100644 --- a/spring-boot/src/test/java/org/baeldung/boot/boottest/EmployeeControllerIntegrationTest.java +++ b/spring-boot/src/test/java/org/baeldung/boot/boottest/EmployeeControllerIntegrationTest.java @@ -45,9 +45,9 @@ public class EmployeeControllerIntegrationTest { given(service.save(Mockito.anyObject())).willReturn(alex); mvc.perform(post("/api/employees").contentType(MediaType.APPLICATION_JSON) - .content(JsonUtil.toJson(alex))) - .andExpect(status().isCreated()) - .andExpect(jsonPath("$.name", is("alex"))); + .content(JsonUtil.toJson(alex))) + .andExpect(status().isCreated()) + .andExpect(jsonPath("$.name", is("alex"))); verify(service, VerificationModeFactory.times(1)).save(Mockito.anyObject()); reset(service); } @@ -63,11 +63,11 @@ public class EmployeeControllerIntegrationTest { given(service.getAllEmployees()).willReturn(allEmployees); mvc.perform(get("/api/employees").contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$", hasSize(3))) - .andExpect(jsonPath("$[0].name", is(alex.getName()))) - .andExpect(jsonPath("$[1].name", is(john.getName()))) - .andExpect(jsonPath("$[2].name", is(bob.getName()))); + .andExpect(status().isOk()) + .andExpect(jsonPath("$", hasSize(3))) + .andExpect(jsonPath("$[0].name", is(alex.getName()))) + .andExpect(jsonPath("$[1].name", is(john.getName()))) + .andExpect(jsonPath("$[2].name", is(bob.getName()))); verify(service, VerificationModeFactory.times(1)).getAllEmployees(); reset(service); } diff --git a/spring-boot/src/test/java/org/baeldung/boot/boottest/EmployeeRepositoryIntegrationTest.java b/spring-boot/src/test/java/org/baeldung/boot/boottest/EmployeeRepositoryIntegrationTest.java index ec599beedf..952ff19707 100644 --- a/spring-boot/src/test/java/org/baeldung/boot/boottest/EmployeeRepositoryIntegrationTest.java +++ b/spring-boot/src/test/java/org/baeldung/boot/boottest/EmployeeRepositoryIntegrationTest.java @@ -1,9 +1,5 @@ package org.baeldung.boot.boottest; -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.List; - import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -11,6 +7,10 @@ import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager; import org.springframework.test.context.junit4.SpringRunner; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + @RunWith(SpringRunner.class) @DataJpaTest public class EmployeeRepositoryIntegrationTest { @@ -65,7 +65,7 @@ public class EmployeeRepositoryIntegrationTest { List allEmployees = employeeRepository.findAll(); assertThat(allEmployees).hasSize(3) - .extracting(Employee::getName) - .containsOnly(alex.getName(), ron.getName(), bob.getName()); + .extracting(Employee::getName) + .containsOnly(alex.getName(), ron.getName(), bob.getName()); } } diff --git a/spring-boot/src/test/java/org/baeldung/boot/boottest/EmployeeRestControllerIntegrationTest.java b/spring-boot/src/test/java/org/baeldung/boot/boottest/EmployeeRestControllerIntegrationTest.java index 4c3a50f933..c1d8c52eb9 100644 --- a/spring-boot/src/test/java/org/baeldung/boot/boottest/EmployeeRestControllerIntegrationTest.java +++ b/spring-boot/src/test/java/org/baeldung/boot/boottest/EmployeeRestControllerIntegrationTest.java @@ -1,19 +1,5 @@ package org.baeldung.boot.boottest; -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.Matchers.greaterThanOrEqualTo; -import static org.hamcrest.Matchers.hasSize; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.io.IOException; -import java.util.List; - import org.baeldung.boot.DemoApplication; import org.junit.After; import org.junit.Test; @@ -27,6 +13,20 @@ import org.springframework.http.MediaType; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; +import java.io.IOException; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.greaterThanOrEqualTo; +import static org.hamcrest.Matchers.hasSize; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = DemoApplication.class) @AutoConfigureMockMvc @@ -49,11 +49,11 @@ public class EmployeeRestControllerIntegrationTest { public void whenValidInput_thenCreateEmployee() throws IOException, Exception { Employee bob = new Employee("bob"); mvc.perform(post("/api/employees").contentType(MediaType.APPLICATION_JSON) - .content(JsonUtil.toJson(bob))); + .content(JsonUtil.toJson(bob))); List found = repository.findAll(); assertThat(found).extracting(Employee::getName) - .containsOnly("bob"); + .containsOnly("bob"); } @Test @@ -63,12 +63,12 @@ public class EmployeeRestControllerIntegrationTest { createTestEmployee("alex"); mvc.perform(get("/api/employees").contentType(MediaType.APPLICATION_JSON)) - .andDo(print()) - .andExpect(status().isOk()) - .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) - .andExpect(jsonPath("$", hasSize(greaterThanOrEqualTo(2)))) - .andExpect(jsonPath("$[0].name", is("bob"))) - .andExpect(jsonPath("$[1].name", is("alex"))); + .andDo(print()) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("$", hasSize(greaterThanOrEqualTo(2)))) + .andExpect(jsonPath("$[0].name", is("bob"))) + .andExpect(jsonPath("$[1].name", is("alex"))); } private void createTestEmployee(String name) { diff --git a/spring-boot/src/test/java/org/baeldung/boot/boottest/EmployeeServiceImplIntegrationTest.java b/spring-boot/src/test/java/org/baeldung/boot/boottest/EmployeeServiceImplIntegrationTest.java index 8038ae4373..5bd6b34c40 100644 --- a/spring-boot/src/test/java/org/baeldung/boot/boottest/EmployeeServiceImplIntegrationTest.java +++ b/spring-boot/src/test/java/org/baeldung/boot/boottest/EmployeeServiceImplIntegrationTest.java @@ -1,10 +1,5 @@ package org.baeldung.boot.boottest; -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Arrays; -import java.util.List; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -16,6 +11,11 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Bean; import org.springframework.test.context.junit4.SpringRunner; +import java.util.Arrays; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + @RunWith(SpringRunner.class) public class EmployeeServiceImplIntegrationTest { @@ -44,27 +44,27 @@ public class EmployeeServiceImplIntegrationTest { List allEmployees = Arrays.asList(john, bob, alex); Mockito.when(employeeRepository.findByName(john.getName())) - .thenReturn(john); + .thenReturn(john); Mockito.when(employeeRepository.findByName(alex.getName())) - .thenReturn(alex); + .thenReturn(alex); Mockito.when(employeeRepository.findByName("wrong_name")) - .thenReturn(null); + .thenReturn(null); Mockito.when(employeeRepository.findById(john.getId())) - .thenReturn(john); + .thenReturn(john); Mockito.when(employeeRepository.findAll()) - .thenReturn(allEmployees); + .thenReturn(allEmployees); Mockito.when(employeeRepository.findById(-99L)) - .thenReturn(null); + .thenReturn(null); } @Test public void whenValidName_thenEmployeeShouldBeFound() { String name = "alex"; Employee found = employeeService.getEmployeeByName(name); - - assertThat(found.getName()) + + assertThat(found.getName()) .isEqualTo(name); - } + } @Test public void whenInValidName_thenEmployeeShouldNotBeFound() { @@ -114,25 +114,25 @@ public class EmployeeServiceImplIntegrationTest { List allEmployees = employeeService.getAllEmployees(); verifyFindAllEmployeesIsCalledOnce(); assertThat(allEmployees).hasSize(3) - .extracting(Employee::getName) - .contains(alex.getName(), john.getName(), bob.getName()); + .extracting(Employee::getName) + .contains(alex.getName(), john.getName(), bob.getName()); } private void verifyFindByNameIsCalledOnce(String name) { Mockito.verify(employeeRepository, VerificationModeFactory.times(1)) - .findByName(name); + .findByName(name); Mockito.reset(employeeRepository); } private void verifyFindByIdIsCalledOnce() { Mockito.verify(employeeRepository, VerificationModeFactory.times(1)) - .findById(Mockito.anyLong()); + .findById(Mockito.anyLong()); Mockito.reset(employeeRepository); } private void verifyFindAllEmployeesIsCalledOnce() { Mockito.verify(employeeRepository, VerificationModeFactory.times(1)) - .findAll(); + .findAll(); Mockito.reset(employeeRepository); } } diff --git a/spring-boot/src/test/java/org/baeldung/boot/boottest/JsonUtil.java b/spring-boot/src/test/java/org/baeldung/boot/boottest/JsonUtil.java index 8c7e5576ce..36d07164b2 100644 --- a/spring-boot/src/test/java/org/baeldung/boot/boottest/JsonUtil.java +++ b/spring-boot/src/test/java/org/baeldung/boot/boottest/JsonUtil.java @@ -1,10 +1,10 @@ package org.baeldung.boot.boottest; -import java.io.IOException; - import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; + class JsonUtil { static byte[] toJson(Object object) throws IOException { ObjectMapper mapper = new ObjectMapper(); diff --git a/spring-rest-docs/src/test/java/com/example/ApiDocumentationIntegrationTest.java b/spring-rest-docs/src/test/java/com/example/ApiDocumentationIntegrationTest.java index 0912023fb7..f2ac9d0f82 100644 --- a/spring-rest-docs/src/test/java/com/example/ApiDocumentationIntegrationTest.java +++ b/spring-rest-docs/src/test/java/com/example/ApiDocumentationIntegrationTest.java @@ -28,9 +28,17 @@ import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.li import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.links; import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; -import static org.springframework.restdocs.operation.preprocess.Preprocessors.*; -import static org.springframework.restdocs.payload.PayloadDocumentation.*; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.patch; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.put; +import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest; +import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse; +import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint; +import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; +import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; +import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; import static org.springframework.restdocs.snippet.Attributes.key; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static org.springframework.util.StringUtils.collectionToDelimitedString; diff --git a/spring-rest-docs/src/test/java/com/example/GettingStartedDocumentationIntegrationTest.java b/spring-rest-docs/src/test/java/com/example/GettingStartedDocumentationIntegrationTest.java index 1af626d03b..c02c0c27f8 100644 --- a/spring-rest-docs/src/test/java/com/example/GettingStartedDocumentationIntegrationTest.java +++ b/spring-rest-docs/src/test/java/com/example/GettingStartedDocumentationIntegrationTest.java @@ -1,8 +1,6 @@ package com.example; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.jayway.jsonpath.JsonPath; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -14,21 +12,19 @@ import org.springframework.restdocs.RestDocumentation; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; -import java.io.UnsupportedEncodingException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; -import static org.springframework.restdocs.operation.preprocess.Preprocessors.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; +import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest; +import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse; +import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = SpringRestDocsApplication.class) diff --git a/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractDiscoverabilityLiveTest.java b/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractDiscoverabilityLiveTest.java index 2d3ad7b13f..e7456f1667 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractDiscoverabilityLiveTest.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractDiscoverabilityLiveTest.java @@ -37,7 +37,7 @@ public abstract class AbstractDiscoverabilityLiveTest ex // Then final String allowHeader = res.getHeader(HttpHeaders.ALLOW); - assertThat(allowHeader, AnyOf. anyOf(containsString("GET"), containsString("PUT"), containsString("DELETE"))); + assertThat(allowHeader, AnyOf.anyOf(containsString("GET"), containsString("PUT"), containsString("DELETE"))); } @Test diff --git a/spring-security-rest-full/src/test/java/org/baeldung/security/csrf/CsrfAbstractIntegrationTest.java b/spring-security-rest-full/src/test/java/org/baeldung/security/csrf/CsrfAbstractIntegrationTest.java index be9b7cf27e..6e70f979c8 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/security/csrf/CsrfAbstractIntegrationTest.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/security/csrf/CsrfAbstractIntegrationTest.java @@ -31,7 +31,7 @@ public abstract class CsrfAbstractIntegrationTest { @Autowired private Filter springSecurityFilterChain; - protected MockMvc mvc; + MockMvc mvc; // @@ -40,15 +40,15 @@ public abstract class CsrfAbstractIntegrationTest { mvc = MockMvcBuilders.webAppContextSetup(context).addFilters(springSecurityFilterChain).build(); } - protected RequestPostProcessor testUser() { + RequestPostProcessor testUser() { return user("user1").password("user1Pass").roles("USER"); } - protected RequestPostProcessor testAdmin() { + RequestPostProcessor testAdmin() { return user("admin").password("adminPass").roles("USER", "ADMIN"); } - protected String createFoo() throws JsonProcessingException { + String createFoo() throws JsonProcessingException { return new ObjectMapper().writeValueAsString(new Foo(randomAlphabetic(6))); } } diff --git a/spring-security-rest-full/src/test/java/org/baeldung/test/JacksonMarshaller.java b/spring-security-rest-full/src/test/java/org/baeldung/test/JacksonMarshaller.java index 392e101193..a899d387ab 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/test/JacksonMarshaller.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/test/JacksonMarshaller.java @@ -33,10 +33,6 @@ public final class JacksonMarshaller implements IMarshaller { String entityAsJSON = null; try { entityAsJSON = objectMapper.writeValueAsString(resource); - } catch (final JsonParseException parseEx) { - logger.error("", parseEx); - } catch (final JsonMappingException mappingEx) { - logger.error("", mappingEx); } catch (final IOException ioEx) { logger.error("", ioEx); } @@ -51,10 +47,6 @@ public final class JacksonMarshaller implements IMarshaller { T entity = null; try { entity = objectMapper.readValue(resourceAsString, clazz); - } catch (final JsonParseException parseEx) { - logger.error("", parseEx); - } catch (final JsonMappingException mappingEx) { - logger.error("", mappingEx); } catch (final IOException ioEx) { logger.error("", ioEx); } @@ -76,10 +68,6 @@ public final class JacksonMarshaller implements IMarshaller { } else { entities = objectMapper.readValue(resourcesAsString, List.class); } - } catch (final JsonParseException parseEx) { - logger.error("", parseEx); - } catch (final JsonMappingException mappingEx) { - logger.error("", mappingEx); } catch (final IOException ioEx) { logger.error("", ioEx); } diff --git a/spring-security-rest-full/src/test/java/org/baeldung/util/IDUtil.java b/spring-security-rest-full/src/test/java/org/baeldung/util/IDUtil.java index 84fb63a321..85ab623e5f 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/util/IDUtil.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/util/IDUtil.java @@ -10,21 +10,21 @@ public final class IDUtil { // API - public final static String randomPositiveLongAsString() { + public static String randomPositiveLongAsString() { return Long.toString(randomPositiveLong()); } - public final static String randomNegativeLongAsString() { + public static String randomNegativeLongAsString() { return Long.toString(randomNegativeLong()); } - public final static long randomPositiveLong() { + public static long randomPositiveLong() { long id = new Random().nextLong() * 10000; id = (id < 0) ? (-1 * id) : id; return id; } - public final static long randomNegativeLong() { + private static long randomNegativeLong() { long id = new Random().nextLong() * 10000; id = (id > 0) ? (-1 * id) : id; return id; diff --git a/spring-security-rest-full/src/test/java/org/baeldung/web/interceptor/LoggerInterceptorIntegrationTest.java b/spring-security-rest-full/src/test/java/org/baeldung/web/interceptor/LoggerInterceptorIntegrationTest.java index 7dcaec5a12..44dc860e62 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/web/interceptor/LoggerInterceptorIntegrationTest.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/web/interceptor/LoggerInterceptorIntegrationTest.java @@ -27,6 +27,7 @@ public class LoggerInterceptorIntegrationTest { @Autowired WebApplicationContext wac; + @Autowired MockHttpSession session; diff --git a/spring-security-rest-full/src/test/java/org/baeldung/web/util/HTTPLinkHeaderUtil.java b/spring-security-rest-full/src/test/java/org/baeldung/web/util/HTTPLinkHeaderUtil.java index bb3919eacc..29f1c91ca3 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/web/util/HTTPLinkHeaderUtil.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/web/util/HTTPLinkHeaderUtil.java @@ -1,10 +1,5 @@ package org.baeldung.web.util; -import java.util.List; - -import com.google.common.base.Preconditions; -import com.google.common.collect.Lists; - public final class HTTPLinkHeaderUtil { private HTTPLinkHeaderUtil() { @@ -13,23 +8,6 @@ public final class HTTPLinkHeaderUtil { // - /** - * ex.
- * https://api.github.com/users/steveklabnik/gists?page=2>; rel="next", ; rel="last" - */ - public static List extractAllURIs(final String linkHeader) { - Preconditions.checkNotNull(linkHeader); - - final List linkHeaders = Lists.newArrayList(); - final String[] links = linkHeader.split(", "); - for (final String link : links) { - final int positionOfSeparator = link.indexOf(';'); - linkHeaders.add(link.substring(1, positionOfSeparator - 1)); - } - - return linkHeaders; - } - public static String extractURIByRel(final String linkHeader, final String rel) { if (linkHeader == null) { return null; @@ -37,7 +15,7 @@ public final class HTTPLinkHeaderUtil { String uriWithSpecifiedRel = null; final String[] links = linkHeader.split(", "); - String linkRelation = null; + String linkRelation; for (final String link : links) { final int positionOfSeparator = link.indexOf(';'); linkRelation = link.substring(positionOfSeparator + 1, link.length()).trim(); @@ -50,20 +28,9 @@ public final class HTTPLinkHeaderUtil { return uriWithSpecifiedRel; } - static Object extractTypeOfRelation(final String linkRelation) { + private static Object extractTypeOfRelation(final String linkRelation) { final int positionOfEquals = linkRelation.indexOf('='); return linkRelation.substring(positionOfEquals + 2, linkRelation.length() - 1).trim(); } - /** - * ex.
- * https://api.github.com/users/steveklabnik/gists?page=2>; rel="next" - */ - public static String extractSingleURI(final String linkHeader) { - Preconditions.checkNotNull(linkHeader); - final int positionOfSeparator = linkHeader.indexOf(';'); - - return linkHeader.substring(1, positionOfSeparator - 1); - } - } diff --git a/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/controller/ExpressionUtilityObjectsControllerIntegrationTest.java b/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/controller/ExpressionUtilityObjectsControllerIntegrationTest.java index 6c551b53b2..462e9e8c21 100644 --- a/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/controller/ExpressionUtilityObjectsControllerIntegrationTest.java +++ b/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/controller/ExpressionUtilityObjectsControllerIntegrationTest.java @@ -41,7 +41,7 @@ public class ExpressionUtilityObjectsControllerIntegrationTest { @Autowired private Filter springSecurityFilterChain; - protected RequestPostProcessor testUser() { + private RequestPostProcessor testUser() { return user("user1").password("user1Pass").roles("USER"); } diff --git a/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/controller/LayoutDialectControllerIntegrationTest.java b/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/controller/LayoutDialectControllerIntegrationTest.java index 62c364f864..9c5efdbfc2 100644 --- a/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/controller/LayoutDialectControllerIntegrationTest.java +++ b/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/controller/LayoutDialectControllerIntegrationTest.java @@ -41,7 +41,7 @@ public class LayoutDialectControllerIntegrationTest { @Autowired private Filter springSecurityFilterChain; - protected RequestPostProcessor testUser() { + private RequestPostProcessor testUser() { return user("user1").password("user1Pass").roles("USER"); } diff --git a/spring-thymeleaf/src/test/java/org/baeldung/security/csrf/CsrfEnabledIntegrationTest.java b/spring-thymeleaf/src/test/java/org/baeldung/security/csrf/CsrfEnabledIntegrationTest.java index 3d8ddfdd5c..4f6480e3b2 100644 --- a/spring-thymeleaf/src/test/java/org/baeldung/security/csrf/CsrfEnabledIntegrationTest.java +++ b/spring-thymeleaf/src/test/java/org/baeldung/security/csrf/CsrfEnabledIntegrationTest.java @@ -41,7 +41,7 @@ public class CsrfEnabledIntegrationTest { @Autowired private Filter springSecurityFilterChain; - protected RequestPostProcessor testUser() { + private RequestPostProcessor testUser() { return user("user1").password("user1Pass").roles("USER"); } diff --git a/testing/src/test/java/com/baeldung/junitparams/SafeAdditionUtilTest.java b/testing/src/test/java/com/baeldung/junitparams/SafeAdditionUtilTest.java index 8ab49309cd..f1659437ec 100644 --- a/testing/src/test/java/com/baeldung/junitparams/SafeAdditionUtilTest.java +++ b/testing/src/test/java/com/baeldung/junitparams/SafeAdditionUtilTest.java @@ -1,20 +1,20 @@ package com.baeldung.junitparams; -import static org.junit.Assert.assertEquals; - import junitparams.FileParameters; import junitparams.JUnitParamsRunner; import junitparams.Parameters; import org.junit.Test; import org.junit.runner.RunWith; +import static org.junit.Assert.assertEquals; + @RunWith(JUnitParamsRunner.class) public class SafeAdditionUtilTest { private SafeAdditionUtil serviceUnderTest = new SafeAdditionUtil(); @Test - @Parameters({ "1, 2, 3", "-10, 30, 20", "15, -5, 10", "-5, -10, -15" }) + @Parameters({"1, 2, 3", "-10, 30, 20", "15, -5, 10", "-5, -10, -15"}) public void whenWithAnnotationProvidedParams_thenSafeAdd(int a, int b, int expectedValue) { assertEquals(expectedValue, serviceUnderTest.safeAdd(a, b)); } @@ -26,7 +26,7 @@ public class SafeAdditionUtilTest { } private Object[] parametersToTestAdd() { - return new Object[] { new Object[] { 1, 2, 3 }, new Object[] { -10, 30, 20 }, new Object[] { Integer.MAX_VALUE, 2, Integer.MAX_VALUE }, new Object[] { Integer.MIN_VALUE, -8, Integer.MIN_VALUE } }; + return new Object[]{new Object[]{1, 2, 3}, new Object[]{-10, 30, 20}, new Object[]{Integer.MAX_VALUE, 2, Integer.MAX_VALUE}, new Object[]{Integer.MIN_VALUE, -8, Integer.MIN_VALUE}}; } @Test @@ -36,7 +36,7 @@ public class SafeAdditionUtilTest { } private Object[] parametersForWhenWithnoParam_thenLoadByNameSafeAdd() { - return new Object[] { new Object[] { 1, 2, 3 }, new Object[] { -10, 30, 20 }, new Object[] { Integer.MAX_VALUE, 2, Integer.MAX_VALUE }, new Object[] { Integer.MIN_VALUE, -8, Integer.MIN_VALUE } }; + return new Object[]{new Object[]{1, 2, 3}, new Object[]{-10, 30, 20}, new Object[]{Integer.MAX_VALUE, 2, Integer.MAX_VALUE}, new Object[]{Integer.MIN_VALUE, -8, Integer.MIN_VALUE}}; } @Test diff --git a/testing/src/test/java/com/baeldung/junitparams/TestDataProvider.java b/testing/src/test/java/com/baeldung/junitparams/TestDataProvider.java index d318345a56..08a472502e 100644 --- a/testing/src/test/java/com/baeldung/junitparams/TestDataProvider.java +++ b/testing/src/test/java/com/baeldung/junitparams/TestDataProvider.java @@ -3,11 +3,11 @@ package com.baeldung.junitparams; public class TestDataProvider { public static Object[] provideBasicData() { - return new Object[] { new Object[] { 1, 2, 3 }, new Object[] { -10, 30, 20 }, new Object[] { 15, -5, 10 }, new Object[] { -5, -10, -15 } }; + return new Object[]{new Object[]{1, 2, 3}, new Object[]{-10, 30, 20}, new Object[]{15, -5, 10}, new Object[]{-5, -10, -15}}; } public static Object[] provideEdgeCaseData() { - return new Object[] { new Object[] { Integer.MAX_VALUE, 2, Integer.MAX_VALUE }, new Object[] { Integer.MIN_VALUE, -2, Integer.MIN_VALUE }, }; + return new Object[]{new Object[]{Integer.MAX_VALUE, 2, Integer.MAX_VALUE}, new Object[]{Integer.MIN_VALUE, -2, Integer.MIN_VALUE},}; } } diff --git a/testing/src/test/java/com/baeldung/testing/calculator/CalculatorIntegrationTest.java b/testing/src/test/java/com/baeldung/testing/calculator/CalculatorIntegrationTest.java index 1cdb92090a..20bd62396c 100644 --- a/testing/src/test/java/com/baeldung/testing/calculator/CalculatorIntegrationTest.java +++ b/testing/src/test/java/com/baeldung/testing/calculator/CalculatorIntegrationTest.java @@ -1,15 +1,14 @@ package com.baeldung.testing.calculator; -import org.junit.runner.RunWith; - import cucumber.api.CucumberOptions; import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; @RunWith(Cucumber.class) @CucumberOptions( - features={"classpath:features/calculator.feature", "classpath:features/calculator-scenario-outline.feature"} - , plugin = { "pretty", "json:target/reports/json/calculator.json" } - , glue = {"com.baeldung.cucumber.calculator"} + features = {"classpath:features/calculator.feature", "classpath:features/calculator-scenario-outline.feature"} + , plugin = {"pretty", "json:target/reports/json/calculator.json"} + , glue = {"com.baeldung.cucumber.calculator"} ) public class CalculatorIntegrationTest { } diff --git a/vavr/src/test/java/com/baeldung/vavr/collections/CollectionAPIUnitTest.java b/vavr/src/test/java/com/baeldung/vavr/collections/CollectionAPIUnitTest.java index 48c0cb7305..8b05b5a230 100644 --- a/vavr/src/test/java/com/baeldung/vavr/collections/CollectionAPIUnitTest.java +++ b/vavr/src/test/java/com/baeldung/vavr/collections/CollectionAPIUnitTest.java @@ -1,16 +1,5 @@ package com.baeldung.vavr.collections; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; - -import java.util.Comparator; - -import org.junit.Test; - -import io.vavr.Tuple; import io.vavr.Tuple2; import io.vavr.collection.Array; import io.vavr.collection.CharSeq; @@ -26,6 +15,16 @@ import io.vavr.collection.Stream; import io.vavr.collection.TreeMap; import io.vavr.collection.TreeSet; import io.vavr.collection.Vector; +import org.junit.Test; + +import java.util.Comparator; +import java.util.stream.Collectors; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; public class CollectionAPIUnitTest { @@ -34,7 +33,7 @@ public class CollectionAPIUnitTest { List intList = List.empty(); List anotherList = intList.push(4) - .push(0); + .push(0); Iterator iterator = anotherList.iterator(); assertEquals(new Integer(0), iterator.next()); @@ -46,7 +45,7 @@ public class CollectionAPIUnitTest { List intList = List.of(1, 2, 3); List newList = intList.tail() - .prepend(0); + .prepend(0); assertEquals(new Integer(1), intList.get(0)); assertEquals(new Integer(2), intList.get(1)); @@ -62,45 +61,45 @@ public class CollectionAPIUnitTest { public void givenQueue_whenEnqueued_thenCorrect() { Queue queue = Queue.of(1, 2, 3); Queue secondQueue = queue.enqueue(4) - .enqueue(5); + .enqueue(5); assertEquals(3, queue.size()); assertEquals(5, secondQueue.size()); secondQueue.dequeue() - .map((k, v) -> { - assertEquals(new Integer(1), k); - return v.dequeue(); - }) - .map((k, v) -> { - assertEquals(new Integer(2), k); - return v.dequeue(); - }) - .map((k, v) -> { - assertEquals(new Integer(3), k); - return v.dequeue(); - }) - .map((k, v) -> { - assertEquals(new Integer(4), k); - return v.dequeue(); - }) - .map((k, v) -> { - assertEquals(new Integer(5), k); - assertTrue(v.isEmpty()); - return null; - }); + .map((k, v) -> { + assertEquals(new Integer(1), k); + return v.dequeue(); + }) + .map((k, v) -> { + assertEquals(new Integer(2), k); + return v.dequeue(); + }) + .map((k, v) -> { + assertEquals(new Integer(3), k); + return v.dequeue(); + }) + .map((k, v) -> { + assertEquals(new Integer(4), k); + return v.dequeue(); + }) + .map((k, v) -> { + assertEquals(new Integer(5), k); + assertTrue(v.isEmpty()); + return null; + }); } @Test public void givenStream_whenProcessed_thenCorrect() { Stream intStream = Stream.iterate(0, i -> i + 1) - .take(10); + .take(10); assertEquals(10, intStream.size()); long evenSum = intStream.filter(i -> i % 2 == 0) - .sum() - .longValue(); + .sum() + .longValue(); assertEquals(20L, evenSum); assertEquals(new Integer(5), intStream.get(5)); @@ -170,7 +169,7 @@ public class CollectionAPIUnitTest { @Test public void givenSortedSet_whenReversed_thenCorrect() { - Comparator reverseCompare = (a, b) -> b.compareTo(a); + Comparator reverseCompare = Comparator.reverseOrder(); SortedSet set = TreeSet.of(reverseCompare, "Green", "Red", "Blue"); Iterator iterator = set.iterator(); @@ -182,17 +181,17 @@ public class CollectionAPIUnitTest { @Test public void givenMap_whenIterated_thenCorrect() { Map> map = List.rangeClosed(0, 10) - .groupBy(i -> i % 2); + .groupBy(i -> i % 2); assertEquals(2, map.size()); Iterator>> iterator = map.iterator(); assertEquals(6, iterator.next() - ._2() - .size()); + ._2() + .size()); assertEquals(5, iterator.next() - ._2() - .size()); + ._2() + .size()); } @Test @@ -201,11 +200,11 @@ public class CollectionAPIUnitTest { Iterator> iterator = map.iterator(); assertEquals(new Integer(1), iterator.next() - ._1()); + ._1()); assertEquals(new Integer(2), iterator.next() - ._1()); + ._1()); assertEquals(new Integer(3), iterator.next() - ._1()); + ._1()); } @Test @@ -223,19 +222,14 @@ public class CollectionAPIUnitTest { @Test public void givenVavrList_whenConverted_thenCorrect() { - Integer[] array = List.of(1, 2, 3) - .toJavaArray(Integer.class); - assertEquals(3, array.length); - - java.util.Map map = List.of("1", "2", "3") - .toJavaMap(i -> Tuple.of(i, Integer.valueOf(i))); - assertEquals(new Integer(2), map.get("2")); + java.util.Set collect = List.of(1, 2, 3) + .collect(Collectors.toSet()); } @Test public void givenVavrList_whenConvertedView_thenCorrect() { java.util.List javaList = List.of(1, 2, 3) - .asJavaMutable(); + .asJavaMutable(); javaList.add(4); assertEquals(new Integer(4), javaList.get(3)); @@ -244,7 +238,7 @@ public class CollectionAPIUnitTest { @Test(expected = UnsupportedOperationException.class) public void givenVavrList_whenConvertedView_thenException() { java.util.List javaList = List.of(1, 2, 3) - .asJava(); + .asJava(); assertEquals(new Integer(3), javaList.get(2)); javaList.add(4); @@ -254,8 +248,8 @@ public class CollectionAPIUnitTest { public void givenList_whenSquared_thenCorrect() { List vavrList = List.of(1, 2, 3); Number sum = vavrList.map(i -> i * i) - .sum(); + .sum(); - assertEquals(new Long(14), sum); + assertEquals(14L, sum); } } diff --git a/video-tutorials/jackson-annotations/src/test/java/com/baeldung/jacksonannotation/deserialization/jsoncreator/JsonCreatorUnitTest.java b/video-tutorials/jackson-annotations/src/test/java/com/baeldung/jacksonannotation/deserialization/jsoncreator/JsonCreatorUnitTest.java index 1b1986417d..33c96acf52 100644 --- a/video-tutorials/jackson-annotations/src/test/java/com/baeldung/jacksonannotation/deserialization/jsoncreator/JsonCreatorUnitTest.java +++ b/video-tutorials/jackson-annotations/src/test/java/com/baeldung/jacksonannotation/deserialization/jsoncreator/JsonCreatorUnitTest.java @@ -21,10 +21,10 @@ public class JsonCreatorUnitTest { // arrange String authorJson = - "{" + - " \"christianName\": \"Alex\"," + - " \"surname\": \"Theedom\"" + - "}"; + "{" + + " \"christianName\": \"Alex\"," + + " \"surname\": \"Theedom\"" + + "}"; // act final Author author = new ObjectMapper().readerFor(Author.class).readValue(authorJson); diff --git a/video-tutorials/jackson-annotations/src/test/java/com/baeldung/jacksonannotation/general/jsonfilter/JsonFilterUnitTest.java b/video-tutorials/jackson-annotations/src/test/java/com/baeldung/jacksonannotation/general/jsonfilter/JsonFilterUnitTest.java index 133f8b1f21..5491168f9b 100644 --- a/video-tutorials/jackson-annotations/src/test/java/com/baeldung/jacksonannotation/general/jsonfilter/JsonFilterUnitTest.java +++ b/video-tutorials/jackson-annotations/src/test/java/com/baeldung/jacksonannotation/general/jsonfilter/JsonFilterUnitTest.java @@ -24,7 +24,7 @@ public class JsonFilterUnitTest { // arrange Author author = new Author("Alex", "Theedom"); FilterProvider filters = new SimpleFilterProvider() - .addFilter("authorFilter", SimpleBeanPropertyFilter.filterOutAllExcept("lastName")); + .addFilter("authorFilter", SimpleBeanPropertyFilter.filterOutAllExcept("lastName")); // act String result = new ObjectMapper().writer(filters).writeValueAsString(author); diff --git a/video-tutorials/jackson-annotations/src/test/java/com/baeldung/jacksonannotation/general/jsonformat/JsonFormatUnitTest.java b/video-tutorials/jackson-annotations/src/test/java/com/baeldung/jacksonannotation/general/jsonformat/JsonFormatUnitTest.java index 373e8d716a..6801516dfd 100644 --- a/video-tutorials/jackson-annotations/src/test/java/com/baeldung/jacksonannotation/general/jsonformat/JsonFormatUnitTest.java +++ b/video-tutorials/jackson-annotations/src/test/java/com/baeldung/jacksonannotation/general/jsonformat/JsonFormatUnitTest.java @@ -32,8 +32,8 @@ public class JsonFormatUnitTest { Date date = df.parse(toParse); Book book = new Book( - "Design Patterns: Elements of Reusable Object-oriented Software", - new Author("The", "GoF") + "Design Patterns: Elements of Reusable Object-oriented Software", + new Author("The", "GoF") ); book.setPublished(date); diff --git a/video-tutorials/jackson-annotations/src/test/java/com/baeldung/jacksonannotation/general/jsonproperty/JsonPropertyUnitTest.java b/video-tutorials/jackson-annotations/src/test/java/com/baeldung/jacksonannotation/general/jsonproperty/JsonPropertyUnitTest.java index 191330be86..62f9b498ac 100644 --- a/video-tutorials/jackson-annotations/src/test/java/com/baeldung/jacksonannotation/general/jsonproperty/JsonPropertyUnitTest.java +++ b/video-tutorials/jackson-annotations/src/test/java/com/baeldung/jacksonannotation/general/jsonproperty/JsonPropertyUnitTest.java @@ -22,8 +22,8 @@ public class JsonPropertyUnitTest { // arrange Book book = new Book( - "Design Patterns: Elements of Reusable Object-oriented Software", - new Author("The", "GoF") + "Design Patterns: Elements of Reusable Object-oriented Software", + new Author("The", "GoF") ); book.configureBinding("Hardback"); From 75ac7de5cde3ac424af9e9f145f258fb4a237703 Mon Sep 17 00:00:00 2001 From: mokhan Date: Fri, 21 Jul 2017 22:12:27 +0530 Subject: [PATCH 60/89] Updated custom logging implementation --- spring-rest-logging/pom.xml | 11 ++++++++++- .../log/app/TaxiFareRequestInterceptor.java | 19 ++++++++++++++++++- .../config/RequestLoggingFilterConfig.java | 3 --- .../log/controller/TaxiFareController.java | 5 ++++- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/spring-rest-logging/pom.xml b/spring-rest-logging/pom.xml index 5924650e5f..799a746b63 100644 --- a/spring-rest-logging/pom.xml +++ b/spring-rest-logging/pom.xml @@ -12,7 +12,7 @@ spring-boot-starter-parent 1.4.3.RELEASE - + @@ -60,5 +60,14 @@ org.springframework spring-test + + + + commons-io + commons-io + 2.4 + + + diff --git a/spring-rest-logging/src/main/java/com/baeldung/rest/log/app/TaxiFareRequestInterceptor.java b/spring-rest-logging/src/main/java/com/baeldung/rest/log/app/TaxiFareRequestInterceptor.java index bc011a4db7..4c187772cc 100644 --- a/spring-rest-logging/src/main/java/com/baeldung/rest/log/app/TaxiFareRequestInterceptor.java +++ b/spring-rest-logging/src/main/java/com/baeldung/rest/log/app/TaxiFareRequestInterceptor.java @@ -7,6 +7,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; +import org.springframework.web.util.ContentCachingRequestWrapper; + +import com.baeldung.rest.log.util.RequestLoggingUtil; @Component public class TaxiFareRequestInterceptor extends HandlerInterceptorAdapter { @@ -15,7 +18,21 @@ public class TaxiFareRequestInterceptor extends HandlerInterceptorAdapter { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { - LOGGER.info("REQUEST URI: " + request.getRequestURI()); + String postData = null; + HttpServletRequest requestCacheWrapperObject = null; + try { + // Uncomment to produce the stream closed issue + // postData = RequestLoggingUtil.getStringFromInputStream(request.getInputStream()); + + // To overcome request stream closed issue + requestCacheWrapperObject = new ContentCachingRequestWrapper(request); + requestCacheWrapperObject.getParameterMap(); + } catch (Exception exception) { + exception.printStackTrace(); + } finally { + postData = RequestLoggingUtil.readPayload(requestCacheWrapperObject); + LOGGER.info("REQUEST DATA: " + postData); + } return true; } diff --git a/spring-rest-logging/src/main/java/com/baeldung/rest/log/config/RequestLoggingFilterConfig.java b/spring-rest-logging/src/main/java/com/baeldung/rest/log/config/RequestLoggingFilterConfig.java index 158ba51f77..7afb34dd11 100644 --- a/spring-rest-logging/src/main/java/com/baeldung/rest/log/config/RequestLoggingFilterConfig.java +++ b/spring-rest-logging/src/main/java/com/baeldung/rest/log/config/RequestLoggingFilterConfig.java @@ -1,13 +1,10 @@ package com.baeldung.rest.log.config; -import javax.servlet.annotation.WebFilter; - import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.filter.CommonsRequestLoggingFilter; @Configuration -@WebFilter public class RequestLoggingFilterConfig { @Bean diff --git a/spring-rest-logging/src/main/java/com/baeldung/rest/log/controller/TaxiFareController.java b/spring-rest-logging/src/main/java/com/baeldung/rest/log/controller/TaxiFareController.java index 0d8e4dafa4..1ef9ece0b2 100644 --- a/spring-rest-logging/src/main/java/com/baeldung/rest/log/controller/TaxiFareController.java +++ b/spring-rest-logging/src/main/java/com/baeldung/rest/log/controller/TaxiFareController.java @@ -34,7 +34,10 @@ public class TaxiFareController { @ResponseBody public String calculateTaxiFare(@RequestBody @Valid TaxiRide taxiRide) { LOGGER.debug("calculateTaxiFare() - START"); - return taxiFareCalculatorService.calculateFare(taxiRide); + String totalFare = taxiFareCalculatorService.calculateFare(taxiRide); + LOGGER.debug("calculateTaxiFare() - Total Fare : {}",totalFare); + LOGGER.debug("calculateTaxiFare() - END"); + return totalFare; } } From e96690ef203ddfd2e8d0202d41faebdeb96aa833 Mon Sep 17 00:00:00 2001 From: slavisa-baeldung Date: Sat, 22 Jul 2017 07:05:12 +0100 Subject: [PATCH 61/89] BAEL-964 - Changing assertions within invert test --- .../commons/collections/MapUtilsTest.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/libraries/src/test/java/com/baeldung/commons/collections/MapUtilsTest.java b/libraries/src/test/java/com/baeldung/commons/collections/MapUtilsTest.java index 10d408b467..4685d84781 100644 --- a/libraries/src/test/java/com/baeldung/commons/collections/MapUtilsTest.java +++ b/libraries/src/test/java/com/baeldung/commons/collections/MapUtilsTest.java @@ -4,14 +4,19 @@ import org.apache.commons.collections4.MapIterator; import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.PredicateUtils; import org.apache.commons.collections4.TransformerUtils; +import org.assertj.core.api.Assertions; import org.junit.Before; import org.junit.Test; import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import java.util.Collection; import java.util.HashMap; import java.util.Map; +import java.util.Set; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; import static org.hamcrest.collection.IsMapContaining.hasEntry; import static org.hamcrest.collection.IsMapWithSize.aMapWithSize; @@ -85,19 +90,12 @@ public class MapUtilsTest { @Test public void whenInvertMap_thenMustReturnInvertedMap() { Map invColorMap = MapUtils.invertMap(this.colorMap); - assertEquals(this.colorMap.size(), invColorMap.size()); - MapIterator itColorMap - = MapUtils.iterableMap(this.colorMap).mapIterator(); - - while (itColorMap.hasNext()) { - String colorMapKey = itColorMap.next(); - String colorMapValue = itColorMap.getValue(); - - String invColorMapValue = MapUtils.getString(invColorMap, colorMapValue); - - assertTrue(invColorMapValue.equals(colorMapKey)); - } + int size = invColorMap.size(); + Assertions.assertThat(invColorMap) + .hasSameSizeAs(colorMap) + .containsKeys(this.colorMap.values().toArray(new String[size])) + .containsValues(this.colorMap.keySet().toArray(new String[size])); } @Test(expected = IllegalArgumentException.class) From 226acd5a195a3173d19a7c520fb778bb95512db8 Mon Sep 17 00:00:00 2001 From: Naresh Babu P B Date: Sat, 22 Jul 2017 19:08:37 +0530 Subject: [PATCH 62/89] Bael-422 Vavr Collections (#2304) * BAEL-422 Examples for tutorial on Vavr Collection API * Fixed as per review comments --- .../collections/CollectionAPIUnitTest.java | 95 +++++++++++-------- 1 file changed, 57 insertions(+), 38 deletions(-) diff --git a/vavr/src/test/java/com/baeldung/vavr/collections/CollectionAPIUnitTest.java b/vavr/src/test/java/com/baeldung/vavr/collections/CollectionAPIUnitTest.java index 8b05b5a230..9f0c48e3ee 100644 --- a/vavr/src/test/java/com/baeldung/vavr/collections/CollectionAPIUnitTest.java +++ b/vavr/src/test/java/com/baeldung/vavr/collections/CollectionAPIUnitTest.java @@ -1,5 +1,18 @@ package com.baeldung.vavr.collections; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + +import java.util.Comparator; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +import org.junit.Test; + +import io.vavr.Tuple; import io.vavr.Tuple2; import io.vavr.collection.Array; import io.vavr.collection.CharSeq; @@ -15,16 +28,6 @@ import io.vavr.collection.Stream; import io.vavr.collection.TreeMap; import io.vavr.collection.TreeSet; import io.vavr.collection.Vector; -import org.junit.Test; - -import java.util.Comparator; -import java.util.stream.Collectors; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; public class CollectionAPIUnitTest { @@ -66,28 +69,16 @@ public class CollectionAPIUnitTest { assertEquals(3, queue.size()); assertEquals(5, secondQueue.size()); - secondQueue.dequeue() - .map((k, v) -> { - assertEquals(new Integer(1), k); - return v.dequeue(); - }) - .map((k, v) -> { - assertEquals(new Integer(2), k); - return v.dequeue(); - }) - .map((k, v) -> { - assertEquals(new Integer(3), k); - return v.dequeue(); - }) - .map((k, v) -> { - assertEquals(new Integer(4), k); - return v.dequeue(); - }) - .map((k, v) -> { - assertEquals(new Integer(5), k); - assertTrue(v.isEmpty()); - return null; - }); + Tuple2> result = secondQueue.dequeue(); + Integer headValue = result.apply((head, tail) -> head); + assertEquals(new Integer(1), headValue); + + Iterator iterator = result.apply((head, tail) -> tail.iterator()); + + assertEquals(new Integer(2), iterator.next()); + assertEquals(new Integer(3), iterator.next()); + assertEquals(new Integer(4), iterator.next()); + assertEquals(new Integer(5), iterator.next()); } @Test @@ -101,7 +92,7 @@ public class CollectionAPIUnitTest { .sum() .longValue(); - assertEquals(20L, evenSum); + assertEquals(20, evenSum); assertEquals(new Integer(5), intStream.get(5)); } @@ -169,8 +160,7 @@ public class CollectionAPIUnitTest { @Test public void givenSortedSet_whenReversed_thenCorrect() { - Comparator reverseCompare = Comparator.reverseOrder(); - SortedSet set = TreeSet.of(reverseCompare, "Green", "Red", "Blue"); + SortedSet set = TreeSet.of(Comparator.reverseOrder(), "Green", "Red", "Blue"); Iterator iterator = set.iterator(); assertEquals("Red", iterator.next()); @@ -212,18 +202,47 @@ public class CollectionAPIUnitTest { java.util.List javaList = java.util.Arrays.asList(1, 2, 3, 4); List vavrList = List.ofAll(javaList); - assertTrue(vavrList instanceof io.vavr.collection.List); + assertEquals(4, vavrList.size()); + assertEquals(new Integer(1), vavrList.head()); java.util.stream.Stream javaStream = javaList.stream(); Set vavrSet = HashSet.ofAll(javaStream); - assertTrue(vavrSet instanceof io.vavr.collection.Set); + assertEquals(4, vavrSet.size()); + assertEquals(new Integer(2), vavrSet.tail() + .head()); + } + + @Test + public void givenJavaStream_whenCollected_thenCorrect() { + List vavrList = IntStream.range(1, 10) + .boxed() + .filter(i -> i % 2 == 0) + .collect(List.collector()); + + assertEquals(4, vavrList.size()); + assertEquals(new Integer(2), vavrList.head()); } @Test public void givenVavrList_whenConverted_thenCorrect() { - java.util.Set collect = List.of(1, 2, 3) + Integer[] array = List.of(1, 2, 3) + .toJavaArray(Integer.class); + assertEquals(3, array.length); + + java.util.Map map = List.of("1", "2", "3") + .toJavaMap(i -> Tuple.of(i, Integer.valueOf(i))); + assertEquals(new Integer(2), map.get("2")); + } + + @Test + public void givenVavrList_whenCollected_thenCorrect() { + java.util.Set javaSet = List.of(1, 2, 3) .collect(Collectors.toSet()); + + assertEquals(3, javaSet.size()); + assertEquals(new Integer(1), javaSet.iterator() + .next()); } @Test From 101f6fd163f23cd825eb9d06dcda318ea620fbcc Mon Sep 17 00:00:00 2001 From: mokhan Date: Sun, 23 Jul 2017 14:44:52 +0530 Subject: [PATCH 63/89] Comment incorporation Missing file commit --- .../rest/log/util/RequestLoggingUtil.java | 38 +++++++++++++++++++ .../controller/TestTaxiFareController.java | 4 +- 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 spring-rest-logging/src/main/java/com/baeldung/rest/log/util/RequestLoggingUtil.java diff --git a/spring-rest-logging/src/main/java/com/baeldung/rest/log/util/RequestLoggingUtil.java b/spring-rest-logging/src/main/java/com/baeldung/rest/log/util/RequestLoggingUtil.java new file mode 100644 index 0000000000..3c9eebf34e --- /dev/null +++ b/spring-rest-logging/src/main/java/com/baeldung/rest/log/util/RequestLoggingUtil.java @@ -0,0 +1,38 @@ +package com.baeldung.rest.log.util; + +import java.io.IOException; +import java.io.InputStream; +import java.io.StringWriter; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.commons.io.IOUtils; +import org.springframework.web.util.ContentCachingRequestWrapper; +import org.springframework.web.util.WebUtils; + +public class RequestLoggingUtil { + + public static String getStringFromInputStream(InputStream is) { + StringWriter writer = new StringWriter(); + String encoding = "UTF-8"; + try { + IOUtils.copy(is, writer, encoding); + } catch (IOException e) { + e.printStackTrace(); + } + return writer.toString(); + } + + public static String readPayload(final HttpServletRequest request) throws IOException { + String payloadData = null; + ContentCachingRequestWrapper contentCachingRequestWrapper = WebUtils.getNativeRequest(request, ContentCachingRequestWrapper.class); + if (null != contentCachingRequestWrapper) { + byte[] buf = contentCachingRequestWrapper.getContentAsByteArray(); + if (buf.length > 0) { + payloadData = new String(buf, 0, buf.length, contentCachingRequestWrapper.getCharacterEncoding()); + } + } + return payloadData; + } + +} diff --git a/spring-rest-logging/src/test/java/com/baeldung/rest/log/controller/TestTaxiFareController.java b/spring-rest-logging/src/test/java/com/baeldung/rest/log/controller/TestTaxiFareController.java index 61d279a0c5..ed3cdda7ad 100644 --- a/spring-rest-logging/src/test/java/com/baeldung/rest/log/controller/TestTaxiFareController.java +++ b/spring-rest-logging/src/test/java/com/baeldung/rest/log/controller/TestTaxiFareController.java @@ -15,14 +15,14 @@ public class TestTaxiFareController { private static final String URL = "http://localhost:" + 9090 + "/rest-log/taxifare/"; @Test - public void given_taxi_fare_get() { + public void givenRequest_thenfetchTaxiFareRateCard() { TestRestTemplate testRestTemplate = new TestRestTemplate(); ResponseEntity response = testRestTemplate.getForEntity(URL + "get/", String.class); assertThat(response.getStatusCode(), equalTo(HttpStatus.OK)); } @Test - public void given_taxi_ride_get_fare() { + public void givenTaxiRide_thenGetCalculatedFare() { TestRestTemplate testRestTemplate = new TestRestTemplate(); TaxiRide taxiRide = new TaxiRide(true,10l); String fare = testRestTemplate.postForObject(URL + "calculate/", taxiRide,String.class); From 879bedf205e7609cd5d792d21d0ba680d681f545 Mon Sep 17 00:00:00 2001 From: mokhan Date: Sun, 23 Jul 2017 14:44:52 +0530 Subject: [PATCH 64/89] Comment incorporation Missing file commit --- pom.xml | 1 + .../rest/log/util/RequestLoggingUtil.java | 38 +++++++++++++++++++ .../controller/TestTaxiFareController.java | 4 +- 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 spring-rest-logging/src/main/java/com/baeldung/rest/log/util/RequestLoggingUtil.java diff --git a/pom.xml b/pom.xml index 818d131359..9bfadc01a5 100644 --- a/pom.xml +++ b/pom.xml @@ -208,6 +208,7 @@ spring-zuul spring-reactor spring-vertx + spring-rest-logging testing testng diff --git a/spring-rest-logging/src/main/java/com/baeldung/rest/log/util/RequestLoggingUtil.java b/spring-rest-logging/src/main/java/com/baeldung/rest/log/util/RequestLoggingUtil.java new file mode 100644 index 0000000000..3c9eebf34e --- /dev/null +++ b/spring-rest-logging/src/main/java/com/baeldung/rest/log/util/RequestLoggingUtil.java @@ -0,0 +1,38 @@ +package com.baeldung.rest.log.util; + +import java.io.IOException; +import java.io.InputStream; +import java.io.StringWriter; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.commons.io.IOUtils; +import org.springframework.web.util.ContentCachingRequestWrapper; +import org.springframework.web.util.WebUtils; + +public class RequestLoggingUtil { + + public static String getStringFromInputStream(InputStream is) { + StringWriter writer = new StringWriter(); + String encoding = "UTF-8"; + try { + IOUtils.copy(is, writer, encoding); + } catch (IOException e) { + e.printStackTrace(); + } + return writer.toString(); + } + + public static String readPayload(final HttpServletRequest request) throws IOException { + String payloadData = null; + ContentCachingRequestWrapper contentCachingRequestWrapper = WebUtils.getNativeRequest(request, ContentCachingRequestWrapper.class); + if (null != contentCachingRequestWrapper) { + byte[] buf = contentCachingRequestWrapper.getContentAsByteArray(); + if (buf.length > 0) { + payloadData = new String(buf, 0, buf.length, contentCachingRequestWrapper.getCharacterEncoding()); + } + } + return payloadData; + } + +} diff --git a/spring-rest-logging/src/test/java/com/baeldung/rest/log/controller/TestTaxiFareController.java b/spring-rest-logging/src/test/java/com/baeldung/rest/log/controller/TestTaxiFareController.java index 61d279a0c5..ed3cdda7ad 100644 --- a/spring-rest-logging/src/test/java/com/baeldung/rest/log/controller/TestTaxiFareController.java +++ b/spring-rest-logging/src/test/java/com/baeldung/rest/log/controller/TestTaxiFareController.java @@ -15,14 +15,14 @@ public class TestTaxiFareController { private static final String URL = "http://localhost:" + 9090 + "/rest-log/taxifare/"; @Test - public void given_taxi_fare_get() { + public void givenRequest_thenfetchTaxiFareRateCard() { TestRestTemplate testRestTemplate = new TestRestTemplate(); ResponseEntity response = testRestTemplate.getForEntity(URL + "get/", String.class); assertThat(response.getStatusCode(), equalTo(HttpStatus.OK)); } @Test - public void given_taxi_ride_get_fare() { + public void givenTaxiRide_thenGetCalculatedFare() { TestRestTemplate testRestTemplate = new TestRestTemplate(); TaxiRide taxiRide = new TaxiRide(true,10l); String fare = testRestTemplate.postForObject(URL + "calculate/", taxiRide,String.class); From ef5013ce24fd38c6758ad608b4953ef757913544 Mon Sep 17 00:00:00 2001 From: Jesus Boadas Date: Sun, 23 Jul 2017 16:10:39 -0400 Subject: [PATCH 65/89] Delete Vaadin from libraries (#2309) * Delete Vaadin from libraries * Add Vaadin to tutorials --- libraries/pom.xml | 183 ------------------ .../webapp/VAADIN/themes/valo/addons.scss | 7 - vaadin/pom.xml | 173 +++++++++++++++++ .../com/baeldung/introduction}/BindData.java | 2 +- .../com/baeldung/introduction}/VaadinUI.java | 4 +- vaadin/src/main/resources/README | 1 + .../webapp/VAADIN/themes/mytheme/addons.scss | 0 .../webapp/VAADIN/themes/mytheme/favicon.ico | Bin .../webapp/VAADIN/themes/mytheme/mytheme.scss | 0 .../webapp/VAADIN/themes/mytheme/styles.css | 0 .../webapp/VAADIN/themes/mytheme/styles.scss | 0 11 files changed, 177 insertions(+), 193 deletions(-) delete mode 100644 libraries/src/main/webapp/VAADIN/themes/valo/addons.scss create mode 100644 vaadin/pom.xml rename {libraries/src/main/java/com/baeldung/vaadin => vaadin/src/main/java/com/baeldung/introduction}/BindData.java (89%) rename {libraries/src/main/java/com/baeldung/vaadin => vaadin/src/main/java/com/baeldung/introduction}/VaadinUI.java (99%) create mode 100644 vaadin/src/main/resources/README rename {libraries => vaadin}/src/main/webapp/VAADIN/themes/mytheme/addons.scss (100%) rename {libraries => vaadin}/src/main/webapp/VAADIN/themes/mytheme/favicon.ico (100%) rename {libraries => vaadin}/src/main/webapp/VAADIN/themes/mytheme/mytheme.scss (100%) rename {libraries => vaadin}/src/main/webapp/VAADIN/themes/mytheme/styles.css (100%) rename {libraries => vaadin}/src/main/webapp/VAADIN/themes/mytheme/styles.scss (100%) diff --git a/libraries/pom.xml b/libraries/pom.xml index 16f70cb171..d80c9ffdae 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -71,78 +71,8 @@ - - - org.apache.maven.plugins - maven-war-plugin - 3.0.0 - - false - WEB-INF/classes/VAADIN/widgetsets/WEB-INF/** - - - - com.vaadin - vaadin-maven-plugin - ${vaadin.plugin.version} - - - - update-theme - update-widgetset - compile - compile-theme - - - - - - org.apache.maven.plugins - maven-clean-plugin - 3.0.0 - - - - src/main/webapp/VAADIN/themes - - **/styles.css - **/styles.scss.cache - - - - - - - org.eclipse.jetty - jetty-maven-plugin - ${jetty.version} - - 2 - true - - - - - - - vaadin-addons - http://maven.vaadin.com/vaadin-addons - - - - - - com.vaadin - vaadin-bom - ${vaadin.version} - pom - import - - - - @@ -463,72 +393,6 @@ ${org.hamcrest.java-hamcrest.version} test - - - com.vaadin - vaadin-server - - - com.vaadin - vaadin-client-compiled - - - com.vaadin - vaadin-themes - - - com.vaadin - vaadin-push - - - org.seleniumhq.selenium - selenium-java - test - 3.4.0 - - - org.seleniumhq.selenium - htmlunit-driver - 2.27 - - - org.eclipse.jetty.websocket - websocket-server - ${jetty.version} - - - org.eclipse.jetty.websocket - websocket-client - ${jetty.version} - - - org.eclipse.jetty.websocket - websocket-api - ${jetty.version} - - - org.eclipse.jetty.websocket - websocket-common - ${jetty.version} - - - org.eclipse.jetty - jetty-continuation - ${jetty.version} - - - org.eclipse.jetty - jetty-util - ${jetty.version} - - - org.seleniumhq.selenium - selenium-api - 3.4.0 - test - jar - - net.agkn hll @@ -580,54 +444,7 @@ 3.5.0 3.0.0 2.0.0.0 - - 7.7.10 - 8.0.6 - mytheme - 1.6.0 1.7.1 - - - - vaadin-prerelease - - false - - - - vaadin-prereleases - http://maven.vaadin.com/vaadin-prereleases - - - vaadin-snapshots - https://oss.sonatype.org/content/repositories/vaadin-snapshots/ - - false - - - true - - - - - - vaadin-prereleases - http://maven.vaadin.com/vaadin-prereleases - - - vaadin-snapshots - https://oss.sonatype.org/content/repositories/vaadin-snapshots/ - - false - - - true - - - - - - diff --git a/libraries/src/main/webapp/VAADIN/themes/valo/addons.scss b/libraries/src/main/webapp/VAADIN/themes/valo/addons.scss deleted file mode 100644 index a5670b70c7..0000000000 --- a/libraries/src/main/webapp/VAADIN/themes/valo/addons.scss +++ /dev/null @@ -1,7 +0,0 @@ -/* This file is automatically managed and will be overwritten from time to time. */ -/* Do not manually edit this file. */ - -/* Import and include this mixin into your project theme to include the addon themes */ -@mixin addons { -} - diff --git a/vaadin/pom.xml b/vaadin/pom.xml new file mode 100644 index 0000000000..6d3512ba2d --- /dev/null +++ b/vaadin/pom.xml @@ -0,0 +1,173 @@ + + + 4.0.0 + + org.test + vaadin-app + war + 1.0-SNAPSHOT + vaadin-app + + + 3 + + + + 7.7.10 + 8.0.6 + 9.3.9.v20160517 + UTF-8 + 1.8 + 1.8 + local + mytheme + + + + + vaadin-addons + http://maven.vaadin.com/vaadin-addons + + + + + + + com.vaadin + vaadin-bom + ${vaadin.version} + pom + import + + + + + + + javax.servlet + javax.servlet-api + 3.0.1 + provided + + + com.vaadin + vaadin-server + + + com.vaadin + vaadin-push + + + com.vaadin + vaadin-client-compiled + + + com.vaadin + vaadin-themes + + + + + + + org.apache.maven.plugins + maven-war-plugin + 3.0.0 + + false + + WEB-INF/classes/VAADIN/widgetsets/WEB-INF/** + + + + com.vaadin + vaadin-maven-plugin + ${vaadin.plugin.version} + + + + update-theme + update-widgetset + compile + + compile-theme + + + + + + org.apache.maven.plugins + maven-clean-plugin + 3.0.0 + + + + + src/main/webapp/VAADIN/themes + + **/styles.css + **/styles.scss.cache + + + + + + + + + org.eclipse.jetty + jetty-maven-plugin + ${jetty.plugin.version} + + 2 + + + + + + + + + vaadin-prerelease + + false + + + + + vaadin-prereleases + http://maven.vaadin.com/vaadin-prereleases + + + vaadin-snapshots + https://oss.sonatype.org/content/repositories/vaadin-snapshots/ + + false + + + true + + + + + + vaadin-prereleases + http://maven.vaadin.com/vaadin-prereleases + + + vaadin-snapshots + https://oss.sonatype.org/content/repositories/vaadin-snapshots/ + + false + + + true + + + + + + + diff --git a/libraries/src/main/java/com/baeldung/vaadin/BindData.java b/vaadin/src/main/java/com/baeldung/introduction/BindData.java similarity index 89% rename from libraries/src/main/java/com/baeldung/vaadin/BindData.java rename to vaadin/src/main/java/com/baeldung/introduction/BindData.java index bcdc4eee71..299554c039 100644 --- a/libraries/src/main/java/com/baeldung/vaadin/BindData.java +++ b/vaadin/src/main/java/com/baeldung/introduction/BindData.java @@ -1,4 +1,4 @@ -package com.baeldung.vaadin; +package com.baeldung.introduction; public class BindData { diff --git a/libraries/src/main/java/com/baeldung/vaadin/VaadinUI.java b/vaadin/src/main/java/com/baeldung/introduction/VaadinUI.java similarity index 99% rename from libraries/src/main/java/com/baeldung/vaadin/VaadinUI.java rename to vaadin/src/main/java/com/baeldung/introduction/VaadinUI.java index 68e2ca7944..1b3733ad74 100644 --- a/libraries/src/main/java/com/baeldung/vaadin/VaadinUI.java +++ b/vaadin/src/main/java/com/baeldung/introduction/VaadinUI.java @@ -1,4 +1,4 @@ -package com.baeldung.vaadin; +package com.baeldung.introduction; import java.time.Instant; import java.util.ArrayList; @@ -278,4 +278,4 @@ public class VaadinUI extends UI { @VaadinServletConfiguration(ui = VaadinUI.class, productionMode = false) public static class MyUIServlet extends VaadinServlet { } -} \ No newline at end of file +} diff --git a/vaadin/src/main/resources/README b/vaadin/src/main/resources/README new file mode 100644 index 0000000000..faabc74ad5 --- /dev/null +++ b/vaadin/src/main/resources/README @@ -0,0 +1 @@ +Please add your static resources here diff --git a/libraries/src/main/webapp/VAADIN/themes/mytheme/addons.scss b/vaadin/src/main/webapp/VAADIN/themes/mytheme/addons.scss similarity index 100% rename from libraries/src/main/webapp/VAADIN/themes/mytheme/addons.scss rename to vaadin/src/main/webapp/VAADIN/themes/mytheme/addons.scss diff --git a/libraries/src/main/webapp/VAADIN/themes/mytheme/favicon.ico b/vaadin/src/main/webapp/VAADIN/themes/mytheme/favicon.ico similarity index 100% rename from libraries/src/main/webapp/VAADIN/themes/mytheme/favicon.ico rename to vaadin/src/main/webapp/VAADIN/themes/mytheme/favicon.ico diff --git a/libraries/src/main/webapp/VAADIN/themes/mytheme/mytheme.scss b/vaadin/src/main/webapp/VAADIN/themes/mytheme/mytheme.scss similarity index 100% rename from libraries/src/main/webapp/VAADIN/themes/mytheme/mytheme.scss rename to vaadin/src/main/webapp/VAADIN/themes/mytheme/mytheme.scss diff --git a/libraries/src/main/webapp/VAADIN/themes/mytheme/styles.css b/vaadin/src/main/webapp/VAADIN/themes/mytheme/styles.css similarity index 100% rename from libraries/src/main/webapp/VAADIN/themes/mytheme/styles.css rename to vaadin/src/main/webapp/VAADIN/themes/mytheme/styles.css diff --git a/libraries/src/main/webapp/VAADIN/themes/mytheme/styles.scss b/vaadin/src/main/webapp/VAADIN/themes/mytheme/styles.scss similarity index 100% rename from libraries/src/main/webapp/VAADIN/themes/mytheme/styles.scss rename to vaadin/src/main/webapp/VAADIN/themes/mytheme/styles.scss From 9c4042eb88480cc4f9ca64179c264ce714fb173c Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Mon, 24 Jul 2017 08:49:36 +0200 Subject: [PATCH 66/89] Add missing "volatile"s (#2307) * Add volatile keywords * Update SafeCounterWithoutLock.java --- .../com/baeldung/concurrent/atomic/SafeCounterWithLock.java | 2 +- .../com/baeldung/concurrent/atomic/SafeCounterWithoutLock.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core-java/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithLock.java b/core-java/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithLock.java index b2502018bb..38633011bf 100644 --- a/core-java/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithLock.java +++ b/core-java/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithLock.java @@ -1,7 +1,7 @@ package com.baeldung.concurrent.atomic; public class SafeCounterWithLock { - int counter; + private volatile int counter; public int getValue() { return counter; diff --git a/core-java/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithoutLock.java b/core-java/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithoutLock.java index 55226f4f13..41e10789a6 100644 --- a/core-java/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithoutLock.java +++ b/core-java/src/main/java/com/baeldung/concurrent/atomic/SafeCounterWithoutLock.java @@ -3,7 +3,7 @@ package com.baeldung.concurrent.atomic; import java.util.concurrent.atomic.AtomicInteger; public class SafeCounterWithoutLock { - AtomicInteger counter = new AtomicInteger(0); + private final AtomicInteger counter = new AtomicInteger(0); public int getValue() { return counter.get(); From f58c41de4db4c0d82680689128332c40b2717262 Mon Sep 17 00:00:00 2001 From: Doha2012 Date: Mon, 24 Jul 2017 09:23:18 +0200 Subject: [PATCH 67/89] cucumber java8 (#2306) * minor logging fix * spring security sso * use basic auth * use form login * cleanup * cleanup * final cleanup * second client app for sso * spring boot bootstrap * add logic * cleanup * add simple controller * add thymeleaf and security * minor fix * minor fix * add more boot properties * fix live test * fix live test * minor fix * semaphores * fix configuration * kotlin collection * add more collection examples * minor upgrade * cucumber java8 --- testing/pom.xml | 6 +++++ .../shopping/ShoppingIntegrationTest.java | 12 ++++++++++ .../testing/shopping/ShoppingStepsDef.java | 22 +++++++++++++++++++ .../test/resources/features/shopping.feature | 11 ++++++++++ 4 files changed, 51 insertions(+) create mode 100644 testing/src/test/java/com/baeldung/testing/shopping/ShoppingIntegrationTest.java create mode 100644 testing/src/test/java/com/baeldung/testing/shopping/ShoppingStepsDef.java create mode 100644 testing/src/test/resources/features/shopping.feature diff --git a/testing/pom.xml b/testing/pom.xml index aa10392aa8..bfd47dbc4a 100644 --- a/testing/pom.xml +++ b/testing/pom.xml @@ -45,6 +45,12 @@ test + + info.cukes + cucumber-java8 + ${cucumber.version} + test + org.pitest diff --git a/testing/src/test/java/com/baeldung/testing/shopping/ShoppingIntegrationTest.java b/testing/src/test/java/com/baeldung/testing/shopping/ShoppingIntegrationTest.java new file mode 100644 index 0000000000..7bf8641ed6 --- /dev/null +++ b/testing/src/test/java/com/baeldung/testing/shopping/ShoppingIntegrationTest.java @@ -0,0 +1,12 @@ +package com.baeldung.testing.shopping; + +import org.junit.runner.RunWith; + +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; + +@RunWith(Cucumber.class) +@CucumberOptions(features = { "classpath:features/shopping.feature" }) +public class ShoppingIntegrationTest { + +} diff --git a/testing/src/test/java/com/baeldung/testing/shopping/ShoppingStepsDef.java b/testing/src/test/java/com/baeldung/testing/shopping/ShoppingStepsDef.java new file mode 100644 index 0000000000..2c4bf2eeae --- /dev/null +++ b/testing/src/test/java/com/baeldung/testing/shopping/ShoppingStepsDef.java @@ -0,0 +1,22 @@ +package com.baeldung.testing.shopping; + +import static org.junit.Assert.assertEquals; +import cucumber.api.java8.En; + +public class ShoppingStepsDef implements En { + + private int budget = 0; + + public ShoppingStepsDef() { + + Given("I have (\\d+) in my wallet", (Integer money) -> budget = money); + + When("I buy .* with (\\d+)", (Integer price) -> budget -= price); + + Then("I should have (\\d+) in my wallet", (Integer finalBudget) -> { + assertEquals(budget, finalBudget.intValue()); + }); + + } + +} \ No newline at end of file diff --git a/testing/src/test/resources/features/shopping.feature b/testing/src/test/resources/features/shopping.feature new file mode 100644 index 0000000000..d1ce43df75 --- /dev/null +++ b/testing/src/test/resources/features/shopping.feature @@ -0,0 +1,11 @@ +Feature: Shopping + + Scenario: Track my budget + Given I have 100 in my wallet + When I buy milk with 10 + Then I should have 90 in my wallet + + Scenario: Track my budget + Given I have 200 in my wallet + When I buy rice with 20 + Then I should have 180 in my wallet From 1be49ebc7ff3cd3874fbd9a801a5b52334a864f4 Mon Sep 17 00:00:00 2001 From: Abhinab Kanrar Date: Mon, 24 Jul 2017 12:58:10 +0530 Subject: [PATCH 68/89] introducing lambda (#2305) * moving jmh into libraries module * refactoring jmh * Update pom.xml * manual algorightm * with BM result * fix for space issue * Fixed indentation * change as per suggestion * vavr either * adding unit test and othe rutilities * adding concurrent module * concurrent package description * concurrent package description * Update EitherUnitTest.java * introducing lambda expression --- .../ScheduledExecutorServiceDemo.java | 30 ++++++------------- .../cyclicbarrier/CyclicBarrierExample.java | 8 ++--- .../concurrent/executor/ExecutorDemo.java | 7 ++--- .../executorservice/ExecutorServiceDemo.java | 9 ++---- .../concurrent/future/FutureDemo.java | 11 +++---- 5 files changed, 20 insertions(+), 45 deletions(-) diff --git a/core-java/src/main/java/com/baeldung/concurrent/Scheduledexecutorservice/ScheduledExecutorServiceDemo.java b/core-java/src/main/java/com/baeldung/concurrent/Scheduledexecutorservice/ScheduledExecutorServiceDemo.java index 171f308c16..b77019eea5 100644 --- a/core-java/src/main/java/com/baeldung/concurrent/Scheduledexecutorservice/ScheduledExecutorServiceDemo.java +++ b/core-java/src/main/java/com/baeldung/concurrent/Scheduledexecutorservice/ScheduledExecutorServiceDemo.java @@ -1,6 +1,5 @@ package com.baeldung.concurrent.Scheduledexecutorservice; -import java.util.concurrent.Callable; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.ScheduledExecutorService; @@ -12,32 +11,21 @@ public class ScheduledExecutorServiceDemo { public void execute() { ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor(); - ScheduledFuture scheduledFuture = executorService.schedule(new Runnable() { - @Override - public void run() { - // task details - } + ScheduledFuture scheduledFuture = executorService.schedule(() -> { + // Task }, 1, TimeUnit.SECONDS); - executorService.scheduleAtFixedRate(new Runnable() { - @Override - public void run() { - // task details - } + executorService.scheduleAtFixedRate(() -> { + // Task }, 1, 10, TimeUnit.SECONDS); - executorService.scheduleWithFixedDelay(new Runnable() { - @Override - public void run() { - // task details - } + executorService.scheduleWithFixedDelay(() -> { + // Task }, 1, 10, TimeUnit.SECONDS); - Future future = executorService.schedule(new Callable() { - @Override - public String call() throws Exception { - return "Hello World"; - } + Future future = executorService.schedule(() -> { + // Task + return "Hellow world"; }, 1, TimeUnit.SECONDS); executorService.shutdown(); diff --git a/core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierExample.java b/core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierExample.java index e6075c933e..85c0cf7680 100644 --- a/core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierExample.java +++ b/core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierExample.java @@ -5,11 +5,9 @@ import java.util.concurrent.CyclicBarrier; public class CyclicBarrierExample { public void start() { - CyclicBarrier cyclicBarrier = new CyclicBarrier(3, new Runnable() { - @Override - public void run() { - System.out.println("All previous tasks are completed"); - } + CyclicBarrier cyclicBarrier = new CyclicBarrier(3, () -> { + // Task + System.out.println("All previous tasks are completed"); }); Thread t1 = new Thread(new Task(cyclicBarrier), "T1"); diff --git a/core-java/src/main/java/com/baeldung/concurrent/executor/ExecutorDemo.java b/core-java/src/main/java/com/baeldung/concurrent/executor/ExecutorDemo.java index 9392134bfb..84998cb489 100644 --- a/core-java/src/main/java/com/baeldung/concurrent/executor/ExecutorDemo.java +++ b/core-java/src/main/java/com/baeldung/concurrent/executor/ExecutorDemo.java @@ -6,11 +6,8 @@ public class ExecutorDemo { public void execute() { Executor executor = new Invoker(); - executor.execute(new Runnable() { - @Override - public void run() { - // task to be performed - } + executor.execute(()->{ + // task to be performed }); } diff --git a/core-java/src/main/java/com/baeldung/concurrent/executorservice/ExecutorServiceDemo.java b/core-java/src/main/java/com/baeldung/concurrent/executorservice/ExecutorServiceDemo.java index 631ae140ab..ae2b279d9a 100644 --- a/core-java/src/main/java/com/baeldung/concurrent/executorservice/ExecutorServiceDemo.java +++ b/core-java/src/main/java/com/baeldung/concurrent/executorservice/ExecutorServiceDemo.java @@ -10,15 +10,10 @@ public class ExecutorServiceDemo { public void execute() { - executor.execute(new Runnable() { - @Override - public void run() { - // task details - } + executor.submit(() -> { + new Task(); }); - executor.submit(new Task()); - executor.shutdown(); executor.shutdownNow(); try { diff --git a/core-java/src/main/java/com/baeldung/concurrent/future/FutureDemo.java b/core-java/src/main/java/com/baeldung/concurrent/future/FutureDemo.java index 89ce1a0a41..7cb611be0f 100644 --- a/core-java/src/main/java/com/baeldung/concurrent/future/FutureDemo.java +++ b/core-java/src/main/java/com/baeldung/concurrent/future/FutureDemo.java @@ -1,6 +1,5 @@ package com.baeldung.concurrent.future; -import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -16,12 +15,10 @@ public class FutureDemo { ExecutorService executorService = Executors.newFixedThreadPool(10); - Future future = executorService.submit(new Callable() { - @Override - public String call() throws Exception { - Thread.sleep(10000l); - return "Hello World"; - } + Future future = executorService.submit(() -> { + // Task + Thread.sleep(10000l); + return "Hellow world"; }); future.cancel(false); From 29b0da9960184906702a49ce5ee2aadde4b3c681 Mon Sep 17 00:00:00 2001 From: mokhan Date: Mon, 24 Jul 2017 23:03:24 +0530 Subject: [PATCH 69/89] Web Logging code included in exisitng module namely "spring-rest" --- spring-rest/pom.xml | 558 +++++++++--------- .../com/baeldung/web/log/app/Application.java | 18 + .../log/app/TaxiFareRequestInterceptor.java | 44 ++ .../config/RequestLoggingFilterConfig.java | 20 + .../web/log/config/TaxiFareMVCConfig.java | 20 + .../log/controller/TaxiFareController.java | 43 ++ .../com/baeldung/web/log/data/RateCard.java | 28 + .../com/baeldung/web/log/data/TaxiRide.java | 32 + .../service/TaxiFareCalculatorService.java | 20 + .../web/log/util/RequestLoggingUtil.java | 38 ++ spring-rest/src/main/resources/logback.xml | 4 + .../web/log/test/TestTaxiFareController.java | 33 ++ 12 files changed, 583 insertions(+), 275 deletions(-) create mode 100644 spring-rest/src/main/java/com/baeldung/web/log/app/Application.java create mode 100644 spring-rest/src/main/java/com/baeldung/web/log/app/TaxiFareRequestInterceptor.java create mode 100644 spring-rest/src/main/java/com/baeldung/web/log/config/RequestLoggingFilterConfig.java create mode 100644 spring-rest/src/main/java/com/baeldung/web/log/config/TaxiFareMVCConfig.java create mode 100644 spring-rest/src/main/java/com/baeldung/web/log/controller/TaxiFareController.java create mode 100644 spring-rest/src/main/java/com/baeldung/web/log/data/RateCard.java create mode 100644 spring-rest/src/main/java/com/baeldung/web/log/data/TaxiRide.java create mode 100644 spring-rest/src/main/java/com/baeldung/web/log/service/TaxiFareCalculatorService.java create mode 100644 spring-rest/src/main/java/com/baeldung/web/log/util/RequestLoggingUtil.java create mode 100644 spring-rest/src/test/java/com/baeldung/web/log/test/TestTaxiFareController.java diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index c12028149d..6065d7e529 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -1,321 +1,329 @@ - 4.0.0 - com.baeldung - spring-rest - 0.1-SNAPSHOT - spring-rest - war + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + com.baeldung + spring-rest + 0.1-SNAPSHOT + spring-rest + war - - parent-boot-4 - com.baeldung - 0.0.1-SNAPSHOT - ../parent-boot-4 - + + parent-boot-4 + com.baeldung + 0.0.1-SNAPSHOT + ../parent-boot-4 + - + - + - - org.springframework.boot - spring-boot-starter-thymeleaf - - - org.springframework.boot - spring-boot-starter-actuator - - - org.springframework.boot - spring-boot-devtools - - - org.springframework.boot - spring-boot-test - + + org.springframework.boot + spring-boot-starter-thymeleaf + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-devtools + + + org.springframework.boot + spring-boot-test + - + - - org.springframework - spring-web - - - commons-logging - commons-logging - - - - - org.springframework - spring-webmvc - - - org.springframework - spring-oxm - + + org.springframework + spring-web + + + commons-logging + commons-logging + + + + + org.springframework + spring-webmvc + + + org.springframework + spring-oxm + - - commons-fileupload - commons-fileupload - ${commons-fileupload.version} - - + + commons-fileupload + commons-fileupload + ${commons-fileupload.version} + + - - javax.servlet - javax.servlet-api - provided - + + javax.servlet + javax.servlet-api + provided + - - javax.servlet - jstl - runtime - + + javax.servlet + jstl + runtime + - + - - com.fasterxml.jackson.core - jackson-databind - + + com.fasterxml.jackson.core + jackson-databind + - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + - - com.thoughtworks.xstream - xstream - ${xstream.version} - + + com.thoughtworks.xstream + xstream + ${xstream.version} + - + - - com.google.guava - guava - ${guava.version} - + + com.google.guava + guava + ${guava.version} + - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + - + - - com.squareup.okhttp3 - okhttp - ${com.squareup.okhttp3.version} - + + com.squareup.okhttp3 + okhttp + ${com.squareup.okhttp3.version} + - + - - org.hamcrest - hamcrest-core - test - - - org.hamcrest - hamcrest-library - test - + + org.hamcrest + hamcrest-core + test + + + org.hamcrest + hamcrest-library + test + - - org.mockito - mockito-core - test - + + org.mockito + mockito-core + test + - - org.springframework - spring-test - + + org.springframework + spring-test + - - - com.google.protobuf - protobuf-java - ${protobuf-java.version} - - - com.googlecode.protobuf-java-format - protobuf-java-format - ${protobuf-java-format.version} - + + + com.google.protobuf + protobuf-java + ${protobuf-java.version} + + + com.googlecode.protobuf-java-format + protobuf-java-format + ${protobuf-java-format.version} + - - com.esotericsoftware - kryo - ${kryo.version} - + + com.esotericsoftware + kryo + ${kryo.version} + - - com.jayway.jsonpath - json-path - + + com.jayway.jsonpath + json-path + - - - spring-rest - - - src/main/resources - true - - + + + commons-io + commons-io + 2.4 + - - - org.springframework.boot - spring-boot-maven-plugin - - true - - - - org.apache.maven.plugins - maven-war-plugin - + - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - tomcat8x - embedded - - - - - - - 8082 - - - - + + spring-rest + + + src/main/resources + true + + - + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + org.apache.maven.plugins + maven-war-plugin + - + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + tomcat8x + embedded + + + + + + + 8082 + + + + - + - - integration - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration-test - - test - - - - none - - - **/*IntegrationTest.java - - - - - + - - - + - - live - - - - org.codehaus.cargo - cargo-maven2-plugin - - - start-server - pre-integration-test - - start - - - - stop-server - post-integration-test - - stop - - - - + + integration + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + none + + + **/*IntegrationTest.java + + + + + - - org.apache.maven.plugins - maven-surefire-plugin - - - integration-test - - test - - - - none - - - **/*LiveTest.java - - - cargo - - - - - + + + - - - + + live + + + + org.codehaus.cargo + cargo-maven2-plugin + + + start-server + pre-integration-test + + start + + + + stop-server + post-integration-test + + stop + + + + - + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + none + + + **/*LiveTest.java + + + cargo + + + + + - - 1.3.2 - 4.0.0 - 1.4 - 3.1.0 - 3.5 - 1.4.9 + + + - - 20.0 + - - 1.6.0 - 3.0.4 + + 1.3.2 + 4.0.0 + 1.4 + 3.1.0 + 3.5 + 1.4.9 - - 3.4.1 + + 20.0 - 2.2.0 - + + 1.6.0 + 3.0.4 + + + 3.4.1 + + 2.2.0 + diff --git a/spring-rest/src/main/java/com/baeldung/web/log/app/Application.java b/spring-rest/src/main/java/com/baeldung/web/log/app/Application.java new file mode 100644 index 0000000000..9bdbbd0d9f --- /dev/null +++ b/spring-rest/src/main/java/com/baeldung/web/log/app/Application.java @@ -0,0 +1,18 @@ +package com.baeldung.web.log.app; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.support.SpringBootServletInitializer; +import org.springframework.context.annotation.ComponentScan; + +@EnableAutoConfiguration +@ComponentScan("com.baeldung.web.log") +@SpringBootApplication +public class Application extends SpringBootServletInitializer { + + public static void main(final String[] args) { + SpringApplication.run(Application.class, args); + } + +} \ No newline at end of file diff --git a/spring-rest/src/main/java/com/baeldung/web/log/app/TaxiFareRequestInterceptor.java b/spring-rest/src/main/java/com/baeldung/web/log/app/TaxiFareRequestInterceptor.java new file mode 100644 index 0000000000..831d236edd --- /dev/null +++ b/spring-rest/src/main/java/com/baeldung/web/log/app/TaxiFareRequestInterceptor.java @@ -0,0 +1,44 @@ +package com.baeldung.web.log.app; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; +import org.springframework.web.util.ContentCachingRequestWrapper; + +import com.baeldung.web.log.util.RequestLoggingUtil; + +@Component +public class TaxiFareRequestInterceptor extends HandlerInterceptorAdapter { + + Logger LOGGER = LoggerFactory.getLogger(TaxiFareRequestInterceptor.class); + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + String postData = null; + HttpServletRequest requestCacheWrapperObject = null; + try { + // Uncomment to produce the stream closed issue + // postData = RequestLoggingUtil.getStringFromInputStream(request.getInputStream()); + + // To overcome request stream closed issue + requestCacheWrapperObject = new ContentCachingRequestWrapper(request); + requestCacheWrapperObject.getParameterMap(); + } catch (Exception exception) { + exception.printStackTrace(); + } finally { + postData = RequestLoggingUtil.readPayload(requestCacheWrapperObject); + LOGGER.info("REQUEST DATA: " + postData); + } + return true; + } + + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { + LOGGER.info("RESPONSE: " + response.getStatus()); + } + +} diff --git a/spring-rest/src/main/java/com/baeldung/web/log/config/RequestLoggingFilterConfig.java b/spring-rest/src/main/java/com/baeldung/web/log/config/RequestLoggingFilterConfig.java new file mode 100644 index 0000000000..bc9ad1cf84 --- /dev/null +++ b/spring-rest/src/main/java/com/baeldung/web/log/config/RequestLoggingFilterConfig.java @@ -0,0 +1,20 @@ +package com.baeldung.web.log.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.filter.CommonsRequestLoggingFilter; + +@Configuration +public class RequestLoggingFilterConfig { + + @Bean + public CommonsRequestLoggingFilter logFilter() { + CommonsRequestLoggingFilter filter = new CommonsRequestLoggingFilter(); + filter.setIncludeQueryString(true); + filter.setIncludePayload(true); + filter.setMaxPayloadLength(10000); + filter.setIncludeHeaders(false); + filter.setAfterMessagePrefix("REQUEST DATA : "); + return filter; + } +} diff --git a/spring-rest/src/main/java/com/baeldung/web/log/config/TaxiFareMVCConfig.java b/spring-rest/src/main/java/com/baeldung/web/log/config/TaxiFareMVCConfig.java new file mode 100644 index 0000000000..fa26706ff0 --- /dev/null +++ b/spring-rest/src/main/java/com/baeldung/web/log/config/TaxiFareMVCConfig.java @@ -0,0 +1,20 @@ +package com.baeldung.web.log.config; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +import com.baeldung.web.log.app.TaxiFareRequestInterceptor; + +@Configuration +public class TaxiFareMVCConfig extends WebMvcConfigurerAdapter { + + @Autowired + private TaxiFareRequestInterceptor taxiFareRequestInterceptor; + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(taxiFareRequestInterceptor).addPathPatterns("/**/taxifare/**/"); + } +} diff --git a/spring-rest/src/main/java/com/baeldung/web/log/controller/TaxiFareController.java b/spring-rest/src/main/java/com/baeldung/web/log/controller/TaxiFareController.java new file mode 100644 index 0000000000..28bf07e8a6 --- /dev/null +++ b/spring-rest/src/main/java/com/baeldung/web/log/controller/TaxiFareController.java @@ -0,0 +1,43 @@ +package com.baeldung.web.log.controller; + +import javax.validation.Valid; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +import com.baeldung.web.log.data.RateCard; +import com.baeldung.web.log.data.TaxiRide; +import com.baeldung.web.log.service.TaxiFareCalculatorService; + +@Controller +public class TaxiFareController { + + @Autowired + private TaxiFareCalculatorService taxiFareCalculatorService; + + private static final Logger LOGGER = LoggerFactory.getLogger(TaxiFareController.class); + + @RequestMapping(method = RequestMethod.GET, value = "/taxifare/get/") + @ResponseBody + public RateCard getTaxiFare() { + LOGGER.debug("getTaxiFare() - START"); + return new RateCard(); + } + + @RequestMapping(method = RequestMethod.POST, value = "/taxifare/calculate/") + @ResponseBody + public String calculateTaxiFare(@RequestBody @Valid TaxiRide taxiRide) { + LOGGER.debug("calculateTaxiFare() - START"); + String totalFare = taxiFareCalculatorService.calculateFare(taxiRide); + LOGGER.debug("calculateTaxiFare() - Total Fare : {}",totalFare); + LOGGER.debug("calculateTaxiFare() - END"); + return totalFare; + } + +} diff --git a/spring-rest/src/main/java/com/baeldung/web/log/data/RateCard.java b/spring-rest/src/main/java/com/baeldung/web/log/data/RateCard.java new file mode 100644 index 0000000000..35ae38fd11 --- /dev/null +++ b/spring-rest/src/main/java/com/baeldung/web/log/data/RateCard.java @@ -0,0 +1,28 @@ +package com.baeldung.web.log.data; + +public class RateCard { + + private String nightSurcharge; + private String ratePerMile; + + public RateCard(){ + nightSurcharge="Extra $ 100"; + ratePerMile="$ 10 Per Mile"; + } + + + public String getNightSurcharge() { + return nightSurcharge; + } + public void setNightSurcharge(String nightSurcharge) { + this.nightSurcharge = nightSurcharge; + } + public String getRatePerMile() { + return ratePerMile; + } + public void setRatePerMile(String ratePerMile) { + this.ratePerMile = ratePerMile; + } + + +} diff --git a/spring-rest/src/main/java/com/baeldung/web/log/data/TaxiRide.java b/spring-rest/src/main/java/com/baeldung/web/log/data/TaxiRide.java new file mode 100644 index 0000000000..0877cdced4 --- /dev/null +++ b/spring-rest/src/main/java/com/baeldung/web/log/data/TaxiRide.java @@ -0,0 +1,32 @@ +package com.baeldung.web.log.data; + +public class TaxiRide { + + private Boolean isNightSurcharge; + private Long distanceInMile; + + public TaxiRide(){} + + public TaxiRide(Boolean isNightSurcharge, Long distanceInMile){ + this.isNightSurcharge = isNightSurcharge; + this.distanceInMile = distanceInMile; + } + + + public Boolean getIsNightSurcharge() { + return isNightSurcharge; + } + + public void setIsNightSurcharge(Boolean isNightSurcharge) { + this.isNightSurcharge = isNightSurcharge; + } + + public Long getDistanceInMile() { + return distanceInMile; + } + + public void setDistanceInMile(Long distanceInMile) { + this.distanceInMile = distanceInMile; + } + +} diff --git a/spring-rest/src/main/java/com/baeldung/web/log/service/TaxiFareCalculatorService.java b/spring-rest/src/main/java/com/baeldung/web/log/service/TaxiFareCalculatorService.java new file mode 100644 index 0000000000..ec9c81187a --- /dev/null +++ b/spring-rest/src/main/java/com/baeldung/web/log/service/TaxiFareCalculatorService.java @@ -0,0 +1,20 @@ +package com.baeldung.web.log.service; + +import org.springframework.stereotype.Service; + +import com.baeldung.web.log.data.TaxiRide; + +@Service +public class TaxiFareCalculatorService { + + public String calculateFare(TaxiRide taxiRide) { + Long fare = 0l; + if (taxiRide.getIsNightSurcharge()) { + fare = taxiRide.getDistanceInMile() * 10 + 100; + } else { + fare = taxiRide.getDistanceInMile() * 10; + } + return String.valueOf(fare); + } + +} diff --git a/spring-rest/src/main/java/com/baeldung/web/log/util/RequestLoggingUtil.java b/spring-rest/src/main/java/com/baeldung/web/log/util/RequestLoggingUtil.java new file mode 100644 index 0000000000..c13d35b55c --- /dev/null +++ b/spring-rest/src/main/java/com/baeldung/web/log/util/RequestLoggingUtil.java @@ -0,0 +1,38 @@ +package com.baeldung.web.log.util; + +import java.io.IOException; +import java.io.InputStream; +import java.io.StringWriter; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.commons.io.IOUtils; +import org.springframework.web.util.ContentCachingRequestWrapper; +import org.springframework.web.util.WebUtils; + +public class RequestLoggingUtil { + + public static String getStringFromInputStream(InputStream is) { + StringWriter writer = new StringWriter(); + String encoding = "UTF-8"; + try { + IOUtils.copy(is, writer, encoding); + } catch (IOException e) { + e.printStackTrace(); + } + return writer.toString(); + } + + public static String readPayload(final HttpServletRequest request) throws IOException { + String payloadData = null; + ContentCachingRequestWrapper contentCachingRequestWrapper = WebUtils.getNativeRequest(request, ContentCachingRequestWrapper.class); + if (null != contentCachingRequestWrapper) { + byte[] buf = contentCachingRequestWrapper.getContentAsByteArray(); + if (buf.length > 0) { + payloadData = new String(buf, 0, buf.length, contentCachingRequestWrapper.getCharacterEncoding()); + } + } + return payloadData; + } + +} diff --git a/spring-rest/src/main/resources/logback.xml b/spring-rest/src/main/resources/logback.xml index ec0dc2469a..3496a4a03c 100644 --- a/spring-rest/src/main/resources/logback.xml +++ b/spring-rest/src/main/resources/logback.xml @@ -6,6 +6,10 @@ + + + + diff --git a/spring-rest/src/test/java/com/baeldung/web/log/test/TestTaxiFareController.java b/spring-rest/src/test/java/com/baeldung/web/log/test/TestTaxiFareController.java new file mode 100644 index 0000000000..935275983f --- /dev/null +++ b/spring-rest/src/test/java/com/baeldung/web/log/test/TestTaxiFareController.java @@ -0,0 +1,33 @@ +package com.baeldung.web.log.test; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.Test; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; + +import com.baeldung.web.log.data.TaxiRide; + +public class TestTaxiFareController { + + private static final String URL = "http://localhost:" + 8082 + "/spring-rest/taxifare/"; + + @Test + public void givenRequest_thenfetchTaxiFareRateCard() { + TestRestTemplate testRestTemplate = new TestRestTemplate(); + ResponseEntity response = testRestTemplate.getForEntity(URL + "get/", String.class); + assertThat(response.getStatusCode(), equalTo(HttpStatus.OK)); + } + + @Test + public void givenTaxiRide_thenGetCalculatedFare() { + TestRestTemplate testRestTemplate = new TestRestTemplate(); + TaxiRide taxiRide = new TaxiRide(true,10l); + String fare = testRestTemplate.postForObject(URL + "calculate/", taxiRide,String.class); + assertThat(fare, equalTo("200")); + } + + +} From 553c26c1a2a96b80012cfa8e9cd64a6e35af8762 Mon Sep 17 00:00:00 2001 From: mokhan Date: Mon, 24 Jul 2017 23:08:43 +0530 Subject: [PATCH 70/89] deleted the new module --- pom.xml | 2 +- spring-rest-logging/pom.xml | 73 ------------------- .../baeldung/rest/log/app/Application.java | 18 ----- .../log/app/TaxiFareRequestInterceptor.java | 44 ----------- .../config/RequestLoggingFilterConfig.java | 20 ----- .../rest/log/config/TaxiFareMVCConfig.java | 20 ----- .../log/controller/TaxiFareController.java | 43 ----------- .../com/baeldung/rest/log/data/RateCard.java | 28 ------- .../com/baeldung/rest/log/data/TaxiRide.java | 32 -------- .../service/TaxiFareCalculatorService.java | 20 ----- .../rest/log/util/RequestLoggingUtil.java | 38 ---------- .../src/main/resources/application.properties | 2 - .../src/main/resources/logback.xml | 21 ------ .../controller/TestTaxiFareController.java | 33 --------- 14 files changed, 1 insertion(+), 393 deletions(-) delete mode 100644 spring-rest-logging/pom.xml delete mode 100644 spring-rest-logging/src/main/java/com/baeldung/rest/log/app/Application.java delete mode 100644 spring-rest-logging/src/main/java/com/baeldung/rest/log/app/TaxiFareRequestInterceptor.java delete mode 100644 spring-rest-logging/src/main/java/com/baeldung/rest/log/config/RequestLoggingFilterConfig.java delete mode 100644 spring-rest-logging/src/main/java/com/baeldung/rest/log/config/TaxiFareMVCConfig.java delete mode 100644 spring-rest-logging/src/main/java/com/baeldung/rest/log/controller/TaxiFareController.java delete mode 100644 spring-rest-logging/src/main/java/com/baeldung/rest/log/data/RateCard.java delete mode 100644 spring-rest-logging/src/main/java/com/baeldung/rest/log/data/TaxiRide.java delete mode 100644 spring-rest-logging/src/main/java/com/baeldung/rest/log/service/TaxiFareCalculatorService.java delete mode 100644 spring-rest-logging/src/main/java/com/baeldung/rest/log/util/RequestLoggingUtil.java delete mode 100644 spring-rest-logging/src/main/resources/application.properties delete mode 100644 spring-rest-logging/src/main/resources/logback.xml delete mode 100644 spring-rest-logging/src/test/java/com/baeldung/rest/log/controller/TestTaxiFareController.java diff --git a/pom.xml b/pom.xml index 9bfadc01a5..7e87d4fd8c 100644 --- a/pom.xml +++ b/pom.xml @@ -208,7 +208,7 @@ spring-zuul spring-reactor spring-vertx - spring-rest-logging + testing testng diff --git a/spring-rest-logging/pom.xml b/spring-rest-logging/pom.xml deleted file mode 100644 index 799a746b63..0000000000 --- a/spring-rest-logging/pom.xml +++ /dev/null @@ -1,73 +0,0 @@ - - 4.0.0 - com.baeldung - spring-rest-logging - 0.1-SNAPSHOT - spring-rest-logging - war - - - org.springframework.boot - spring-boot-starter-parent - 1.4.3.RELEASE - - - - - - org.springframework.boot - spring-boot-starter-thymeleaf - - - - - org.springframework.boot - spring-boot-test - - - - - org.springframework - spring-web - - - commons-logging - commons-logging - - - - - org.springframework - spring-webmvc - - - - - - javax.servlet - javax.servlet-api - provided - - - - junit - junit - test - - - - org.springframework - spring-test - - - - - commons-io - commons-io - 2.4 - - - - - diff --git a/spring-rest-logging/src/main/java/com/baeldung/rest/log/app/Application.java b/spring-rest-logging/src/main/java/com/baeldung/rest/log/app/Application.java deleted file mode 100644 index 9eb79ee1b1..0000000000 --- a/spring-rest-logging/src/main/java/com/baeldung/rest/log/app/Application.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.baeldung.rest.log.app; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.web.support.SpringBootServletInitializer; -import org.springframework.context.annotation.ComponentScan; - -@EnableAutoConfiguration -@ComponentScan("com.baeldung") -@SpringBootApplication -public class Application extends SpringBootServletInitializer { - - public static void main(final String[] args) { - SpringApplication.run(Application.class, args); - } - -} \ No newline at end of file diff --git a/spring-rest-logging/src/main/java/com/baeldung/rest/log/app/TaxiFareRequestInterceptor.java b/spring-rest-logging/src/main/java/com/baeldung/rest/log/app/TaxiFareRequestInterceptor.java deleted file mode 100644 index 4c187772cc..0000000000 --- a/spring-rest-logging/src/main/java/com/baeldung/rest/log/app/TaxiFareRequestInterceptor.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.baeldung.rest.log.app; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; -import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; -import org.springframework.web.util.ContentCachingRequestWrapper; - -import com.baeldung.rest.log.util.RequestLoggingUtil; - -@Component -public class TaxiFareRequestInterceptor extends HandlerInterceptorAdapter { - - Logger LOGGER = LoggerFactory.getLogger(TaxiFareRequestInterceptor.class); - - @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { - String postData = null; - HttpServletRequest requestCacheWrapperObject = null; - try { - // Uncomment to produce the stream closed issue - // postData = RequestLoggingUtil.getStringFromInputStream(request.getInputStream()); - - // To overcome request stream closed issue - requestCacheWrapperObject = new ContentCachingRequestWrapper(request); - requestCacheWrapperObject.getParameterMap(); - } catch (Exception exception) { - exception.printStackTrace(); - } finally { - postData = RequestLoggingUtil.readPayload(requestCacheWrapperObject); - LOGGER.info("REQUEST DATA: " + postData); - } - return true; - } - - @Override - public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { - LOGGER.info("RESPONSE: " + response.getStatus()); - } - -} diff --git a/spring-rest-logging/src/main/java/com/baeldung/rest/log/config/RequestLoggingFilterConfig.java b/spring-rest-logging/src/main/java/com/baeldung/rest/log/config/RequestLoggingFilterConfig.java deleted file mode 100644 index 7afb34dd11..0000000000 --- a/spring-rest-logging/src/main/java/com/baeldung/rest/log/config/RequestLoggingFilterConfig.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.baeldung.rest.log.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.filter.CommonsRequestLoggingFilter; - -@Configuration -public class RequestLoggingFilterConfig { - - @Bean - public CommonsRequestLoggingFilter logFilter() { - CommonsRequestLoggingFilter filter = new CommonsRequestLoggingFilter(); - filter.setIncludeQueryString(true); - filter.setIncludePayload(true); - filter.setMaxPayloadLength(10000); - filter.setIncludeHeaders(false); - filter.setAfterMessagePrefix("REQUEST DATA : "); - return filter; - } -} diff --git a/spring-rest-logging/src/main/java/com/baeldung/rest/log/config/TaxiFareMVCConfig.java b/spring-rest-logging/src/main/java/com/baeldung/rest/log/config/TaxiFareMVCConfig.java deleted file mode 100644 index 71d0fd379f..0000000000 --- a/spring-rest-logging/src/main/java/com/baeldung/rest/log/config/TaxiFareMVCConfig.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.baeldung.rest.log.config; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.InterceptorRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; - -import com.baeldung.rest.log.app.TaxiFareRequestInterceptor; - -@Configuration -public class TaxiFareMVCConfig extends WebMvcConfigurerAdapter { - - @Autowired - private TaxiFareRequestInterceptor taxiFareRequestInterceptor; - - @Override - public void addInterceptors(InterceptorRegistry registry) { - registry.addInterceptor(taxiFareRequestInterceptor).addPathPatterns("/**/taxifare/**/"); - } -} diff --git a/spring-rest-logging/src/main/java/com/baeldung/rest/log/controller/TaxiFareController.java b/spring-rest-logging/src/main/java/com/baeldung/rest/log/controller/TaxiFareController.java deleted file mode 100644 index 1ef9ece0b2..0000000000 --- a/spring-rest-logging/src/main/java/com/baeldung/rest/log/controller/TaxiFareController.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.baeldung.rest.log.controller; - -import javax.validation.Valid; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -import com.baeldung.rest.log.data.RateCard; -import com.baeldung.rest.log.data.TaxiRide; -import com.baeldung.rest.log.service.TaxiFareCalculatorService; - -@Controller -public class TaxiFareController { - - @Autowired - private TaxiFareCalculatorService taxiFareCalculatorService; - - private static final Logger LOGGER = LoggerFactory.getLogger(TaxiFareController.class); - - @RequestMapping(method = RequestMethod.GET, value = "/taxifare/get/") - @ResponseBody - public RateCard getTaxiFare() { - LOGGER.debug("getTaxiFare() - START"); - return new RateCard(); - } - - @RequestMapping(method = RequestMethod.POST, value = "/taxifare/calculate/") - @ResponseBody - public String calculateTaxiFare(@RequestBody @Valid TaxiRide taxiRide) { - LOGGER.debug("calculateTaxiFare() - START"); - String totalFare = taxiFareCalculatorService.calculateFare(taxiRide); - LOGGER.debug("calculateTaxiFare() - Total Fare : {}",totalFare); - LOGGER.debug("calculateTaxiFare() - END"); - return totalFare; - } - -} diff --git a/spring-rest-logging/src/main/java/com/baeldung/rest/log/data/RateCard.java b/spring-rest-logging/src/main/java/com/baeldung/rest/log/data/RateCard.java deleted file mode 100644 index 6e0c6d0e38..0000000000 --- a/spring-rest-logging/src/main/java/com/baeldung/rest/log/data/RateCard.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baeldung.rest.log.data; - -public class RateCard { - - private String nightSurcharge; - private String ratePerMile; - - public RateCard(){ - nightSurcharge="Extra $ 100"; - ratePerMile="$ 10 Per Mile"; - } - - - public String getNightSurcharge() { - return nightSurcharge; - } - public void setNightSurcharge(String nightSurcharge) { - this.nightSurcharge = nightSurcharge; - } - public String getRatePerMile() { - return ratePerMile; - } - public void setRatePerMile(String ratePerMile) { - this.ratePerMile = ratePerMile; - } - - -} diff --git a/spring-rest-logging/src/main/java/com/baeldung/rest/log/data/TaxiRide.java b/spring-rest-logging/src/main/java/com/baeldung/rest/log/data/TaxiRide.java deleted file mode 100644 index bcf102e49d..0000000000 --- a/spring-rest-logging/src/main/java/com/baeldung/rest/log/data/TaxiRide.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baeldung.rest.log.data; - -public class TaxiRide { - - private Boolean isNightSurcharge; - private Long distanceInMile; - - public TaxiRide(){} - - public TaxiRide(Boolean isNightSurcharge, Long distanceInMile){ - this.isNightSurcharge = isNightSurcharge; - this.distanceInMile = distanceInMile; - } - - - public Boolean getIsNightSurcharge() { - return isNightSurcharge; - } - - public void setIsNightSurcharge(Boolean isNightSurcharge) { - this.isNightSurcharge = isNightSurcharge; - } - - public Long getDistanceInMile() { - return distanceInMile; - } - - public void setDistanceInMile(Long distanceInMile) { - this.distanceInMile = distanceInMile; - } - -} diff --git a/spring-rest-logging/src/main/java/com/baeldung/rest/log/service/TaxiFareCalculatorService.java b/spring-rest-logging/src/main/java/com/baeldung/rest/log/service/TaxiFareCalculatorService.java deleted file mode 100644 index 31dfd7ac50..0000000000 --- a/spring-rest-logging/src/main/java/com/baeldung/rest/log/service/TaxiFareCalculatorService.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.baeldung.rest.log.service; - -import org.springframework.stereotype.Service; - -import com.baeldung.rest.log.data.TaxiRide; - -@Service -public class TaxiFareCalculatorService { - - public String calculateFare(TaxiRide taxiRide) { - Long fare = 0l; - if (taxiRide.getIsNightSurcharge()) { - fare = taxiRide.getDistanceInMile() * 10 + 100; - } else { - fare = taxiRide.getDistanceInMile() * 10; - } - return String.valueOf(fare); - } - -} diff --git a/spring-rest-logging/src/main/java/com/baeldung/rest/log/util/RequestLoggingUtil.java b/spring-rest-logging/src/main/java/com/baeldung/rest/log/util/RequestLoggingUtil.java deleted file mode 100644 index 3c9eebf34e..0000000000 --- a/spring-rest-logging/src/main/java/com/baeldung/rest/log/util/RequestLoggingUtil.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.baeldung.rest.log.util; - -import java.io.IOException; -import java.io.InputStream; -import java.io.StringWriter; - -import javax.servlet.http.HttpServletRequest; - -import org.apache.commons.io.IOUtils; -import org.springframework.web.util.ContentCachingRequestWrapper; -import org.springframework.web.util.WebUtils; - -public class RequestLoggingUtil { - - public static String getStringFromInputStream(InputStream is) { - StringWriter writer = new StringWriter(); - String encoding = "UTF-8"; - try { - IOUtils.copy(is, writer, encoding); - } catch (IOException e) { - e.printStackTrace(); - } - return writer.toString(); - } - - public static String readPayload(final HttpServletRequest request) throws IOException { - String payloadData = null; - ContentCachingRequestWrapper contentCachingRequestWrapper = WebUtils.getNativeRequest(request, ContentCachingRequestWrapper.class); - if (null != contentCachingRequestWrapper) { - byte[] buf = contentCachingRequestWrapper.getContentAsByteArray(); - if (buf.length > 0) { - payloadData = new String(buf, 0, buf.length, contentCachingRequestWrapper.getCharacterEncoding()); - } - } - return payloadData; - } - -} diff --git a/spring-rest-logging/src/main/resources/application.properties b/spring-rest-logging/src/main/resources/application.properties deleted file mode 100644 index ff8a818e66..0000000000 --- a/spring-rest-logging/src/main/resources/application.properties +++ /dev/null @@ -1,2 +0,0 @@ -server.port= 9090 -server.context-path=/rest-log diff --git a/spring-rest-logging/src/main/resources/logback.xml b/spring-rest-logging/src/main/resources/logback.xml deleted file mode 100644 index 08117752c7..0000000000 --- a/spring-rest-logging/src/main/resources/logback.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - web - %date [%thread] %-5level %logger{36} - %message%n - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-rest-logging/src/test/java/com/baeldung/rest/log/controller/TestTaxiFareController.java b/spring-rest-logging/src/test/java/com/baeldung/rest/log/controller/TestTaxiFareController.java deleted file mode 100644 index ed3cdda7ad..0000000000 --- a/spring-rest-logging/src/test/java/com/baeldung/rest/log/controller/TestTaxiFareController.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.baeldung.rest.log.controller; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.MatcherAssert.assertThat; - -import org.junit.Test; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; - -import com.baeldung.rest.log.data.TaxiRide; - -public class TestTaxiFareController { - - private static final String URL = "http://localhost:" + 9090 + "/rest-log/taxifare/"; - - @Test - public void givenRequest_thenfetchTaxiFareRateCard() { - TestRestTemplate testRestTemplate = new TestRestTemplate(); - ResponseEntity response = testRestTemplate.getForEntity(URL + "get/", String.class); - assertThat(response.getStatusCode(), equalTo(HttpStatus.OK)); - } - - @Test - public void givenTaxiRide_thenGetCalculatedFare() { - TestRestTemplate testRestTemplate = new TestRestTemplate(); - TaxiRide taxiRide = new TaxiRide(true,10l); - String fare = testRestTemplate.postForObject(URL + "calculate/", taxiRide,String.class); - assertThat(fare, equalTo("200")); - } - - -} From 34dc899c9b2df10ac03b3cc6e29f50af5cf69799 Mon Sep 17 00:00:00 2001 From: Alejandro Gervasio Date: Mon, 24 Jul 2017 18:15:09 -0300 Subject: [PATCH 71/89] Custom Efficient hashCode() Implementations - Alejandro Gervasio - alejandro.gervasio@gmail.com (#2301) * Initial Commit * Updated pom.xml * Updated User class * Updated pom.xml * Updated Application class --- core-java/hashcode/pom.xml | 39 +++++++++++++++++++ .../com/baeldung/application/Application.java | 23 +++++++++++ .../main/java/com/baeldung/entities/User.java | 38 ++++++++++++++++++ .../baeldung/application/ApplicationTest.java | 30 ++++++++++++++ .../java/com/baeldung/entities/UserTest.java | 34 ++++++++++++++++ 5 files changed, 164 insertions(+) create mode 100644 core-java/hashcode/pom.xml create mode 100644 core-java/hashcode/src/main/java/com/baeldung/application/Application.java create mode 100644 core-java/hashcode/src/main/java/com/baeldung/entities/User.java create mode 100644 core-java/hashcode/src/test/java/com/baeldung/application/ApplicationTest.java create mode 100644 core-java/hashcode/src/test/java/com/baeldung/entities/UserTest.java diff --git a/core-java/hashcode/pom.xml b/core-java/hashcode/pom.xml new file mode 100644 index 0000000000..393aa69153 --- /dev/null +++ b/core-java/hashcode/pom.xml @@ -0,0 +1,39 @@ + + + 4.0.0 + com.baeldung.hashcode + hashcode + 1.0 + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + + + junit + junit + 4.12 + test + + + org.slf4j + slf4j-api + 1.7.25 + + + org.slf4j + slf4j-simple + 1.7.25 + + + \ No newline at end of file diff --git a/core-java/hashcode/src/main/java/com/baeldung/application/Application.java b/core-java/hashcode/src/main/java/com/baeldung/application/Application.java new file mode 100644 index 0000000000..08c670c82f --- /dev/null +++ b/core-java/hashcode/src/main/java/com/baeldung/application/Application.java @@ -0,0 +1,23 @@ +package com.baeldung.application; + +import com.baeldung.entities.User; +import java.util.HashMap; +import java.util.Map; + +public class Application { + + public static void main(String[] args) { + Map users = new HashMap<>(); + User user1 = new User(1L, "John", "john@domain.com"); + User user2 = new User(2L, "Jennifer", "jennifer@domain.com"); + User user3 = new User(3L, "Mary", "mary@domain.com"); + + users.put(user1, user1); + users.put(user2, user2); + users.put(user3, user3); + + if (users.containsKey(user1)) { + System.out.print("User found in the collection"); + } + } +} diff --git a/core-java/hashcode/src/main/java/com/baeldung/entities/User.java b/core-java/hashcode/src/main/java/com/baeldung/entities/User.java new file mode 100644 index 0000000000..a976233562 --- /dev/null +++ b/core-java/hashcode/src/main/java/com/baeldung/entities/User.java @@ -0,0 +1,38 @@ +package com.baeldung.entities; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class User { + + private final Logger logger = LoggerFactory.getLogger(User.class); + private long id; + private String name; + private String email; + + public User(long id, String name, String email) { + this.id = id; + this.name = name; + this.email = email; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (this.getClass() != o.getClass()) return false; + User user = (User) o; + return id != user.id && (!name.equals(user.name) && !email.equals(user.email)); + } + + @Override + public int hashCode() { + int hash = 7; + hash = 31 * hash + (int) id; + hash = 31 * hash + (name == null ? 0 : name.hashCode()); + hash = 31 * hash + (email == null ? 0 : email.hashCode()); + logger.info("hashCode() method called - Computed hash: " + hash); + return hash; + } + // getters and setters here +} diff --git a/core-java/hashcode/src/test/java/com/baeldung/application/ApplicationTest.java b/core-java/hashcode/src/test/java/com/baeldung/application/ApplicationTest.java new file mode 100644 index 0000000000..dcd853f451 --- /dev/null +++ b/core-java/hashcode/src/test/java/com/baeldung/application/ApplicationTest.java @@ -0,0 +1,30 @@ +package com.baeldung.application; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import static org.junit.Assert.assertEquals; + +public class ApplicationTest { + + private ByteArrayOutputStream outContent; + + @Before + public void setUpPrintStreamInstance() throws Exception { + this.outContent = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outContent)); + } + + @After + public void tearDownByteArrayOutputStream() throws Exception { + outContent = null; + } + + @Test + public void main_NoInputState_TextPrintedToConsole() throws Exception { + Application.main(new String[]{}); + assertEquals("User found in the collection", outContent.toString()); + } +} \ No newline at end of file diff --git a/core-java/hashcode/src/test/java/com/baeldung/entities/UserTest.java b/core-java/hashcode/src/test/java/com/baeldung/entities/UserTest.java new file mode 100644 index 0000000000..01f6085d7e --- /dev/null +++ b/core-java/hashcode/src/test/java/com/baeldung/entities/UserTest.java @@ -0,0 +1,34 @@ +package com.baeldung.entities; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class UserTest { + + private User user; + private User comparisonUser; + + @Before + public void setUpUserInstances() { + this.user = new User(1L, "test", "test@domain.com"); + this.comparisonUser = this.user; + } + + @After + public void tearDownUserInstances() { + user = null; + comparisonUser = null; + } + + @Test + public void equals_EqualUserInstance_TrueAssertion(){ + Assert.assertTrue(user.equals(comparisonUser)); + } + + @Test + public void hashCode_UserHash_TrueAssertion() { + Assert.assertEquals(1792276941, user.hashCode()); + } +} \ No newline at end of file From 7fdab0e191fb709e4481198caad1ad73baba9479 Mon Sep 17 00:00:00 2001 From: slavisa-baeldung Date: Tue, 25 Jul 2017 15:42:57 +0100 Subject: [PATCH 72/89] BAEL-554 - Logging Spring Web Request --- .../web/log/test/TestTaxiFareController.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spring-rest/src/test/java/com/baeldung/web/log/test/TestTaxiFareController.java b/spring-rest/src/test/java/com/baeldung/web/log/test/TestTaxiFareController.java index 935275983f..398e3c04e9 100644 --- a/spring-rest/src/test/java/com/baeldung/web/log/test/TestTaxiFareController.java +++ b/spring-rest/src/test/java/com/baeldung/web/log/test/TestTaxiFareController.java @@ -13,21 +13,21 @@ import com.baeldung.web.log.data.TaxiRide; public class TestTaxiFareController { private static final String URL = "http://localhost:" + 8082 + "/spring-rest/taxifare/"; - + @Test - public void givenRequest_thenfetchTaxiFareRateCard() { + public void givenRequest_whenFetchTaxiFareRateCard_thanOK() { TestRestTemplate testRestTemplate = new TestRestTemplate(); ResponseEntity response = testRestTemplate.getForEntity(URL + "get/", String.class); + assertThat(response.getStatusCode(), equalTo(HttpStatus.OK)); } - + @Test - public void givenTaxiRide_thenGetCalculatedFare() { + public void givenTaxiRide_whenCalculatedFare_thanStatus200() { TestRestTemplate testRestTemplate = new TestRestTemplate(); - TaxiRide taxiRide = new TaxiRide(true,10l); - String fare = testRestTemplate.postForObject(URL + "calculate/", taxiRide,String.class); + TaxiRide taxiRide = new TaxiRide(true, 10l); + String fare = testRestTemplate.postForObject(URL + "calculate/", taxiRide, String.class); + assertThat(fare, equalTo("200")); } - - } From d4f245a275e016386562d7d7f4bb2b40b5cc74cb Mon Sep 17 00:00:00 2001 From: Adam InTae Gerard Date: Tue, 25 Jul 2017 15:11:02 -0700 Subject: [PATCH 73/89] BAEL-771 (#2286) * BAEL-771 * Corrected XOR from mislabeled AND * Unit tests added * Merged into libraries module - removed Neuroph module * Merged into libraries module - removed Neuroph module * Merged pom.xml * Merged pom.xml * libraries pom.xml - I removed a white space during merge so conflict persisted - here's the temporary reversion --- libraries/README.md | 1 + libraries/pom.xml | 45 +++++++++++- .../java/com/baeldung/neuroph/NeurophXOR.java | 73 +++++++++++++++++++ .../java/com/baeldung/neuroph/XORTest.java | 50 +++++++++++++ 4 files changed, 167 insertions(+), 2 deletions(-) create mode 100644 libraries/src/main/java/com/baeldung/neuroph/NeurophXOR.java create mode 100644 libraries/src/test/java/com/baeldung/neuroph/XORTest.java diff --git a/libraries/README.md b/libraries/README.md index 7970c0e99e..f0484ec710 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -26,6 +26,7 @@ - [A Guide to Apache Commons DbUtils](http://www.baeldung.com/apache-commons-dbutils) - [Introduction to Awaitility](http://www.baeldung.com/awaitlity-testing) - [Guide to the HyperLogLog Algorithm](http://www.baeldung.com/java-hyperloglog) +- [Introduction to Neuroph](http://www.baeldung.com/intro-to-neuroph) The libraries module contains examples related to small libraries that are relatively easy to use and does not require any separate module of its own. diff --git a/libraries/pom.xml b/libraries/pom.xml index d80c9ffdae..c5e1f64594 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -7,7 +7,6 @@ 1.0.0-SNAPSHOT 4.0.0 - libraries libraries @@ -71,9 +70,51 @@ + + + org.apache.maven.plugins + maven-jar-plugin + 3.0.2 + + + **/log4j.properties + + + + com.baeldung.neuroph.NeurophXOR + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.18.1 + + + test + test + + test + + + + test/java/com/baeldung/neuroph/XORTest.java + + + + + + + + + org.beykery + neuroph + ${neuroph.version} + cglib @@ -327,7 +368,6 @@ quartz 2.3.0 - one.util streamex @@ -432,6 +472,7 @@ 2.5 1.2.0 2.8.5 + 2.92 1.4.0 1.24.0 1.1.3-rc.5 diff --git a/libraries/src/main/java/com/baeldung/neuroph/NeurophXOR.java b/libraries/src/main/java/com/baeldung/neuroph/NeurophXOR.java new file mode 100644 index 0000000000..fb6a01d4c1 --- /dev/null +++ b/libraries/src/main/java/com/baeldung/neuroph/NeurophXOR.java @@ -0,0 +1,73 @@ +package com.baeldung.neuroph; + +import org.neuroph.core.Layer; +import org.neuroph.core.NeuralNetwork; +import org.neuroph.core.Neuron; +import org.neuroph.core.data.DataSet; +import org.neuroph.core.data.DataSetRow; +import org.neuroph.nnet.learning.BackPropagation; +import org.neuroph.util.ConnectionFactory; +import org.neuroph.util.NeuralNetworkType; + +public class NeurophXOR { + + public static NeuralNetwork assembleNeuralNetwork() { + + Layer inputLayer = new Layer(); + inputLayer.addNeuron(new Neuron()); + inputLayer.addNeuron(new Neuron()); + + Layer hiddenLayerOne = new Layer(); + hiddenLayerOne.addNeuron(new Neuron()); + hiddenLayerOne.addNeuron(new Neuron()); + hiddenLayerOne.addNeuron(new Neuron()); + hiddenLayerOne.addNeuron(new Neuron()); + + Layer hiddenLayerTwo = new Layer(); + hiddenLayerTwo.addNeuron(new Neuron()); + hiddenLayerTwo.addNeuron(new Neuron()); + hiddenLayerTwo.addNeuron(new Neuron()); + hiddenLayerTwo.addNeuron(new Neuron()); + + Layer outputLayer = new Layer(); + outputLayer.addNeuron(new Neuron()); + + NeuralNetwork ann = new NeuralNetwork(); + + ann.addLayer(0, inputLayer); + ann.addLayer(1, hiddenLayerOne); + ConnectionFactory.fullConnect(ann.getLayerAt(0), ann.getLayerAt(1)); + ann.addLayer(2, hiddenLayerTwo); + ConnectionFactory.fullConnect(ann.getLayerAt(1), ann.getLayerAt(2)); + ann.addLayer(3, outputLayer); + ConnectionFactory.fullConnect(ann.getLayerAt(2), ann.getLayerAt(3)); + ConnectionFactory.fullConnect(ann.getLayerAt(0), ann.getLayerAt(ann.getLayersCount()-1), false); + + ann.setInputNeurons(inputLayer.getNeurons()); + ann.setOutputNeurons(outputLayer.getNeurons()); + + ann.setNetworkType(NeuralNetworkType.MULTI_LAYER_PERCEPTRON); + return ann; + } + + public static NeuralNetwork trainNeuralNetwork(NeuralNetwork ann) { + int inputSize = 2; + int outputSize = 1; + DataSet ds = new DataSet(inputSize, outputSize); + + DataSetRow rOne = new DataSetRow(new double[] {0, 1}, new double[] {1}); + ds.addRow(rOne); + DataSetRow rTwo = new DataSetRow(new double[] {1, 1}, new double[] {0}); + ds.addRow(rTwo); + DataSetRow rThree = new DataSetRow(new double[] {0, 0}, new double[] {0}); + ds.addRow(rThree); + DataSetRow rFour = new DataSetRow(new double[] {1, 0}, new double[] {1}); + ds.addRow(rFour); + + BackPropagation backPropagation = new BackPropagation(); + backPropagation.setMaxIterations(1000); + + ann.learn(ds, backPropagation); + return ann; + } +} diff --git a/libraries/src/test/java/com/baeldung/neuroph/XORTest.java b/libraries/src/test/java/com/baeldung/neuroph/XORTest.java new file mode 100644 index 0000000000..063c57195b --- /dev/null +++ b/libraries/src/test/java/com/baeldung/neuroph/XORTest.java @@ -0,0 +1,50 @@ +package com.baeldung.neuroph; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.neuroph.core.NeuralNetwork; + +import static org.junit.Assert.*; + +public class XORTest { + private NeuralNetwork ann = null; + + @Before + public void annInit() { + ann = NeurophXOR.trainNeuralNetwork(NeurophXOR.assembleNeuralNetwork()); + } + + @Test + public void leftDisjunctTest() { + ann.setInput(0, 1); + ann.calculate(); + assertEquals(ann.getOutput()[0], 1.0,0.0); + } + + @Test + public void rightDisjunctTest() { + ann.setInput(1, 0); + ann.calculate(); + assertEquals(ann.getOutput()[0], 1.0,0.0); + } + + @Test + public void bothFalseConjunctTest() { + ann.setInput(0, 0); + ann.calculate(); + assertEquals(ann.getOutput()[0], 0.0,0.0); + } + + @Test + public void bothTrueConjunctTest() { + ann.setInput(1, 1); + ann.calculate(); + assertEquals(ann.getOutput()[0], 0.0,0.0); + } + + @After + public void annClose() { + ann = null; + } +} From a3c47eca35af99a65a39d7775e7fe951be325f9b Mon Sep 17 00:00:00 2001 From: mokhan Date: Wed, 26 Jul 2017 21:01:36 +0530 Subject: [PATCH 74/89] @GetMapping and @PostMapping instead of @RequestMappings change --- .../baeldung/web/log/controller/TaxiFareController.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-rest/src/main/java/com/baeldung/web/log/controller/TaxiFareController.java b/spring-rest/src/main/java/com/baeldung/web/log/controller/TaxiFareController.java index 28bf07e8a6..c39be88059 100644 --- a/spring-rest/src/main/java/com/baeldung/web/log/controller/TaxiFareController.java +++ b/spring-rest/src/main/java/com/baeldung/web/log/controller/TaxiFareController.java @@ -6,9 +6,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import com.baeldung.web.log.data.RateCard; @@ -23,14 +23,14 @@ public class TaxiFareController { private static final Logger LOGGER = LoggerFactory.getLogger(TaxiFareController.class); - @RequestMapping(method = RequestMethod.GET, value = "/taxifare/get/") + @GetMapping(value = "/taxifare/get/") @ResponseBody public RateCard getTaxiFare() { LOGGER.debug("getTaxiFare() - START"); return new RateCard(); } - @RequestMapping(method = RequestMethod.POST, value = "/taxifare/calculate/") + @PostMapping(value = "/taxifare/calculate/") @ResponseBody public String calculateTaxiFare(@RequestBody @Valid TaxiRide taxiRide) { LOGGER.debug("calculateTaxiFare() - START"); From 7ffd8ecb12dd24a12ae92e7d759192453e509f7d Mon Sep 17 00:00:00 2001 From: cleversonzanon Date: Thu, 27 Jul 2017 03:20:04 -0300 Subject: [PATCH 75/89] Cleverson Zanon | cleverson.ssantos1008@gmail.com (#2315) * Different Types of Bean Injection in Spring code * Dataclasses in Kotlin * Revert "Different Types of Bean Injection in Spring code" This reverts commit 4b747726b93a9f6bf76d6518792fc77e0d5c2fc9. * Destructuring Declarations in Kotlin --- .../destructuringdeclarations/Person.kt | 3 + .../destructuringdeclarations/Result.kt | 3 + .../destructuringdeclarations/Sandbox.kt | 55 +++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Person.kt create mode 100644 kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Result.kt create mode 100644 kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt diff --git a/kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Person.kt b/kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Person.kt new file mode 100644 index 0000000000..d3167ce033 --- /dev/null +++ b/kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Person.kt @@ -0,0 +1,3 @@ +package com.baeldung.destructuringdeclarations + +data class Person(var id: Int, var name: String, var age: Int) \ No newline at end of file diff --git a/kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Result.kt b/kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Result.kt new file mode 100644 index 0000000000..e3da9b46a4 --- /dev/null +++ b/kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Result.kt @@ -0,0 +1,3 @@ +package com.baeldung.destructuringdeclarations + +data class Result(val result: Int, val status: String) \ No newline at end of file diff --git a/kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt b/kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt new file mode 100644 index 0000000000..87775f9378 --- /dev/null +++ b/kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt @@ -0,0 +1,55 @@ +package com.baeldung.destructuringdeclarations + +import com.baeldung.destructuringdeclarations.Person +import com.baeldung.destructuringdeclarations.Result + +fun main(args: Array) { + + //2.1. Objects + val person = Person(1, "Jon Snow", 20) + val(id, name, age) = person + + println(id) //1 + println(name) //Jon Snow + println(age) //20 + + //The equivalent of line 10 +/* val id = person.component1(); + val name = person.component2(); + val age = person.component3();*/ + + //2.2. Functions + fun getPersonInfo() = Person(2, "Ned Stark", 45) + val(idf, namef, agef) = getPersonInfo() + + fun twoValuesReturn(): Result { + + // needed code + + return Result(1, "success") + } + + // Now, to use this function: + val (result, status) = twoValuesReturn() + + //2.3. Collections and For-loops + var map: HashMap = HashMap() + map.put(1, person) + + for((key, value) in map){ + println("Key: $key, Value: $value") + } + + //2.4. Underscore and Destructuring in Lambdas + val (_, status2) = twoValuesReturn() + + map.mapValues { entry -> "${entry.value}!" } + map.mapValues { (key, value) -> "$value!" } + + //A pair of parameters vs. a destructuring pair +/* { a -> ... } // one parameter + { a, b -> ... } // two parameters + { (a, b) -> ... } // a destructured pair + { (a, b), c -> ... } // a destructured pair and another parameter*/ + +} \ No newline at end of file From 0a631ac3269726b3569c94153c6c9e2e78f2e632 Mon Sep 17 00:00:00 2001 From: Seun Matt Date: Thu, 27 Jul 2017 21:59:45 +0100 Subject: [PATCH 76/89] Example Code for BAEL-1048 (#2316) * added updated example codes * updated example code StringToCharStream * deleted StringToCharStream.java locally * removed redundant file * added code for apache commons collection SetUtils * refactored example code * added example code for bytebuddy * added example code for PCollections * update pom --- libraries/pom.xml | 6 ++ .../pcollections/PCollectionsUnitTest.java | 91 +++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 libraries/src/test/java/com/baeldung/pcollections/PCollectionsUnitTest.java diff --git a/libraries/pom.xml b/libraries/pom.xml index c5e1f64594..a655f5267a 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -448,6 +448,11 @@ byte-buddy-agent ${bytebuddy.version} + + org.pcollections + pcollections + ${pcollections.version} + 0.7.0 @@ -487,5 +492,6 @@ 2.0.0.0 1.6.0 1.7.1 + 2.1.2 diff --git a/libraries/src/test/java/com/baeldung/pcollections/PCollectionsUnitTest.java b/libraries/src/test/java/com/baeldung/pcollections/PCollectionsUnitTest.java new file mode 100644 index 0000000000..b2f815074a --- /dev/null +++ b/libraries/src/test/java/com/baeldung/pcollections/PCollectionsUnitTest.java @@ -0,0 +1,91 @@ +package com.baeldung.pcollections; + +import org.junit.Test; +import org.pcollections.*; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class PCollectionsUnitTest { + + @Test + public void whenEmpty_thenCreateEmptyHashPMap() { + HashPMap pmap = HashTreePMap.empty(); + assertEquals(pmap.size(), 0); + } + + @Test + public void givenKeyValue_whenSingleton_thenCreateNonEmptyHashPMap() { + HashPMap pmap1 = HashTreePMap.singleton("key1", "value1"); + assertEquals(pmap1.size(), 1); + } + + @Test + public void givenExistingHashMap_whenFrom_thenCreateHashPMap() { + Map map = new HashMap(); + map.put("mkey1", "mval1"); + map.put("mkey2", "mval2"); + + HashPMap pmap2 = HashTreePMap.from(map); + assertEquals(pmap2.size(), 2); + } + + @Test + public void whenHashPMapMethods_thenPerformOperations() { + + HashPMap pmap = HashTreePMap.empty(); + pmap = pmap.plus("key1", "value1"); + assertEquals(pmap.size(), 1); + + Map map = new HashMap(); + map.put("key2", "val2"); + map.put("key3", "val3"); + pmap = pmap.plusAll(map); + + assertEquals(pmap.size(), 3); + + pmap = pmap.minus("key1"); + assertFalse(pmap.containsKey("key1")); + + pmap = pmap.minusAll(map.keySet()); + assertEquals(pmap.size(), 0); + + } + + @Test + public void whenTreePVectorMethods_thenPerformOperations() { + TreePVector pVector = TreePVector.empty(); + + pVector = pVector.plus("e1"); + pVector = pVector.plusAll(Arrays.asList("e2", "e3", "e4")); + assertEquals(4, pVector.size()); + + TreePVector pSub = pVector.subList(0, 2); + assertTrue(pSub.contains("e1") && pSub.contains("e2")); + + TreePVector pVW = (TreePVector) pVector.with(0, "e10"); + assertEquals(pVW.get(0), "e10"); + + pVector = pVector.minus("e1"); + TreePVector pV1 = pVector.minusAll(Arrays.asList("e2", "e3")); + assertEquals(pV1.size(), 1); + } + + @Test + public void whenMapPSetMethods_thenPerformOperations() { + + MapPSet pSet = HashTreePSet.empty() + .plusAll(Arrays.asList("e1","e2","e3","e4")); + assertEquals(pSet.size(), 4); + + pSet = pSet.minus("e4"); + assertFalse(pSet.contains("e4")); + + } + +} From 9e193396ef620b41ad305ee6df2110f4a74e8113 Mon Sep 17 00:00:00 2001 From: Tian Baoqiang Date: Fri, 28 Jul 2017 04:58:24 -0500 Subject: [PATCH 77/89] BAEL-1026 (#2322) --- ratpack/pom.xml | 99 ++++++++++--------- .../java/com/baeldung/spring/ArticleList.java | 11 +++ .../main/java/com/baeldung/spring/Config.java | 24 +++++ .../java/com/baeldung/spring/Content.java | 10 ++ .../com/baeldung/spring/EmbedRatpackApp.java | 46 +++++++++ .../baeldung/spring/EmbedSpringBootApp.java | 19 ++++ ratpack/src/main/resources/public/index.html | 10 ++ .../EmbedRatpackAppIntegrationTest.java | 41 ++++++++ 8 files changed, 215 insertions(+), 45 deletions(-) create mode 100644 ratpack/src/main/java/com/baeldung/spring/ArticleList.java create mode 100644 ratpack/src/main/java/com/baeldung/spring/Config.java create mode 100644 ratpack/src/main/java/com/baeldung/spring/Content.java create mode 100644 ratpack/src/main/java/com/baeldung/spring/EmbedRatpackApp.java create mode 100644 ratpack/src/main/java/com/baeldung/spring/EmbedSpringBootApp.java create mode 100644 ratpack/src/main/resources/public/index.html create mode 100644 ratpack/src/test/java/com/baeldung/spring/EmbedRatpackAppIntegrationTest.java diff --git a/ratpack/pom.xml b/ratpack/pom.xml index 8681f5fc10..7a75ec50b7 100644 --- a/ratpack/pom.xml +++ b/ratpack/pom.xml @@ -1,55 +1,64 @@ - 4.0.0 - com.baeldung - ratpack - jar - 1.0-SNAPSHOT - ratpack - http://maven.apache.org + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + 4.0.0 + com.baeldung + ratpack + jar + 1.0-SNAPSHOT + ratpack + http://maven.apache.org - - UTF-8 - 1.8 - 1.8 - + + UTF-8 + 1.8 + 1.8 + 1.4.6 + com.baeldung parent-modules 1.0.0-SNAPSHOT - - - - - io.ratpack - ratpack-core - 1.4.5 - - - io.ratpack - ratpack-hikari - 1.4.5 - - - io.ratpack - ratpack-test - 1.4.5 - - - com.h2database - h2 - 1.4.193 - - + - - ${project.artifactId} - - - src/main/resources - - - + + + + io.ratpack + ratpack-spring-boot-starter + ${ratpack.version} + pom + + + + io.ratpack + ratpack-core + ${ratpack.version} + + + io.ratpack + ratpack-hikari + ${ratpack.version} + + + io.ratpack + ratpack-test + ${ratpack.version} + + + com.h2database + h2 + 1.4.193 + + + + + ${project.artifactId} + + + src/main/resources + + + diff --git a/ratpack/src/main/java/com/baeldung/spring/ArticleList.java b/ratpack/src/main/java/com/baeldung/spring/ArticleList.java new file mode 100644 index 0000000000..b4d50bb3d3 --- /dev/null +++ b/ratpack/src/main/java/com/baeldung/spring/ArticleList.java @@ -0,0 +1,11 @@ +package com.baeldung.spring; + +import java.util.List; + +/** + * @author aiet + */ +public interface ArticleList { + + List articles(); +} diff --git a/ratpack/src/main/java/com/baeldung/spring/Config.java b/ratpack/src/main/java/com/baeldung/spring/Config.java new file mode 100644 index 0000000000..ec0d1787e6 --- /dev/null +++ b/ratpack/src/main/java/com/baeldung/spring/Config.java @@ -0,0 +1,24 @@ +package com.baeldung.spring; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.Arrays; + +/** + * @author aiet + */ +@Configuration +public class Config { + + @Bean + public Content content() { + return () -> "hello baeldung!"; + } + + @Bean + public ArticleList articles() { + return () -> Arrays.asList("Introduction to Ratpack", "Ratpack Google Guice Integration", "Ratpack Spring Boot Integration"); + } + +} diff --git a/ratpack/src/main/java/com/baeldung/spring/Content.java b/ratpack/src/main/java/com/baeldung/spring/Content.java new file mode 100644 index 0000000000..4d01c70cb9 --- /dev/null +++ b/ratpack/src/main/java/com/baeldung/spring/Content.java @@ -0,0 +1,10 @@ +package com.baeldung.spring; + +/** + * @author aiet + */ +public interface Content { + + String body(); + +} diff --git a/ratpack/src/main/java/com/baeldung/spring/EmbedRatpackApp.java b/ratpack/src/main/java/com/baeldung/spring/EmbedRatpackApp.java new file mode 100644 index 0000000000..7f3483d676 --- /dev/null +++ b/ratpack/src/main/java/com/baeldung/spring/EmbedRatpackApp.java @@ -0,0 +1,46 @@ +package com.baeldung.spring; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import ratpack.func.Action; +import ratpack.handling.Chain; +import ratpack.server.ServerConfig; +import ratpack.spring.config.EnableRatpack; + +/** + * @author aiet + */ +@SpringBootApplication +@EnableRatpack +public class EmbedRatpackApp { + + @Autowired private Content content; + @Autowired private ArticleList list; + + @Bean + public Action hello() { + return chain -> chain.get("hello", ctx -> ctx.render(content.body())); + } + + @Bean + public Action list() { + return chain -> chain.get("list", ctx -> ctx.render(list + .articles() + .toString())); + } + + @Bean + public ServerConfig ratpackServerConfig() { + return ServerConfig + .builder() + .findBaseDir("public") + .build(); + } + + public static void main(String[] args) { + SpringApplication.run(EmbedRatpackApp.class, args); + } + +} diff --git a/ratpack/src/main/java/com/baeldung/spring/EmbedSpringBootApp.java b/ratpack/src/main/java/com/baeldung/spring/EmbedSpringBootApp.java new file mode 100644 index 0000000000..05ff00cbbd --- /dev/null +++ b/ratpack/src/main/java/com/baeldung/spring/EmbedSpringBootApp.java @@ -0,0 +1,19 @@ +package com.baeldung.spring; + +import ratpack.server.RatpackServer; + +import static ratpack.spring.Spring.spring; + +public class EmbedSpringBootApp { + + public static void main(String[] args) throws Exception { + RatpackServer.start(server -> server + .registry(spring(Config.class)) + .handlers(chain -> chain.get(ctx -> ctx.render(ctx + .get(Content.class) + .body())))); + } + +} + + diff --git a/ratpack/src/main/resources/public/index.html b/ratpack/src/main/resources/public/index.html new file mode 100644 index 0000000000..d6573bfb7f --- /dev/null +++ b/ratpack/src/main/resources/public/index.html @@ -0,0 +1,10 @@ + + + + + Special Static Resource + + +This page is static. + + \ No newline at end of file diff --git a/ratpack/src/test/java/com/baeldung/spring/EmbedRatpackAppIntegrationTest.java b/ratpack/src/test/java/com/baeldung/spring/EmbedRatpackAppIntegrationTest.java new file mode 100644 index 0000000000..802fe75d5c --- /dev/null +++ b/ratpack/src/test/java/com/baeldung/spring/EmbedRatpackAppIntegrationTest.java @@ -0,0 +1,41 @@ +package com.baeldung.spring; + +import org.junit.Test; +import ratpack.test.MainClassApplicationUnderTest; + +import java.io.IOException; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; + +/** + * @author aiet + */ +public class EmbedRatpackAppIntegrationTest { + + MainClassApplicationUnderTest appUnderTest = new MainClassApplicationUnderTest(EmbedRatpackApp.class); + + @Test + public void whenSayHello_thenGotWelcomeMessage() { + assertEquals("hello baeldung!", appUnderTest + .getHttpClient() + .getText("/hello")); + } + + @Test + public void whenRequestList_thenGotArticles() throws IOException { + assertEquals(3, appUnderTest + .getHttpClient() + .getText("/list") + .split(",").length); + } + + @Test + public void whenRequestStaticResource_thenGotStaticContent() { + assertThat(appUnderTest + .getHttpClient() + .getText("/"), containsString("page is static")); + } + +} From 828e5143d133188d46e8570638543b172d611965 Mon Sep 17 00:00:00 2001 From: dimitarsazdovski Date: Fri, 28 Jul 2017 14:33:00 +0200 Subject: [PATCH 78/89] BAEL-907: Code example and tests (#2295) * BAEL-907: Code example and tests * Moved files to libraries module * Moved example to test class * Moved files. Formatted code. Changed object declaring. * Code fixes according to comments --- .../CircularFifoQueueTest.java | 159 ++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 libraries/src/test/java/com/baeldung/circularfifoqueue/CircularFifoQueueTest.java diff --git a/libraries/src/test/java/com/baeldung/circularfifoqueue/CircularFifoQueueTest.java b/libraries/src/test/java/com/baeldung/circularfifoqueue/CircularFifoQueueTest.java new file mode 100644 index 0000000000..9f670af03c --- /dev/null +++ b/libraries/src/test/java/com/baeldung/circularfifoqueue/CircularFifoQueueTest.java @@ -0,0 +1,159 @@ +package com.baeldung.circularfifoqueue; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.collections4.queue.CircularFifoQueue; +import org.junit.Assert; +import org.junit.Test; + +public class CircularFifoQueueTest { + + private static final int DEFAULT_SIZE = 32; + + private static final int FIXED_SIZE = 5; + + private static final int COLLECTION_SIZE = 7; + + private static final String TEST_COLOR = "Red"; + + private static final String TEST_COLOR_BY_INDEX = "Blue"; + + @Test + public void whenUsingDefualtConstructor_correctSizeQueue() { + CircularFifoQueue bits = new CircularFifoQueue<>(); + + Assert.assertEquals(DEFAULT_SIZE, bits.maxSize()); + } + + @Test + public void givenAddElements_whenUsingIntConstructor_correctSizeQueue() { + CircularFifoQueue colors = new CircularFifoQueue<>(5); + colors.add("Red"); + colors.add("Blue"); + colors.add("Green"); + colors.offer("White"); + colors.offer("Black"); + + Assert.assertEquals(FIXED_SIZE, colors.maxSize()); + } + + @Test + public void whenUsingCollectionConstructor_correctSizeQueue() { + List days = new ArrayList<>(); + days.add("Monday"); + days.add("Tuesday"); + days.add("Wednesday"); + days.add("Thursday"); + days.add("Friday"); + days.add("Saturday"); + days.add("Sunday"); + + CircularFifoQueue daysOfWeek = new CircularFifoQueue<>(days); + + Assert.assertEquals(COLLECTION_SIZE, daysOfWeek.maxSize()); + } + + @Test + public void givenAddElements_whenGetElement_correctElement() { + CircularFifoQueue colors = new CircularFifoQueue<>(5); + colors.add("Red"); + colors.add("Blue"); + colors.add("Green"); + colors.offer("White"); + colors.offer("Black"); + + Assert.assertEquals(TEST_COLOR_BY_INDEX, colors.get(1)); + } + + @Test + public void givenAddElements_whenPollElement_correctElement() { + CircularFifoQueue colors = new CircularFifoQueue<>(5); + colors.add("Red"); + colors.add("Blue"); + colors.add("Green"); + colors.offer("White"); + colors.offer("Black"); + + Assert.assertEquals(TEST_COLOR, colors.poll()); + } + + @Test + public void givenAddElements_whenPeekQueue_correctElement() { + CircularFifoQueue colors = new CircularFifoQueue<>(5); + colors.add("Red"); + colors.add("Blue"); + colors.add("Green"); + colors.offer("White"); + colors.offer("Black"); + + Assert.assertEquals(TEST_COLOR, colors.peek()); + } + + @Test + public void givenAddElements_whenElementQueue_correctElement() { + CircularFifoQueue colors = new CircularFifoQueue<>(5); + colors.add("Red"); + colors.add("Blue"); + colors.add("Green"); + colors.offer("White"); + colors.offer("Black"); + + Assert.assertEquals(TEST_COLOR, colors.element()); + } + + @Test + public void givenAddElements_whenRemoveElement_correctElement() { + CircularFifoQueue colors = new CircularFifoQueue<>(5); + colors.add("Red"); + colors.add("Blue"); + colors.add("Green"); + colors.offer("White"); + colors.offer("Black"); + + Assert.assertEquals(TEST_COLOR, colors.remove()); + } + + @Test + public void givenFullQueue_whenClearQueue_getIsEmpty() { + CircularFifoQueue colors = new CircularFifoQueue<>(5); + colors.add("Red"); + colors.add("Blue"); + colors.add("Green"); + colors.offer("White"); + colors.offer("Black"); + + colors.clear(); + + Assert.assertEquals(true, colors.isEmpty()); + } + + @Test + public void givenFullQueue_whenCheckFull_getIsFull() { + CircularFifoQueue colors = new CircularFifoQueue<>(5); + colors.add("Red"); + colors.add("Blue"); + colors.add("Green"); + colors.offer("White"); + colors.offer("Black"); + + Assert.assertEquals(false, colors.isFull()); + } + + @Test + public void givenFullQueue_whenAddMoreElements_getIsAtFullCapacity() { + CircularFifoQueue colors = new CircularFifoQueue<>(5); + colors.add("Red"); + colors.add("Blue"); + colors.add("Green"); + colors.offer("White"); + colors.offer("Black"); + + colors.add("Orange"); + colors.add("Violet"); + colors.add("Pink"); + + Assert.assertEquals(true, colors.isAtFullCapacity()); + } + +} From d71f330b09ca2993d27094cb8ad31ead792540b6 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Fri, 28 Jul 2017 17:49:28 +0200 Subject: [PATCH 79/89] Enable GitHub Incremental Builder (#2323) * Enable GIB * Enable GIB --- pom.xml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index b6813a8c18..fa6a3e5673 100644 --- a/pom.xml +++ b/pom.xml @@ -12,6 +12,9 @@ UTF-8 refs/heads/master + true + false + false 4.12 1.3 @@ -328,11 +331,11 @@ - + 3.4 + From 9b143b820c7b6e077664552773c7711facefcbd8 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Fri, 28 Jul 2017 18:15:37 +0200 Subject: [PATCH 80/89] Refactor core-java (#2324) --- .../cyclicbarrier/CyclicBarrierExample.java | 30 +++++++++---------- .../concurrent/cyclicbarrier/Task.java | 27 ++++++++--------- .../equalshashcode/entities/Rectangle.java | 2 +- .../executable/ExecutableMavenJar.java | 3 +- 4 files changed, 29 insertions(+), 33 deletions(-) diff --git a/core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierExample.java b/core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierExample.java index 85c0cf7680..dd80a7971c 100644 --- a/core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierExample.java +++ b/core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierExample.java @@ -4,22 +4,20 @@ import java.util.concurrent.CyclicBarrier; public class CyclicBarrierExample { - public void start() { - CyclicBarrier cyclicBarrier = new CyclicBarrier(3, () -> { - // Task - System.out.println("All previous tasks are completed"); - }); + public void start() { + CyclicBarrier cyclicBarrier = new CyclicBarrier(3, () -> { + // Task + System.out.println("All previous tasks are completed"); + }); - Thread t1 = new Thread(new Task(cyclicBarrier), "T1"); - Thread t2 = new Thread(new Task(cyclicBarrier), "T2"); - Thread t3 = new Thread(new Task(cyclicBarrier), "T3"); - - if (!cyclicBarrier.isBroken()) { - t1.start(); - t2.start(); - t3.start(); - } - - } + Thread t1 = new Thread(new Task(cyclicBarrier), "T1"); + Thread t2 = new Thread(new Task(cyclicBarrier), "T2"); + Thread t3 = new Thread(new Task(cyclicBarrier), "T3"); + if (!cyclicBarrier.isBroken()) { + t1.start(); + t2.start(); + t3.start(); + } + } } diff --git a/core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/Task.java b/core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/Task.java index 4f7801e8c5..cc9ed105dc 100644 --- a/core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/Task.java +++ b/core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/Task.java @@ -6,20 +6,19 @@ import java.util.concurrent.CyclicBarrier; public class Task implements Runnable { private CyclicBarrier barrier; - - public Task(CyclicBarrier barrier) { - this.barrier = barrier; - } - @Override - public void run() { + public Task(CyclicBarrier barrier) { + this.barrier = barrier; + } + + @Override + public void run() { try { - System.out.println("Thread : "+ Thread.currentThread().getName() + " is waiting"); - barrier.await(); - System.out.println("Thread : "+ Thread.currentThread().getName() + " is released"); - } catch (InterruptedException | BrokenBarrierException e) { - e.printStackTrace(); - } - } - + System.out.println("Thread : " + Thread.currentThread().getName() + " is waiting"); + barrier.await(); + System.out.println("Thread : " + Thread.currentThread().getName() + " is released"); + } catch (InterruptedException | BrokenBarrierException e) { + e.printStackTrace(); + } + } } diff --git a/core-java/src/main/java/org/baeldung/equalshashcode/entities/Rectangle.java b/core-java/src/main/java/org/baeldung/equalshashcode/entities/Rectangle.java index 1e1423f0b3..5e38eb6088 100644 --- a/core-java/src/main/java/org/baeldung/equalshashcode/entities/Rectangle.java +++ b/core-java/src/main/java/org/baeldung/equalshashcode/entities/Rectangle.java @@ -4,7 +4,7 @@ public class Rectangle extends Shape { private double width; private double length; - public Rectangle(double width, double length) { + Rectangle(double width, double length) { this.width = width; this.length = length; } diff --git a/core-java/src/main/java/org/baeldung/executable/ExecutableMavenJar.java b/core-java/src/main/java/org/baeldung/executable/ExecutableMavenJar.java index 09344902b7..d291ac0d3b 100644 --- a/core-java/src/main/java/org/baeldung/executable/ExecutableMavenJar.java +++ b/core-java/src/main/java/org/baeldung/executable/ExecutableMavenJar.java @@ -1,11 +1,10 @@ package org.baeldung.executable; -import javax.swing.JOptionPane; +import javax.swing.*; public class ExecutableMavenJar { public static void main(String[] args) { JOptionPane.showMessageDialog(null, "It worked!", "Executable Jar with Maven", 1); } - } From 7f22e3dc35e033c24b42a6a83f336a49cf1aea40 Mon Sep 17 00:00:00 2001 From: cleversonzanon Date: Fri, 28 Jul 2017 17:51:16 -0300 Subject: [PATCH 81/89] Destructuring Declarations in Kotlin - Cleverson Zanon | cleverson.ssantos1008@gmail.com (#2318) * Different Types of Bean Injection in Spring code * Dataclasses in Kotlin * Revert "Different Types of Bean Injection in Spring code" This reverts commit 4b747726b93a9f6bf76d6518792fc77e0d5c2fc9. * Destructuring Declarations in Kotlin * Corrections on Destructuring Declarations in Kotlin --- .../destructuringdeclarations/Sandbox.kt | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt b/kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt index 87775f9378..a5018d93c8 100644 --- a/kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt +++ b/kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt @@ -1,11 +1,10 @@ package com.baeldung.destructuringdeclarations import com.baeldung.destructuringdeclarations.Person -import com.baeldung.destructuringdeclarations.Result fun main(args: Array) { - //2.1. Objects + //2.1. Objects val person = Person(1, "Jon Snow", 20) val(id, name, age) = person @@ -13,20 +12,15 @@ fun main(args: Array) { println(name) //Jon Snow println(age) //20 - //The equivalent of line 10 -/* val id = person.component1(); - val name = person.component2(); - val age = person.component3();*/ - //2.2. Functions fun getPersonInfo() = Person(2, "Ned Stark", 45) val(idf, namef, agef) = getPersonInfo() - fun twoValuesReturn(): Result { + fun twoValuesReturn(): Pair { // needed code - return Result(1, "success") + return Pair(1, "success") } // Now, to use this function: @@ -41,15 +35,10 @@ fun main(args: Array) { } //2.4. Underscore and Destructuring in Lambdas - val (_, status2) = twoValuesReturn() + val (_, name2, age2) = person + val (id3, name3) = person map.mapValues { entry -> "${entry.value}!" } map.mapValues { (key, value) -> "$value!" } - //A pair of parameters vs. a destructuring pair -/* { a -> ... } // one parameter - { a, b -> ... } // two parameters - { (a, b) -> ... } // a destructured pair - { (a, b), c -> ... } // a destructured pair and another parameter*/ - } \ No newline at end of file From e8df7f8116ad20a632c19ae97ee5c5ac2be5af96 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sat, 29 Jul 2017 10:06:27 +0200 Subject: [PATCH 82/89] Taxi fare refactor (#2328) --- spring-rest/difference-uri-url-rest/pom.xml | 32 ------------------ .../baeldung/springboot/rest/Greeting.java | 21 ------------ .../springboot/rest/GreetingController.java | 21 ------------ .../rest/SpringBootWebApplication.java | 27 --------------- .../rest/client/ApplicationClient.java | 27 --------------- .../springboot/rest/client/Greeting.java | 33 ------------------- .../rest/test/DifferenceURIURLRESTTest.java | 32 ------------------ .../controller/DataProducerController.java | 2 +- .../com/baeldung/web/log/app/Application.java | 1 - .../log/app/TaxiFareRequestInterceptor.java | 4 +-- .../web/log/config/TaxiFareMVCConfig.java | 5 ++- .../log/controller/TaxiFareController.java | 9 +++-- .../com/baeldung/web/log/data/RateCard.java | 19 ++++++----- .../com/baeldung/web/log/data/TaxiRide.java | 11 ++++--- .../service/TaxiFareCalculatorService.java | 14 +++----- .../org/baeldung/config/MainApplication.java | 1 - .../repository/HeavyResourceRepository.java | 7 ++-- 17 files changed, 34 insertions(+), 232 deletions(-) delete mode 100644 spring-rest/difference-uri-url-rest/pom.xml delete mode 100644 spring-rest/difference-uri-url-rest/src/main/java/com/baeldung/springboot/rest/Greeting.java delete mode 100644 spring-rest/difference-uri-url-rest/src/main/java/com/baeldung/springboot/rest/GreetingController.java delete mode 100644 spring-rest/difference-uri-url-rest/src/main/java/com/baeldung/springboot/rest/SpringBootWebApplication.java delete mode 100644 spring-rest/difference-uri-url-rest/src/main/java/com/baeldung/springboot/rest/client/ApplicationClient.java delete mode 100644 spring-rest/difference-uri-url-rest/src/main/java/com/baeldung/springboot/rest/client/Greeting.java delete mode 100644 spring-rest/difference-uri-url-rest/src/test/java/com/baeldung/springboot/rest/test/DifferenceURIURLRESTTest.java diff --git a/spring-rest/difference-uri-url-rest/pom.xml b/spring-rest/difference-uri-url-rest/pom.xml deleted file mode 100644 index 5ab6e63240..0000000000 --- a/spring-rest/difference-uri-url-rest/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ - - 4.0.0 - org.baeldung.springboot.rest - difference-uri-url-rest - 0.0.1-SNAPSHOT - war - - - 1.8 - - - - org.springframework.boot - spring-boot-starter-parent - 1.5.2.RELEASE - - - - - - org.springframework.boot - spring-boot-starter-web - compile - - - org.springframework.boot - spring-boot-starter-test - test - - - - \ No newline at end of file diff --git a/spring-rest/difference-uri-url-rest/src/main/java/com/baeldung/springboot/rest/Greeting.java b/spring-rest/difference-uri-url-rest/src/main/java/com/baeldung/springboot/rest/Greeting.java deleted file mode 100644 index cc166587df..0000000000 --- a/spring-rest/difference-uri-url-rest/src/main/java/com/baeldung/springboot/rest/Greeting.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.baeldung.springboot.rest; - -public class Greeting { - private static final long serialVersionUID = 1L; - - private Integer id = null; - private String content = null; - - public Greeting(Integer id) { - this.id = id; - this.content = "Hello World"; - } - - public Integer getId() { - return id; - } - - public String getContent() { - return content; - } -} \ No newline at end of file diff --git a/spring-rest/difference-uri-url-rest/src/main/java/com/baeldung/springboot/rest/GreetingController.java b/spring-rest/difference-uri-url-rest/src/main/java/com/baeldung/springboot/rest/GreetingController.java deleted file mode 100644 index 3fca9a1a76..0000000000 --- a/spring-rest/difference-uri-url-rest/src/main/java/com/baeldung/springboot/rest/GreetingController.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.baeldung.springboot.rest; - -import java.util.concurrent.atomic.AtomicLong; - -import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -@RestController("/") -@Component -public class GreetingController { - - private final AtomicLong counter = new AtomicLong(); - - @RequestMapping(value = "/greetings", method = RequestMethod.GET) - public Greeting greeting() { - - return new Greeting(new Integer((int) counter.incrementAndGet())); - } -} \ No newline at end of file diff --git a/spring-rest/difference-uri-url-rest/src/main/java/com/baeldung/springboot/rest/SpringBootWebApplication.java b/spring-rest/difference-uri-url-rest/src/main/java/com/baeldung/springboot/rest/SpringBootWebApplication.java deleted file mode 100644 index 08d4c2c65e..0000000000 --- a/spring-rest/difference-uri-url-rest/src/main/java/com/baeldung/springboot/rest/SpringBootWebApplication.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.baeldung.springboot.rest; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.web.support.SpringBootServletInitializer; - -@EnableAutoConfiguration -@SpringBootApplication -public class SpringBootWebApplication extends SpringBootServletInitializer { - - // method for explicit deployment on Application Server - @Override - protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { - return application.sources(SpringBootWebApplication.class); - } - - // run it as standalone JAVA application - public static void main(String[] args) throws Exception { - SpringApplication.run(SpringBootWebApplication.class, args); - } - - //Samples - // http://localhost:8080/greetings - // http://localhost:8989/difference-uri-url-rest/greetings -} \ No newline at end of file diff --git a/spring-rest/difference-uri-url-rest/src/main/java/com/baeldung/springboot/rest/client/ApplicationClient.java b/spring-rest/difference-uri-url-rest/src/main/java/com/baeldung/springboot/rest/client/ApplicationClient.java deleted file mode 100644 index 2d92c890c5..0000000000 --- a/spring-rest/difference-uri-url-rest/src/main/java/com/baeldung/springboot/rest/client/ApplicationClient.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.baeldung.springboot.rest.client; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.web.client.RestTemplate; - -public class ApplicationClient { - //private static final Logger log = LoggerFactory.getLogger(ApplicationClient.class); - final static String URI_STRING = "http://localhost:8080/difference-uri-url-rest/greetings"; - - - public ApplicationClient() { - super(); - } - - public Greeting init() { - RestTemplate restTemplate = new RestTemplate(); - Greeting greeting = restTemplate.getForObject(ApplicationClient.URI_STRING, Greeting.class); - //log.info(greeting.toString()); - return greeting; - } - public static void main(String args[]) { - Greeting greeting = new ApplicationClient().init(); - System.out.println(greeting.toString()); - } - -} diff --git a/spring-rest/difference-uri-url-rest/src/main/java/com/baeldung/springboot/rest/client/Greeting.java b/spring-rest/difference-uri-url-rest/src/main/java/com/baeldung/springboot/rest/client/Greeting.java deleted file mode 100644 index 7d1119d155..0000000000 --- a/spring-rest/difference-uri-url-rest/src/main/java/com/baeldung/springboot/rest/client/Greeting.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.baeldung.springboot.rest.client; - -import java.io.Serializable; - -public class Greeting implements Serializable { - private static final long serialVersionUID = 1L; - - private Integer id = null; - private String content = null; - - /** Default constructor is mandatory for client */ - public Greeting() { - super(); - } - - public Greeting(Integer id) { - this.id = id; - this.content = "Hello World"; - } - - public Integer getId() { - return id; - } - - public String getContent() { - return content; - } - - @Override - public String toString() { - return "Id: " + getId().toString() + " Content: " + getContent(); - } -} \ No newline at end of file diff --git a/spring-rest/difference-uri-url-rest/src/test/java/com/baeldung/springboot/rest/test/DifferenceURIURLRESTTest.java b/spring-rest/difference-uri-url-rest/src/test/java/com/baeldung/springboot/rest/test/DifferenceURIURLRESTTest.java deleted file mode 100644 index 4397f8e088..0000000000 --- a/spring-rest/difference-uri-url-rest/src/test/java/com/baeldung/springboot/rest/test/DifferenceURIURLRESTTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baeldung.springboot.rest.test; - -import static org.junit.Assert.assertNotNull; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.springframework.web.client.RestTemplate; - -import com.baeldung.springboot.rest.client.Greeting; - -public class DifferenceURIURLRESTTest { - final static String URI_STRING = "http://localhost:8080/difference-uri-url-rest/greetings"; - static RestTemplate restTemplate; - Greeting greeting; - - @BeforeClass - public static void setupTest() { - restTemplate = new RestTemplate(); - } - - @Test - public void givenRestTenplate_whenIsNotNull_thenSuccess() { - assertNotNull("Rest Template not null", restTemplate); - } - - @Test - public void givenWiredConstructorParam_whenIsNotNull_thenSuccess() { - greeting = restTemplate.getForObject(URI_STRING, Greeting.class); - assertNotNull("Greeting class is not null", greeting); - } - -} diff --git a/spring-rest/src/main/java/com/baeldung/produceimage/controller/DataProducerController.java b/spring-rest/src/main/java/com/baeldung/produceimage/controller/DataProducerController.java index 6f34bdb9ae..ab233a8b60 100644 --- a/spring-rest/src/main/java/com/baeldung/produceimage/controller/DataProducerController.java +++ b/spring-rest/src/main/java/com/baeldung/produceimage/controller/DataProducerController.java @@ -17,7 +17,7 @@ public class DataProducerController { return "Hello world"; } - @GetMapping(value = "/get-image") + @GetMapping("/get-image") public @ResponseBody byte[] getImage() throws IOException { final InputStream in = getClass().getResourceAsStream("/com/baeldung/produceimage/image.jpg"); return IOUtils.toByteArray(in); diff --git a/spring-rest/src/main/java/com/baeldung/web/log/app/Application.java b/spring-rest/src/main/java/com/baeldung/web/log/app/Application.java index 9bdbbd0d9f..41042008ef 100644 --- a/spring-rest/src/main/java/com/baeldung/web/log/app/Application.java +++ b/spring-rest/src/main/java/com/baeldung/web/log/app/Application.java @@ -14,5 +14,4 @@ public class Application extends SpringBootServletInitializer { public static void main(final String[] args) { SpringApplication.run(Application.class, args); } - } \ No newline at end of file diff --git a/spring-rest/src/main/java/com/baeldung/web/log/app/TaxiFareRequestInterceptor.java b/spring-rest/src/main/java/com/baeldung/web/log/app/TaxiFareRequestInterceptor.java index 831d236edd..b154f3665f 100644 --- a/spring-rest/src/main/java/com/baeldung/web/log/app/TaxiFareRequestInterceptor.java +++ b/spring-rest/src/main/java/com/baeldung/web/log/app/TaxiFareRequestInterceptor.java @@ -14,11 +14,11 @@ import com.baeldung.web.log.util.RequestLoggingUtil; @Component public class TaxiFareRequestInterceptor extends HandlerInterceptorAdapter { - Logger LOGGER = LoggerFactory.getLogger(TaxiFareRequestInterceptor.class); + private final static Logger LOGGER = LoggerFactory.getLogger(TaxiFareRequestInterceptor.class); @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { - String postData = null; + String postData; HttpServletRequest requestCacheWrapperObject = null; try { // Uncomment to produce the stream closed issue diff --git a/spring-rest/src/main/java/com/baeldung/web/log/config/TaxiFareMVCConfig.java b/spring-rest/src/main/java/com/baeldung/web/log/config/TaxiFareMVCConfig.java index fa26706ff0..f433b4f3c7 100644 --- a/spring-rest/src/main/java/com/baeldung/web/log/config/TaxiFareMVCConfig.java +++ b/spring-rest/src/main/java/com/baeldung/web/log/config/TaxiFareMVCConfig.java @@ -1,18 +1,17 @@ package com.baeldung.web.log.config; +import com.baeldung.web.log.app.TaxiFareRequestInterceptor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; -import com.baeldung.web.log.app.TaxiFareRequestInterceptor; - @Configuration public class TaxiFareMVCConfig extends WebMvcConfigurerAdapter { @Autowired private TaxiFareRequestInterceptor taxiFareRequestInterceptor; - + @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(taxiFareRequestInterceptor).addPathPatterns("/**/taxifare/**/"); diff --git a/spring-rest/src/main/java/com/baeldung/web/log/controller/TaxiFareController.java b/spring-rest/src/main/java/com/baeldung/web/log/controller/TaxiFareController.java index c39be88059..7de88d44a8 100644 --- a/spring-rest/src/main/java/com/baeldung/web/log/controller/TaxiFareController.java +++ b/spring-rest/src/main/java/com/baeldung/web/log/controller/TaxiFareController.java @@ -14,8 +14,9 @@ import org.springframework.web.bind.annotation.ResponseBody; import com.baeldung.web.log.data.RateCard; import com.baeldung.web.log.data.TaxiRide; import com.baeldung.web.log.service.TaxiFareCalculatorService; +import org.springframework.web.bind.annotation.RestController; -@Controller +@RestController public class TaxiFareController { @Autowired @@ -23,15 +24,13 @@ public class TaxiFareController { private static final Logger LOGGER = LoggerFactory.getLogger(TaxiFareController.class); - @GetMapping(value = "/taxifare/get/") - @ResponseBody + @GetMapping("/taxifare/get/") public RateCard getTaxiFare() { LOGGER.debug("getTaxiFare() - START"); return new RateCard(); } - @PostMapping(value = "/taxifare/calculate/") - @ResponseBody + @PostMapping("/taxifare/calculate/") public String calculateTaxiFare(@RequestBody @Valid TaxiRide taxiRide) { LOGGER.debug("calculateTaxiFare() - START"); String totalFare = taxiFareCalculatorService.calculateFare(taxiRide); diff --git a/spring-rest/src/main/java/com/baeldung/web/log/data/RateCard.java b/spring-rest/src/main/java/com/baeldung/web/log/data/RateCard.java index 35ae38fd11..c7955b561b 100644 --- a/spring-rest/src/main/java/com/baeldung/web/log/data/RateCard.java +++ b/spring-rest/src/main/java/com/baeldung/web/log/data/RateCard.java @@ -4,25 +4,28 @@ public class RateCard { private String nightSurcharge; private String ratePerMile; - - public RateCard(){ - nightSurcharge="Extra $ 100"; - ratePerMile="$ 10 Per Mile"; + + public RateCard() { + nightSurcharge = "Extra $ 100"; + ratePerMile = "$ 10 Per Mile"; } - - + + public String getNightSurcharge() { return nightSurcharge; } + public void setNightSurcharge(String nightSurcharge) { this.nightSurcharge = nightSurcharge; } + public String getRatePerMile() { return ratePerMile; } + public void setRatePerMile(String ratePerMile) { this.ratePerMile = ratePerMile; } - - + + } diff --git a/spring-rest/src/main/java/com/baeldung/web/log/data/TaxiRide.java b/spring-rest/src/main/java/com/baeldung/web/log/data/TaxiRide.java index 0877cdced4..2e0f33f02b 100644 --- a/spring-rest/src/main/java/com/baeldung/web/log/data/TaxiRide.java +++ b/spring-rest/src/main/java/com/baeldung/web/log/data/TaxiRide.java @@ -5,14 +5,15 @@ public class TaxiRide { private Boolean isNightSurcharge; private Long distanceInMile; - public TaxiRide(){} - - public TaxiRide(Boolean isNightSurcharge, Long distanceInMile){ + public TaxiRide() { + } + + public TaxiRide(Boolean isNightSurcharge, Long distanceInMile) { this.isNightSurcharge = isNightSurcharge; this.distanceInMile = distanceInMile; } - - + + public Boolean getIsNightSurcharge() { return isNightSurcharge; } diff --git a/spring-rest/src/main/java/com/baeldung/web/log/service/TaxiFareCalculatorService.java b/spring-rest/src/main/java/com/baeldung/web/log/service/TaxiFareCalculatorService.java index ec9c81187a..1176b31e4c 100644 --- a/spring-rest/src/main/java/com/baeldung/web/log/service/TaxiFareCalculatorService.java +++ b/spring-rest/src/main/java/com/baeldung/web/log/service/TaxiFareCalculatorService.java @@ -1,20 +1,14 @@ package com.baeldung.web.log.service; -import org.springframework.stereotype.Service; - import com.baeldung.web.log.data.TaxiRide; +import org.springframework.stereotype.Service; @Service public class TaxiFareCalculatorService { public String calculateFare(TaxiRide taxiRide) { - Long fare = 0l; - if (taxiRide.getIsNightSurcharge()) { - fare = taxiRide.getDistanceInMile() * 10 + 100; - } else { - fare = taxiRide.getDistanceInMile() * 10; - } - return String.valueOf(fare); + return String.valueOf((Long) (taxiRide.getIsNightSurcharge() + ? taxiRide.getDistanceInMile() * 10 + 100 + : taxiRide.getDistanceInMile() * 10)); } - } diff --git a/spring-rest/src/main/java/org/baeldung/config/MainApplication.java b/spring-rest/src/main/java/org/baeldung/config/MainApplication.java index e31fdfaaa9..36b021a537 100644 --- a/spring-rest/src/main/java/org/baeldung/config/MainApplication.java +++ b/spring-rest/src/main/java/org/baeldung/config/MainApplication.java @@ -12,5 +12,4 @@ public class MainApplication extends WebMvcConfigurerAdapter { public static void main(final String[] args) { SpringApplication.run(MainApplication.class, args); } - } \ No newline at end of file diff --git a/spring-rest/src/main/java/org/baeldung/repository/HeavyResourceRepository.java b/spring-rest/src/main/java/org/baeldung/repository/HeavyResourceRepository.java index 4ed5c21b83..e4eb6d8875 100644 --- a/spring-rest/src/main/java/org/baeldung/repository/HeavyResourceRepository.java +++ b/spring-rest/src/main/java/org/baeldung/repository/HeavyResourceRepository.java @@ -1,11 +1,11 @@ package org.baeldung.repository; -import java.util.Map; - import org.baeldung.web.dto.HeavyResource; import org.baeldung.web.dto.HeavyResourceAddressOnly; -public class HeavyResourceRepository { +import java.util.Map; + +public class HeavyResourceRepository { public void save(HeavyResource heavyResource) { } @@ -21,6 +21,7 @@ public class HeavyResourceRepository { public void save(HeavyResource heavyResource, String id) { } + public void save(HeavyResourceAddressOnly partialUpdate, String id) { } From c5f029b46c3f916130dbc0d7afb94e054a108a19 Mon Sep 17 00:00:00 2001 From: Ante Pocedulic Date: Sat, 29 Jul 2017 16:16:23 +0200 Subject: [PATCH 83/89] - added custom theme for asciidoc book (#2327) - changed AsciiDoc document - added new things in pom --- asciidoctor/pom.xml | 5 +++++ asciidoctor/src/docs/asciidoc/test.adoc | 14 ++++++++++-- asciidoctor/src/themes/custom-theme.yml | 29 +++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 asciidoctor/src/themes/custom-theme.yml diff --git a/asciidoctor/pom.xml b/asciidoctor/pom.xml index 989f6e5354..a602cd11b9 100644 --- a/asciidoctor/pom.xml +++ b/asciidoctor/pom.xml @@ -35,7 +35,12 @@ src/docs/asciidoc target/docs/asciidoc + + ${project.basedir}/src/themes + custom + pdf + book diff --git a/asciidoctor/src/docs/asciidoc/test.adoc b/asciidoctor/src/docs/asciidoc/test.adoc index 5a86a00440..fec1f73584 100644 --- a/asciidoctor/src/docs/asciidoc/test.adoc +++ b/asciidoctor/src/docs/asciidoc/test.adoc @@ -1,3 +1,13 @@ -== Introduction Section +:icons: font -Hi. I'm a simple test to see if this Maven build is working. If you see me in a nice PDF, then it means everything is [red]#working#. \ No newline at end of file + += Generating book with AsciiDoctorj +Baeldung + +[abstract] +This is the actual content. + +== First Section + +This is first section of the book where you can include some nice icons like icon:comment[]. +You can also create http://www.baeldung.com[links] diff --git a/asciidoctor/src/themes/custom-theme.yml b/asciidoctor/src/themes/custom-theme.yml new file mode 100644 index 0000000000..a3c8c00510 --- /dev/null +++ b/asciidoctor/src/themes/custom-theme.yml @@ -0,0 +1,29 @@ +title_page: + align: left + +page: + layout: portrait + margin: [0.75in, 1in, 0.75in, 1in] + size: A4 +base: + font_color: #333333 + line_height_length: 17 + line_height: $base_line_height_length / $base_font_size +link: + font_color: #009900 + +header: + height: 0.5in + line_height: 1 + recto_content: + center: '{document-title}' + verso_content: + center: '{document-title}' + +footer: + height: 0.5in + line_height: 1 + recto_content: + right: '{chapter-title} | *{page-number}*' + verso_content: + left: '*{page-number}* | {chapter-title}' \ No newline at end of file From ae33aa6386ce0947389c94fe189c5cb0e786efef Mon Sep 17 00:00:00 2001 From: Seun Matt Date: Sat, 29 Jul 2017 15:44:40 +0100 Subject: [PATCH 84/89] Refactored tests for PCollections (#2331) * added updated example codes * updated example code StringToCharStream * deleted StringToCharStream.java locally * removed redundant file * added code for apache commons collection SetUtils * refactored example code * added example code for bytebuddy * added example code for PCollections * update pom * refactored tests for PCollections --- .../pcollections/PCollectionsUnitTest.java | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/libraries/src/test/java/com/baeldung/pcollections/PCollectionsUnitTest.java b/libraries/src/test/java/com/baeldung/pcollections/PCollectionsUnitTest.java index b2f815074a..23f9abf2f3 100644 --- a/libraries/src/test/java/com/baeldung/pcollections/PCollectionsUnitTest.java +++ b/libraries/src/test/java/com/baeldung/pcollections/PCollectionsUnitTest.java @@ -39,41 +39,41 @@ public class PCollectionsUnitTest { public void whenHashPMapMethods_thenPerformOperations() { HashPMap pmap = HashTreePMap.empty(); - pmap = pmap.plus("key1", "value1"); - assertEquals(pmap.size(), 1); + HashPMap pmap0 = pmap.plus("key1", "value1"); Map map = new HashMap(); map.put("key2", "val2"); map.put("key3", "val3"); - pmap = pmap.plusAll(map); - assertEquals(pmap.size(), 3); - - pmap = pmap.minus("key1"); - assertFalse(pmap.containsKey("key1")); - - pmap = pmap.minusAll(map.keySet()); - assertEquals(pmap.size(), 0); + HashPMap pmap1 = pmap0.plusAll(map); + HashPMap pmap2 = pmap1.minus("key1"); + HashPMap pmap3 = pmap2.minusAll(map.keySet()); + assertEquals(pmap0.size(), 1); + assertEquals(pmap1.size(), 3); + assertFalse(pmap2.containsKey("key1")); + assertEquals(pmap3.size(), 0); } @Test public void whenTreePVectorMethods_thenPerformOperations() { TreePVector pVector = TreePVector.empty(); - pVector = pVector.plus("e1"); - pVector = pVector.plusAll(Arrays.asList("e2", "e3", "e4")); - assertEquals(4, pVector.size()); + TreePVector pV1 = pVector.plus("e1"); + TreePVector pV2 = pV1.plusAll(Arrays.asList("e2", "e3", "e4")); + assertEquals(1, pV1.size()); + assertEquals(4, pV2.size()); - TreePVector pSub = pVector.subList(0, 2); + TreePVector pV3 = pV2.minus("e1"); + TreePVector pV4 = pV3.minusAll(Arrays.asList("e2", "e3", "e4")); + assertEquals(pV3.size(), 3); + assertEquals(pV4.size(), 0); + + TreePVector pSub = pV2.subList(0, 2); assertTrue(pSub.contains("e1") && pSub.contains("e2")); - TreePVector pVW = (TreePVector) pVector.with(0, "e10"); + TreePVector pVW = (TreePVector) pV2.with(0, "e10"); assertEquals(pVW.get(0), "e10"); - - pVector = pVector.minus("e1"); - TreePVector pV1 = pVector.minusAll(Arrays.asList("e2", "e3")); - assertEquals(pV1.size(), 1); } @Test @@ -83,9 +83,8 @@ public class PCollectionsUnitTest { .plusAll(Arrays.asList("e1","e2","e3","e4")); assertEquals(pSet.size(), 4); - pSet = pSet.minus("e4"); - assertFalse(pSet.contains("e4")); - + MapPSet pSet1 = pSet.minus("e4"); + assertFalse(pSet1.contains("e4")); } } From 5c1bf55e34f8ffb8db2d803b7796f653bbfbab04 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 29 Jul 2017 17:45:12 +0300 Subject: [PATCH 85/89] minor cleanup work --- feign/pom.xml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/feign/pom.xml b/feign/pom.xml index 9c3868c82f..78e1bbcf4c 100644 --- a/feign/pom.xml +++ b/feign/pom.xml @@ -1,12 +1,9 @@ - + 4.0.0 com.baeldung.feign feign-client - 1.0.0-SNAPSHOT com.baeldung From 244a678b463a43ea150c200d2966dda6d0222f52 Mon Sep 17 00:00:00 2001 From: Abhinab Kanrar Date: Sat, 29 Jul 2017 20:26:24 +0530 Subject: [PATCH 86/89] jooby project (#2330) * moving jmh into libraries module * refactoring jmh * Update pom.xml * manual algorightm * with BM result * fix for space issue * Fixed indentation * change as per suggestion * vavr either * adding unit test and othe rutilities * adding concurrent module * concurrent package description * concurrent package description * Update EitherUnitTest.java * introducing lambda expression * jooby project * jooby project --- .../cyclicbarrier/CyclicBarrierExample.java | 1 + jooby/conf/application.conf | 2 + jooby/conf/logback.xml | 42 ++++++++ jooby/pom.xml | 56 +++++++++++ jooby/public/form.html | 17 ++++ jooby/public/welcome.html | 10 ++ jooby/src/etc/stork.yml | 41 ++++++++ .../src/main/java/com/baeldung/jooby/App.java | 95 +++++++++++++++++++ .../com/baeldung/jooby/bean/Employee.java | 20 ++++ .../com/baeldung/jooby/mvc/GetController.java | 22 +++++ .../baeldung/jooby/mvc/PostController.java | 14 +++ .../test/java/com/baeldung/jooby/AppTest.java | 29 ++++++ 12 files changed, 349 insertions(+) create mode 100644 jooby/conf/application.conf create mode 100644 jooby/conf/logback.xml create mode 100644 jooby/pom.xml create mode 100644 jooby/public/form.html create mode 100644 jooby/public/welcome.html create mode 100644 jooby/src/etc/stork.yml create mode 100644 jooby/src/main/java/com/baeldung/jooby/App.java create mode 100644 jooby/src/main/java/com/baeldung/jooby/bean/Employee.java create mode 100644 jooby/src/main/java/com/baeldung/jooby/mvc/GetController.java create mode 100644 jooby/src/main/java/com/baeldung/jooby/mvc/PostController.java create mode 100644 jooby/src/test/java/com/baeldung/jooby/AppTest.java diff --git a/core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierExample.java b/core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierExample.java index dd80a7971c..a9b92d9f4a 100644 --- a/core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierExample.java +++ b/core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierExample.java @@ -21,3 +21,4 @@ public class CyclicBarrierExample { } } } + diff --git a/jooby/conf/application.conf b/jooby/conf/application.conf new file mode 100644 index 0000000000..2f89e0eb6b --- /dev/null +++ b/jooby/conf/application.conf @@ -0,0 +1,2 @@ +#application.secret = 2o128940921eo298e21 +#db = /url/to/the/datastore \ No newline at end of file diff --git a/jooby/conf/logback.xml b/jooby/conf/logback.xml new file mode 100644 index 0000000000..50733ee6d6 --- /dev/null +++ b/jooby/conf/logback.xml @@ -0,0 +1,42 @@ + + + + + [%d{ISO8601}]-[%thread] %-5level %logger - %msg%n + + + + + log/jooby.log + + log/jooby.%d{yyyy-MM-dd}.log + 1mb + 7 + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n + + + + + log/access.log + + log/access.%d{yyyy-MM-dd}.log + 1mb + 7 + + + + %msg%n + + + + + + + + + + + diff --git a/jooby/pom.xml b/jooby/pom.xml new file mode 100644 index 0000000000..1935c646ee --- /dev/null +++ b/jooby/pom.xml @@ -0,0 +1,56 @@ + + + 4.0.0 + jooby + com.baeldung.jooby + 1.0 + jooby + + + org.jooby + modules + 1.1.3 + + + + 1.1.3 + com.baeldung.jooby.App + + + + + org.jooby + jooby-netty + + + org.jooby + jooby-jedis + 1.1.3 + + + ch.qos.logback + logback-classic + + + junit + junit + test + + + io.rest-assured + rest-assured + test + + + + + + + org.apache.maven.plugins + maven-shade-plugin + + + + + diff --git a/jooby/public/form.html b/jooby/public/form.html new file mode 100644 index 0000000000..a23620812a --- /dev/null +++ b/jooby/public/form.html @@ -0,0 +1,17 @@ + + + + +Insert title here + + +
+ + + + + + +
+ + \ No newline at end of file diff --git a/jooby/public/welcome.html b/jooby/public/welcome.html new file mode 100644 index 0000000000..cd21fb1988 --- /dev/null +++ b/jooby/public/welcome.html @@ -0,0 +1,10 @@ + + + + +Insert title here + + +i m welcomed + + \ No newline at end of file diff --git a/jooby/src/etc/stork.yml b/jooby/src/etc/stork.yml new file mode 100644 index 0000000000..f2f2790cd1 --- /dev/null +++ b/jooby/src/etc/stork.yml @@ -0,0 +1,41 @@ +# Name of application (make sure it has no spaces) +name: "${project.artifactId}" + +# Display name of application (can have spaces) +display_name: "${project.name}" + +# Type of launcher (CONSOLE or DAEMON) +type: DAEMON + +# Java class to run +main_class: "${application.class}" + +domain: "${project.groupId}" + +short_description: "${project.artifactId}" + +# Platform launchers to generate (WINDOWS, LINUX, MAC_OSX) +# Linux launcher is suitable for Bourne shells (e.g. Linux/BSD) +platforms: [ LINUX ] + +# Working directory for app +# RETAIN will not change the working directory +# APP_HOME will change the working directory to the home of the app +# (where it was intalled) before running the main class +working_dir_mode: RETAIN + +# Minimum version of java required (system will be searched for acceptable jvm) +min_java_version: "1.8" + +# Min/max fixed memory (measured in MB) +min_java_memory: 512 +max_java_memory: 512 + +# Min/max memory by percentage of system +#min_java_memory_pct: 10 +#max_java_memory_pct: 20 + +# Try to create a symbolic link to java executable in /run with +# the name of "-java" so that commands like "ps" will make it +# easier to find your app +symlink_java: true diff --git a/jooby/src/main/java/com/baeldung/jooby/App.java b/jooby/src/main/java/com/baeldung/jooby/App.java new file mode 100644 index 0000000000..94a24048c2 --- /dev/null +++ b/jooby/src/main/java/com/baeldung/jooby/App.java @@ -0,0 +1,95 @@ +package com.baeldung.jooby; + +import org.jooby.Jooby; +import org.jooby.Mutant; +import org.jooby.Session; +import org.jooby.jedis.Redis; +import org.jooby.jedis.RedisSessionStore; + +import com.baeldung.jooby.bean.Employee; + +public class App extends Jooby { + + { + port(8080); + securePort(8443); + } + + { + get("/", () -> "Hello World!"); + } + + { + get("/user/{id}", req -> "Hello user : " + req.param("id").value()); + get("/user/:id", req -> "Hello user: " + req.param("id").value()); + get("/uid:{id}", req -> "Hello User with id : uid" + req.param("id").value()); + } + + { + onStart(() -> { + System.out.println("starting app"); + }); + + onStop(() -> { + System.out.println("stopping app"); + }); + + onStarted(() -> { + System.out.println("app started"); + }); + } + + { + get("/login", () -> "Hello from Baeldung"); + } + + { + post("/save", req -> { + Mutant token = req.param("token"); + return token.intValue(); + }); + } + + { + { + assets("/employee", "form.html"); + } + + post("/submitForm", req -> { + Employee employee = req.params(Employee.class); + // TODO + return "empoyee data saved successfullly"; + }); + } + + { + get("/filter", (req, resp, chain) -> { + // TODO + // resp.send(...); + chain.next(req, resp); + }); + get("/filter", (req, resp) -> { + resp.send("filter response"); + }); + } + + { +// cookieSession(); + +// use(new Redis()); +// +// session(RedisSessionStore.class); + + get("/session", req -> { + Session session = req.session(); + session.set("token", "value"); + return session.get("token").value(); + }); + } + + public static void main(final String[] args) { + + run(App::new, args); + } + +} diff --git a/jooby/src/main/java/com/baeldung/jooby/bean/Employee.java b/jooby/src/main/java/com/baeldung/jooby/bean/Employee.java new file mode 100644 index 0000000000..6e18495ef1 --- /dev/null +++ b/jooby/src/main/java/com/baeldung/jooby/bean/Employee.java @@ -0,0 +1,20 @@ +package com.baeldung.jooby.bean; + +public class Employee { + + String id; + String name; + String email; + String phone; + String address; + + public Employee(String id, String name, String email, String phone, String address) { + super(); + this.id = id; + this.name = name; + this.email = email; + this.phone = phone; + this.address = address; + } + +} diff --git a/jooby/src/main/java/com/baeldung/jooby/mvc/GetController.java b/jooby/src/main/java/com/baeldung/jooby/mvc/GetController.java new file mode 100644 index 0000000000..a2c51bae70 --- /dev/null +++ b/jooby/src/main/java/com/baeldung/jooby/mvc/GetController.java @@ -0,0 +1,22 @@ +package com.baeldung.jooby.mvc; + +import org.jooby.Result; +import org.jooby.Results; +import org.jooby.mvc.GET; +import org.jooby.mvc.Path; + +@Path("/hello") +public class GetController { + + @GET + public String hello() { + return "Hello Baeldung"; + } + + @GET + @Path("/home") + public Result home() { + return Results.html("welcome").put("model", new Object()); + } + +} diff --git a/jooby/src/main/java/com/baeldung/jooby/mvc/PostController.java b/jooby/src/main/java/com/baeldung/jooby/mvc/PostController.java new file mode 100644 index 0000000000..df00e47da5 --- /dev/null +++ b/jooby/src/main/java/com/baeldung/jooby/mvc/PostController.java @@ -0,0 +1,14 @@ +package com.baeldung.jooby.mvc; + +import org.jooby.mvc.POST; +import org.jooby.mvc.Path; + +@Path("/submit") +public class PostController { + + @POST + public String hello() { + return "Submit Baeldung"; + } + +} diff --git a/jooby/src/test/java/com/baeldung/jooby/AppTest.java b/jooby/src/test/java/com/baeldung/jooby/AppTest.java new file mode 100644 index 0000000000..af2626c046 --- /dev/null +++ b/jooby/src/test/java/com/baeldung/jooby/AppTest.java @@ -0,0 +1,29 @@ +package com.baeldung.jooby; + +import static io.restassured.RestAssured.get; +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertEquals; + +import org.jooby.test.JoobyRule; +import org.jooby.test.MockRouter; +import org.junit.ClassRule; +import org.junit.Test; + +public class AppTest { + + @ClassRule + public static JoobyRule app = new JoobyRule(new App()); + + @Test + public void given_defaultUrl_expect_fixedString() { + get("/").then().assertThat().body(equalTo("Hello World!")).statusCode(200) + .contentType("text/html;charset=UTF-8"); + } + + @Test + public void given_defaultUrl_with_mockrouter_expect_fixedString() throws Throwable { + String result = new MockRouter(new App()).get("/"); + assertEquals("Hello World!", result); + } + +} From fd6e7c51fc4cf2f7284cadca7da0dae9332078c9 Mon Sep 17 00:00:00 2001 From: Abhinab Kanrar Date: Sun, 30 Jul 2017 01:18:06 +0530 Subject: [PATCH 87/89] reducing employee bean content (#2332) * moving jmh into libraries module * refactoring jmh * Update pom.xml * manual algorightm * with BM result * fix for space issue * Fixed indentation * change as per suggestion * vavr either * adding unit test and othe rutilities * adding concurrent module * concurrent package description * concurrent package description * Update EitherUnitTest.java * introducing lambda expression * jooby project * jooby project * reducing employee bean content --- jooby/src/main/java/com/baeldung/jooby/bean/Employee.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/jooby/src/main/java/com/baeldung/jooby/bean/Employee.java b/jooby/src/main/java/com/baeldung/jooby/bean/Employee.java index 6e18495ef1..2c4a1038b5 100644 --- a/jooby/src/main/java/com/baeldung/jooby/bean/Employee.java +++ b/jooby/src/main/java/com/baeldung/jooby/bean/Employee.java @@ -5,16 +5,12 @@ public class Employee { String id; String name; String email; - String phone; - String address; - public Employee(String id, String name, String email, String phone, String address) { + public Employee(String id, String name, String email) { super(); this.id = id; this.name = name; this.email = email; - this.phone = phone; - this.address = address; } } From 9f45d709db9ad7144614e78d0c19124f468e40ad Mon Sep 17 00:00:00 2001 From: baljeet20 Date: Sun, 30 Jul 2017 01:50:14 +0530 Subject: [PATCH 88/89] BAEL-1024 introduction to mock server (#2333) * review changes * BAEL-1024 Removed the proxy reference * BAEL-1024 Renamed methods --- .../java/com/baeldung/mock/server/MockServerLiveTest.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mockserver/src/test/java/com/baeldung/mock/server/MockServerLiveTest.java b/mockserver/src/test/java/com/baeldung/mock/server/MockServerLiveTest.java index 56d354be7f..e7b972f6a4 100644 --- a/mockserver/src/test/java/com/baeldung/mock/server/MockServerLiveTest.java +++ b/mockserver/src/test/java/com/baeldung/mock/server/MockServerLiveTest.java @@ -28,13 +28,11 @@ import static org.mockserver.model.StringBody.exact; public class MockServerLiveTest { - private static ClientAndProxy proxy; private static ClientAndServer mockServer; @BeforeClass - public static void startProxy() { + public static void startServer() { mockServer = startClientAndServer(1080); - proxy = startClientAndProxy(1090); } @@ -169,8 +167,7 @@ public class MockServerLiveTest { } @AfterClass - public static void stopProxy() { - proxy.stop(); + public static void stopServer() { mockServer.stop(); } } From f445a4d11bdb58a5d14a98166092344a04b64942 Mon Sep 17 00:00:00 2001 From: Jose Carvajal Date: Sun, 30 Jul 2017 00:29:25 +0200 Subject: [PATCH 89/89] BAEL-373: Improve/Upgrade existing Mockito articles to Mockito 2 (#2311) * BAEL-373: Improve/Upgrade existing Mockito articles to Mockito 2 * Fix formatting issue with LoginControllerIntegrationTest --- core-java/pom.xml | 4 +- .../MappedByteBufferUnitTest.java | 2 +- .../com/baeldung/money/JavaMoneyUnitTest.java | 2 +- .../baeldung/java/io/JavaScannerUnitTest.java | 2 + mockito/pom.xml | 4 +- mockito2/pom.xml | 2 +- mocks/mock-comparisons/pom.xml | 2 +- .../LoginControllerIntegrationTest.java | 67 +++++++++++++------ pom.xml | 2 +- video-tutorials/jackson-annotations/pom.xml | 2 +- 10 files changed, 57 insertions(+), 32 deletions(-) diff --git a/core-java/pom.xml b/core-java/pom.xml index ee0d6b4b4a..78338fc439 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -382,7 +382,7 @@
- + 2.8.5 @@ -408,7 +408,7 @@ 1.3 4.12 - 1.10.19 + 2.8.9 3.6.1 1.7.0 diff --git a/core-java/src/test/java/com/baeldung/mappedbytebuffer/MappedByteBufferUnitTest.java b/core-java/src/test/java/com/baeldung/mappedbytebuffer/MappedByteBufferUnitTest.java index 3c2d9904d4..0a0993a0d7 100644 --- a/core-java/src/test/java/com/baeldung/mappedbytebuffer/MappedByteBufferUnitTest.java +++ b/core-java/src/test/java/com/baeldung/mappedbytebuffer/MappedByteBufferUnitTest.java @@ -63,6 +63,6 @@ public class MappedByteBufferUnitTest { private Path getFileURIFromResources(String fileName) throws Exception { ClassLoader classLoader = getClass().getClassLoader(); - return Paths.get(classLoader.getResource(fileName).getPath()); + return Paths.get(classLoader.getResource(fileName).toURI()); } } diff --git a/core-java/src/test/java/com/baeldung/money/JavaMoneyUnitTest.java b/core-java/src/test/java/com/baeldung/money/JavaMoneyUnitTest.java index 8948d1ebf7..3d52a9eea9 100644 --- a/core-java/src/test/java/com/baeldung/money/JavaMoneyUnitTest.java +++ b/core-java/src/test/java/com/baeldung/money/JavaMoneyUnitTest.java @@ -179,7 +179,7 @@ public class JavaMoneyUnitTest { MonetaryAmountFormat customFormat = MonetaryFormats.getAmountFormat(AmountFormatQueryBuilder .of(Locale.US) .set(CurrencyStyle.NAME) - .set("pattern", "00000.00 ¤") + .set("pattern", "00000.00 ") .build()); String customFormatted = customFormat.format(oneDollar); diff --git a/core-java/src/test/java/org/baeldung/java/io/JavaScannerUnitTest.java b/core-java/src/test/java/org/baeldung/java/io/JavaScannerUnitTest.java index 5af286dbca..1c16a5d435 100644 --- a/core-java/src/test/java/org/baeldung/java/io/JavaScannerUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/io/JavaScannerUnitTest.java @@ -11,6 +11,7 @@ import java.io.FileInputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; +import java.util.Locale; import java.util.Scanner; import org.junit.Test; @@ -105,6 +106,7 @@ public class JavaScannerUnitTest { public void whenScanString_thenCorrect() throws IOException { final String input = "Hello 1 F 3.5"; final Scanner scanner = new Scanner(input); + scanner.useLocale(Locale.US); assertEquals("Hello", scanner.next()); assertEquals(1, scanner.nextInt()); diff --git a/mockito/pom.xml b/mockito/pom.xml index c77d42f97d..19dd2f6468 100644 --- a/mockito/pom.xml +++ b/mockito/pom.xml @@ -41,7 +41,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 ${powermock.version} test @@ -65,7 +65,7 @@ 3.5 - 1.6.6 + 1.7.0 diff --git a/mockito2/pom.xml b/mockito2/pom.xml index 523cfa816d..a7c4683c30 100644 --- a/mockito2/pom.xml +++ b/mockito2/pom.xml @@ -53,6 +53,6 @@ UTF-8 - 2.7.5 + 2.8.9 diff --git a/mocks/mock-comparisons/pom.xml b/mocks/mock-comparisons/pom.xml index 2ab35651f1..e350457f54 100644 --- a/mocks/mock-comparisons/pom.xml +++ b/mocks/mock-comparisons/pom.xml @@ -13,7 +13,7 @@ mock-comparisons - 1.10.19 + 2.8.9 3.4 1.29 diff --git a/mocks/mock-comparisons/src/test/java/org/baeldung/mocks/mockito/LoginControllerIntegrationTest.java b/mocks/mock-comparisons/src/test/java/org/baeldung/mocks/mockito/LoginControllerIntegrationTest.java index 18bc2ae189..8f8918ab22 100644 --- a/mocks/mock-comparisons/src/test/java/org/baeldung/mocks/mockito/LoginControllerIntegrationTest.java +++ b/mocks/mock-comparisons/src/test/java/org/baeldung/mocks/mockito/LoginControllerIntegrationTest.java @@ -7,7 +7,12 @@ import org.baeldung.mocks.testCase.UserForm; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.mockito.*; +import org.mockito.ArgumentMatcher; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.mockito.Spy; public class LoginControllerIntegrationTest { @@ -41,50 +46,63 @@ public class LoginControllerIntegrationTest { public void assertTwoMethodsHaveBeenCalled() { UserForm userForm = new UserForm(); userForm.username = "foo"; - Mockito.when(loginService.login(userForm)).thenReturn(true); + Mockito.when(loginService.login(userForm)) + .thenReturn(true); String login = loginController.login(userForm); Assert.assertEquals("OK", login); - Mockito.verify(loginService).login(userForm); - Mockito.verify(loginService).setCurrentUser("foo"); + Mockito.verify(loginService) + .login(userForm); + Mockito.verify(loginService) + .setCurrentUser("foo"); } @Test public void assertOnlyOneMethodHasBeenCalled() { UserForm userForm = new UserForm(); userForm.username = "foo"; - Mockito.when(loginService.login(userForm)).thenReturn(false); + Mockito.when(loginService.login(userForm)) + .thenReturn(false); String login = loginController.login(userForm); Assert.assertEquals("KO", login); - Mockito.verify(loginService).login(userForm); + Mockito.verify(loginService) + .login(userForm); Mockito.verifyNoMoreInteractions(loginService); } @Test public void mockExceptionThrowing() { UserForm userForm = new UserForm(); - Mockito.when(loginService.login(userForm)).thenThrow(IllegalArgumentException.class); + Mockito.when(loginService.login(userForm)) + .thenThrow(IllegalArgumentException.class); String login = loginController.login(userForm); Assert.assertEquals("ERROR", login); - Mockito.verify(loginService).login(userForm); + Mockito.verify(loginService) + .login(userForm); Mockito.verifyZeroInteractions(loginService); } @Test public void mockAnObjectToPassAround() { - UserForm userForm = Mockito.when(Mockito.mock(UserForm.class).getUsername()).thenReturn("foo").getMock(); - Mockito.when(loginService.login(userForm)).thenReturn(true); + UserForm userForm = Mockito.when(Mockito.mock(UserForm.class) + .getUsername()) + .thenReturn("foo") + .getMock(); + Mockito.when(loginService.login(userForm)) + .thenReturn(true); String login = loginController.login(userForm); Assert.assertEquals("OK", login); - Mockito.verify(loginService).login(userForm); - Mockito.verify(loginService).setCurrentUser("foo"); + Mockito.verify(loginService) + .login(userForm); + Mockito.verify(loginService) + .setCurrentUser("foo"); } @Test @@ -92,19 +110,22 @@ public class LoginControllerIntegrationTest { UserForm userForm = new UserForm(); userForm.username = "foo"; // default matcher - Mockito.when(loginService.login(Mockito.any(UserForm.class))).thenReturn(true); + Mockito.when(loginService.login(Mockito.any(UserForm.class))) + .thenReturn(true); String login = loginController.login(userForm); Assert.assertEquals("OK", login); - Mockito.verify(loginService).login(userForm); + Mockito.verify(loginService) + .login(userForm); // complex matcher - Mockito.verify(loginService).setCurrentUser(Mockito.argThat(new ArgumentMatcher() { - @Override - public boolean matches(Object argument) { - return argument instanceof String && ((String) argument).startsWith("foo"); - } - })); + Mockito.verify(loginService) + .setCurrentUser(Mockito.argThat(new ArgumentMatcher() { + @Override + public boolean matches(String argument) { + return argument.startsWith("foo"); + } + })); } @Test @@ -114,12 +135,14 @@ public class LoginControllerIntegrationTest { UserForm userForm = new UserForm(); userForm.username = "foo"; // let service's login use implementation so let's mock DAO call - Mockito.when(loginDao.login(userForm)).thenReturn(1); + Mockito.when(loginDao.login(userForm)) + .thenReturn(1); String login = loginController.login(userForm); Assert.assertEquals("OK", login); // verify mocked call - Mockito.verify(spiedLoginService).setCurrentUser("foo"); + Mockito.verify(spiedLoginService) + .setCurrentUser("foo"); } } diff --git a/pom.xml b/pom.xml index fa6a3e5673..6641155044 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ 4.12 1.3 - 1.10.19 + 2.8.9 1.7.21 1.1.7 diff --git a/video-tutorials/jackson-annotations/pom.xml b/video-tutorials/jackson-annotations/pom.xml index 853c84a1b8..e44611fab0 100644 --- a/video-tutorials/jackson-annotations/pom.xml +++ b/video-tutorials/jackson-annotations/pom.xml @@ -164,7 +164,7 @@ 2.5 - 2.2.26 + 2.8.9 4.4.1 4.5