Skip to content

Commit

Permalink
#19.: remove empty source file and public keyword in test files
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuqiu Ge committed Jul 4, 2020
1 parent e8ea251 commit 63c9bec
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 95 deletions.
2 changes: 0 additions & 2 deletions jhipster/src/main/webapp/app/home/home.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<div class="row">
<div class="col-md-9">
<!--<h1 class="display-4" jhiTranslate="home.title">Welcome!</h1>-->

<div [ngSwitch]="isAuthenticated()">
<div class="alert alert-success" *ngSwitchCase="true">
<span id="home-logged-message" *ngIf="account" jhiTranslate="home.logged.message"
Expand Down
3 changes: 1 addition & 2 deletions jhipster/src/main/webapp/app/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import {Router} from '@angular/router';

@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['home.scss'],
templateUrl: './home.component.html'
})
export class HomeComponent implements OnInit, OnDestroy {
account: Account | null = null;
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* Integration tests for the ZoneId Hibernate configuration.
*/
@SpringBootTest(classes = SfoGateAssignmentProblemApp.class)
public class HibernateTimeZoneIT {
class HibernateTimeZoneIT {

@Autowired
private DateTimeWrapperRepository dateTimeWrapperRepository;
Expand All @@ -38,7 +38,7 @@ public class HibernateTimeZoneIT {
private DateTimeFormatter dateFormatter;

@BeforeEach
public void setup() {
void setup() {
dateTimeWrapper = new DateTimeWrapper();
dateTimeWrapper.setInstant(Instant.parse("2014-11-12T05:50:00.0Z"));
dateTimeWrapper.setLocalDateTime(LocalDateTime.parse("2014-11-12T07:50:00.0"));
Expand All @@ -62,7 +62,7 @@ public void setup() {

@Test
@Transactional
public void storeInstantWithZoneIdConfigShouldBeStoredOnGMTTimeZone() {
void storeInstantWithZoneIdConfigShouldBeStoredOnGMTTimeZone() {
dateTimeWrapperRepository.saveAndFlush(dateTimeWrapper);

String request = generateSqlRequest("instant", dateTimeWrapper.getId());
Expand All @@ -74,7 +74,7 @@ public void storeInstantWithZoneIdConfigShouldBeStoredOnGMTTimeZone() {

@Test
@Transactional
public void storeLocalDateTimeWithZoneIdConfigShouldBeStoredOnGMTTimeZone() {
void storeLocalDateTimeWithZoneIdConfigShouldBeStoredOnGMTTimeZone() {
dateTimeWrapperRepository.saveAndFlush(dateTimeWrapper);

String request = generateSqlRequest("local_date_time", dateTimeWrapper.getId());
Expand All @@ -89,7 +89,7 @@ public void storeLocalDateTimeWithZoneIdConfigShouldBeStoredOnGMTTimeZone() {

@Test
@Transactional
public void storeOffsetDateTimeWithZoneIdConfigShouldBeStoredOnGMTTimeZone() {
void storeOffsetDateTimeWithZoneIdConfigShouldBeStoredOnGMTTimeZone() {
dateTimeWrapperRepository.saveAndFlush(dateTimeWrapper);

String request = generateSqlRequest("offset_date_time", dateTimeWrapper.getId());
Expand All @@ -103,7 +103,7 @@ public void storeOffsetDateTimeWithZoneIdConfigShouldBeStoredOnGMTTimeZone() {

@Test
@Transactional
public void storeZoneDateTimeWithZoneIdConfigShouldBeStoredOnGMTTimeZone() {
void storeZoneDateTimeWithZoneIdConfigShouldBeStoredOnGMTTimeZone() {
dateTimeWrapperRepository.saveAndFlush(dateTimeWrapper);

String request = generateSqlRequest("zoned_date_time", dateTimeWrapper.getId());
Expand All @@ -117,7 +117,7 @@ public void storeZoneDateTimeWithZoneIdConfigShouldBeStoredOnGMTTimeZone() {

@Test
@Transactional
public void storeLocalTimeWithZoneIdConfigShouldBeStoredOnGMTTimeZoneAccordingToHis1stJan1970Value() {
void storeLocalTimeWithZoneIdConfigShouldBeStoredOnGMTTimeZoneAccordingToHis1stJan1970Value() {
dateTimeWrapperRepository.saveAndFlush(dateTimeWrapper);

String request = generateSqlRequest("local_time", dateTimeWrapper.getId());
Expand All @@ -133,7 +133,7 @@ public void storeLocalTimeWithZoneIdConfigShouldBeStoredOnGMTTimeZoneAccordingTo

@Test
@Transactional
public void storeOffsetTimeWithZoneIdConfigShouldBeStoredOnGMTTimeZoneAccordingToHis1stJan1970Value() {
void storeOffsetTimeWithZoneIdConfigShouldBeStoredOnGMTTimeZoneAccordingToHis1stJan1970Value() {
dateTimeWrapperRepository.saveAndFlush(dateTimeWrapper);

String request = generateSqlRequest("offset_time", dateTimeWrapper.getId());
Expand All @@ -150,7 +150,7 @@ public void storeOffsetTimeWithZoneIdConfigShouldBeStoredOnGMTTimeZoneAccordingT

@Test
@Transactional
public void storeLocalDateWithZoneIdConfigShouldBeStoredWithoutTransformation() {
void storeLocalDateWithZoneIdConfigShouldBeStoredWithoutTransformation() {
dateTimeWrapperRepository.saveAndFlush(dateTimeWrapper);

String request = generateSqlRequest("local_date", dateTimeWrapper.getId());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package it.economics.kata.repository;

import it.economics.kata.SfoGateAssignmentProblemApp;

import it.economics.kata.config.Constants;
import it.economics.kata.config.audit.AuditEventConverter;
import it.economics.kata.domain.PersistentAuditEvent;
Expand All @@ -22,15 +21,15 @@
import java.util.List;
import java.util.Map;

import static org.assertj.core.api.Assertions.assertThat;
import static it.economics.kata.repository.CustomAuditEventRepository.EVENT_DATA_COLUMN_MAX_LENGTH;
import static org.assertj.core.api.Assertions.assertThat;

/**
* Integration tests for {@link CustomAuditEventRepository}.
*/
@SpringBootTest(classes = SfoGateAssignmentProblemApp.class)
@Transactional
public class CustomAuditEventRepositoryIT {
class CustomAuditEventRepositoryIT {

@Autowired
private PersistenceAuditEventRepository persistenceAuditEventRepository;
Expand All @@ -41,7 +40,7 @@ public class CustomAuditEventRepositoryIT {
private CustomAuditEventRepository customAuditEventRepository;

@BeforeEach
public void setup() {
void setup() {
customAuditEventRepository = new CustomAuditEventRepository(persistenceAuditEventRepository, auditEventConverter);
persistenceAuditEventRepository.deleteAll();
Instant oneHourAgo = Instant.now().minusSeconds(3600);
Expand All @@ -66,7 +65,7 @@ public void setup() {
}

@Test
public void addAuditEvent() {
void addAuditEvent() {
Map<String, Object> data = new HashMap<>();
data.put("test-key", "test-value");
AuditEvent event = new AuditEvent("test-user", "test-type", data);
Expand All @@ -83,7 +82,7 @@ public void addAuditEvent() {
}

@Test
public void addAuditEventTruncateLargeData() {
void addAuditEventTruncateLargeData() {
Map<String, Object> data = new HashMap<>();
StringBuilder largeData = new StringBuilder();
for (int i = 0; i < EVENT_DATA_COLUMN_MAX_LENGTH + 10; i++) {
Expand All @@ -106,7 +105,7 @@ public void addAuditEventTruncateLargeData() {
}

@Test
public void testAddEventWithWebAuthenticationDetails() {
void testAddEventWithWebAuthenticationDetails() {
HttpSession session = new MockHttpSession(null, "test-session-id");
MockHttpServletRequest request = new MockHttpServletRequest();
request.setSession(session);
Expand All @@ -124,7 +123,7 @@ public void testAddEventWithWebAuthenticationDetails() {
}

@Test
public void testAddEventWithNullData() {
void testAddEventWithNullData() {
Map<String, Object> data = new HashMap<>();
data.put("test-key", null);
AuditEvent event = new AuditEvent("test-user", "test-type", data);
Expand All @@ -136,7 +135,7 @@ public void testAddEventWithNullData() {
}

@Test
public void addAuditEventWithAnonymousUser() {
void addAuditEventWithAnonymousUser() {
Map<String, Object> data = new HashMap<>();
data.put("test-key", "test-value");
AuditEvent event = new AuditEvent(Constants.ANONYMOUS_USER, "test-type", data);
Expand All @@ -146,7 +145,7 @@ public void addAuditEventWithAnonymousUser() {
}

@Test
public void addAuditEventWithAuthorizationFailureType() {
void addAuditEventWithAuthorizationFailureType() {
Map<String, Object> data = new HashMap<>();
data.put("test-key", "test-value");
AuditEvent event = new AuditEvent("test-user", "AUTHORIZATION_FAILURE", data);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package it.economics.kata.service;

import io.github.jhipster.config.JHipsterProperties;
import it.economics.kata.SfoGateAssignmentProblemApp;
import it.economics.kata.domain.PersistentAuditEvent;
import it.economics.kata.repository.PersistenceAuditEventRepository;
import it.economics.kata.SfoGateAssignmentProblemApp;
import io.github.jhipster.config.JHipsterProperties;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.transaction.annotation.Transactional;

import java.time.Instant;
import java.time.temporal.ChronoUnit;

Expand All @@ -19,7 +20,7 @@
*/
@SpringBootTest(classes = SfoGateAssignmentProblemApp.class)
@Transactional
public class AuditEventServiceIT {
class AuditEventServiceIT {
@Autowired
private AuditEventService auditEventService;

Expand All @@ -36,7 +37,7 @@ public class AuditEventServiceIT {
private PersistentAuditEvent auditEventNew;

@BeforeEach
public void init() {
void init() {
auditEventOld = new PersistentAuditEvent();
auditEventOld.setAuditEventDate(Instant.now().minus(jHipsterProperties.getAuditEvents().getRetentionPeriod() + 1, ChronoUnit.DAYS));
auditEventOld.setPrincipal("test-user-old");
Expand All @@ -55,7 +56,7 @@ public void init() {

@Test
@Transactional
public void verifyOldAuditEventsAreDeleted() {
void verifyOldAuditEventsAreDeleted() {
persistenceAuditEventRepository.deleteAll();
persistenceAuditEventRepository.save(auditEventOld);
persistenceAuditEventRepository.save(auditEventWithinRetention);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*/
@SpringBootTest(classes = SfoGateAssignmentProblemApp.class)
@Transactional
public class UserServiceIT {
class UserServiceIT {

private static final String DEFAULT_LOGIN = "johndoe";

Expand Down Expand Up @@ -57,7 +57,7 @@ public class UserServiceIT {
private User user;

@BeforeEach
public void init() {
void init() {
user = new User();
user.setLogin(DEFAULT_LOGIN);
user.setPassword(RandomStringUtils.random(60));
Expand All @@ -74,7 +74,7 @@ public void init() {

@Test
@Transactional
public void assertThatAnonymousUserIsNotGet() {
void assertThatAnonymousUserIsNotGet() {
user.setLogin(Constants.ANONYMOUS_USER);
if (!userRepository.findOneByLogin(Constants.ANONYMOUS_USER).isPresent()) {
userRepository.saveAndFlush(user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@
@AutoConfigureMockMvc
@WithMockUser(value = TEST_USER_LOGIN)
@SpringBootTest(classes = SfoGateAssignmentProblemApp.class)
public class AccountResourceIT {
class AccountResourceIT {
static final String TEST_USER_LOGIN = "test";

@Autowired
private MockMvc restAccountMockMvc;

@Test
@WithUnauthenticatedMockUser
public void testNonAuthenticatedUser() throws Exception {
void testNonAuthenticatedUser() throws Exception {
restAccountMockMvc.perform(get("/api/authenticate")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().string(""));
}

@Test
public void testAuthenticatedUser() throws Exception {
void testAuthenticatedUser() throws Exception {
restAccountMockMvc.perform(get("/api/authenticate")
.with(request -> {
request.setRemoteUser(TEST_USER_LOGIN);
Expand All @@ -48,7 +48,7 @@ public void testAuthenticatedUser() throws Exception {
}

@Test
public void testGetUnknownAccount() throws Exception {
void testGetUnknownAccount() throws Exception {
restAccountMockMvc.perform(get("/api/account")
.accept(MediaType.APPLICATION_PROBLEM_JSON))
.andExpect(status().isInternalServerError());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@
import it.economics.kata.domain.PersistentAuditEvent;
import it.economics.kata.repository.PersistenceAuditEventRepository;
import it.economics.kata.security.AuthoritiesConstants;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.transaction.annotation.Transactional;

import java.time.Instant;
Expand All @@ -32,7 +28,7 @@
@WithMockUser(authorities = AuthoritiesConstants.ADMIN)
@SpringBootTest(classes = SfoGateAssignmentProblemApp.class)
@Transactional
public class AuditResourceIT {
class AuditResourceIT {

private static final String SAMPLE_PRINCIPAL = "SAMPLE_PRINCIPAL";
private static final String SAMPLE_TYPE = "SAMPLE_TYPE";
Expand All @@ -48,7 +44,7 @@ public class AuditResourceIT {
private MockMvc restAuditMockMvc;

@BeforeEach
public void initTest() {
void initTest() {
auditEventRepository.deleteAll();
auditEvent = new PersistentAuditEvent();
auditEvent.setAuditEventType(SAMPLE_TYPE);
Expand All @@ -57,7 +53,7 @@ public void initTest() {
}

@Test
public void getAllAudits() throws Exception {
void getAllAudits() throws Exception {
// Initialize the database
auditEventRepository.save(auditEvent);

Expand All @@ -69,7 +65,7 @@ public void getAllAudits() throws Exception {
}

@Test
public void getAudit() throws Exception {
void getAudit() throws Exception {
// Initialize the database
auditEventRepository.save(auditEvent);

Expand All @@ -81,7 +77,7 @@ public void getAudit() throws Exception {
}

@Test
public void getAuditsByDate() throws Exception {
void getAuditsByDate() throws Exception {
// Initialize the database
auditEventRepository.save(auditEvent);

Expand All @@ -97,7 +93,7 @@ public void getAuditsByDate() throws Exception {
}

@Test
public void getNonExistingAuditsByDate() throws Exception {
void getNonExistingAuditsByDate() throws Exception {
// Initialize the database
auditEventRepository.save(auditEvent);

Expand All @@ -113,14 +109,14 @@ public void getNonExistingAuditsByDate() throws Exception {
}

@Test
public void getNonExistingAudit() throws Exception {
void getNonExistingAudit() throws Exception {
// Get the audit
restAuditMockMvc.perform(get("/management/audits/{id}", Long.MAX_VALUE))
.andExpect(status().isNotFound());
}

@Test
public void testPersistentAuditEventEquals() throws Exception {
void testPersistentAuditEventEquals() throws Exception {
TestUtil.equalsVerifier(PersistentAuditEvent.class);
PersistentAuditEvent auditEvent1 = new PersistentAuditEvent();
auditEvent1.setId(1L);
Expand Down
Loading

0 comments on commit 63c9bec

Please sign in to comment.