Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.
Prev Previous commit
Next Next commit
Reformatting the code.. #96
  • Loading branch information
visweshwar committed Jun 2, 2019
commit d74bad09c8dcab4916eebb7f77f2f98c436647d7
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ public void setMaxInactiveIntervalInSeconds(Integer maxInactiveIntervalInSeconds

public void setImportMetadata(AnnotationMetadata importMetadata) {

AnnotationAttributes attributes = AnnotationAttributes.fromMap(
importMetadata.getAnnotationAttributes(EnableMongoHttpSession.class.getName()));
AnnotationAttributes attributes = AnnotationAttributes
.fromMap(importMetadata.getAnnotationAttributes(EnableMongoHttpSession.class.getName()));

if (attributes != null) {
this.maxInactiveIntervalInSeconds = attributes.getNumber("maxInactiveIntervalInSeconds");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,21 @@
*/
package org.springframework.session.data.mongo.config.annotation.web.http;

import static org.assertj.core.api.Assertions.*;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.BDDMockito.*;


import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.context.annotation.*;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Primary;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.index.IndexOperations;
Expand All @@ -29,12 +38,6 @@
import org.springframework.session.data.mongo.MongoOperationsSessionRepository;
import org.springframework.test.util.ReflectionTestUtils;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.mock;

/**
* Tests for {@link MongoHttpSessionConfiguration}.
*
Expand All @@ -47,8 +50,7 @@ public class MongoHttpSessionConfigurationTest {

private static final int MAX_INACTIVE_INTERVAL_IN_SECONDS = 600;

@Rule
public final ExpectedException thrown = ExpectedException.none();
@Rule public final ExpectedException thrown = ExpectedException.none();

private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();

Expand Down Expand Up @@ -106,8 +108,8 @@ public void customMaxInactiveIntervalInSeconds() {
MongoOperationsSessionRepository repository = this.context.getBean(MongoOperationsSessionRepository.class);

assertThat(repository).isNotNull();
assertThat(ReflectionTestUtils.getField(repository, "maxInactiveIntervalInSeconds")).isEqualTo(
MAX_INACTIVE_INTERVAL_IN_SECONDS);
assertThat(ReflectionTestUtils.getField(repository, "maxInactiveIntervalInSeconds"))
.isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS);
}

@Test
Expand All @@ -118,8 +120,8 @@ public void setCustomMaxInactiveIntervalInSeconds() {
MongoOperationsSessionRepository repository = this.context.getBean(MongoOperationsSessionRepository.class);

assertThat(repository).isNotNull();
assertThat(ReflectionTestUtils.getField(repository, "maxInactiveIntervalInSeconds")).isEqualTo(
MAX_INACTIVE_INTERVAL_IN_SECONDS);
assertThat(ReflectionTestUtils.getField(repository, "maxInactiveIntervalInSeconds"))
.isEqualTo(MAX_INACTIVE_INTERVAL_IN_SECONDS);
}

@Test
Expand All @@ -138,8 +140,7 @@ public void setCustomSessionConverterConfiguration() {
@Test
public void resolveCollectionNameByPropertyPlaceholder() {

this.context.setEnvironment(
new MockEnvironment().withProperty("session.mongo.collectionName", COLLECTION_NAME));
this.context.setEnvironment(new MockEnvironment().withProperty("session.mongo.collectionName", COLLECTION_NAME));
registerAndRefresh(CustomMongoJdbcSessionConfiguration.class);

MongoHttpSessionConfiguration configuration = this.context.getBean(MongoHttpSessionConfiguration.class);
Expand Down