Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 22 additions & 8 deletions mcitmocks.iml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-jpa:2.4.4" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-aop:2.4.4" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.3.5" level="project" />
<orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.9.6" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.4.4" level="project" />
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.4.5" level="project" />
Expand All @@ -58,7 +57,6 @@
<orderEntry type="library" name="Maven: org.glassfish.jaxb:jaxb-runtime:2.3.3" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.jaxb:txw2:2.3.3" level="project" />
<orderEntry type="library" name="Maven: com.sun.istack:istack-commons-runtime:3.0.11" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.sun.activation:jakarta.activation:1.2.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-jpa:2.4.6" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:2.4.6" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-orm:5.3.5" level="project" />
Expand All @@ -80,9 +78,6 @@
<orderEntry type="library" name="Maven: jakarta.annotation:jakarta.annotation-api:1.3.5" level="project" />
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.27" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.4.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.11.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.11.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.11.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.11.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.11.4" level="project" />
Expand All @@ -99,9 +94,9 @@
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:2.4.4" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.4.4" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.4.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.ow2.asm:asm:5.0.4" level="project" />
<orderEntry type="library" name="Maven: net.minidev:json-smart:2.3" level="project" />
<orderEntry type="library" name="Maven: net.minidev:accessors-smart:1.2" level="project" />
<orderEntry type="library" name="Maven: org.ow2.asm:asm:5.0.4" level="project" />
<orderEntry type="library" name="Maven: jakarta.xml.bind:jakarta.xml.bind-api:2.3.3" level="project" />
<orderEntry type="library" name="Maven: jakarta.activation:jakarta.activation-api:1.2.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:3.18.1" level="project" />
Expand All @@ -124,5 +119,24 @@
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.3.5" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:5.3.5" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.xmlunit:xmlunit-core:2.7.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-security:2.4.4" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.3.5" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-config:5.4.5" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-web:5.4.5" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-oauth2-client:2.4.4" level="project" />
<orderEntry type="library" name="Maven: com.sun.mail:jakarta.mail:1.6.6" level="project" />
<orderEntry type="library" name="Maven: com.sun.activation:jakarta.activation:1.2.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-core:5.4.5" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-oauth2-client:5.4.5" level="project" />
<orderEntry type="library" name="Maven: com.nimbusds:oauth2-oidc-sdk:8.36.1" level="project" />
<orderEntry type="library" name="Maven: com.github.stephenc.jcip:jcip-annotations:1.0-1" level="project" />
<orderEntry type="library" name="Maven: com.nimbusds:content-type:2.1" level="project" />
<orderEntry type="library" name="Maven: com.nimbusds:lang-tag:1.4.4" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-oauth2-core:5.4.5" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-oauth2-jose:5.4.5" level="project" />
<orderEntry type="library" name="Maven: com.nimbusds:nimbus-jose-jwt:8.20.2" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.11.1" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.11.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.11.4" level="project" />
</component>
</module>
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.11.1</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.beans.ConstructorProperties;
import java.util.HashSet;
import java.util.Set;

@Entity
@Table(name="interview_questions")
@Table(name = "interview_questions")
public class InterviewQuestion {

@Id
Expand All @@ -23,10 +24,14 @@ public class InterviewQuestion {
@ElementCollection
private Set<QuestionType> questionTypes;

protected InterviewQuestion() {}
protected InterviewQuestion() {
}

public InterviewQuestion(String questionName, QuestionDifficulty questionDifficulty, HashSet<QuestionType> questionTypes) {
@ConstructorProperties({"questionName", "questionText", "answerText", "questionDifficulty", "questionTypes"})
public InterviewQuestion(String questionName, String questionText, String answerText, QuestionDifficulty questionDifficulty, Set<QuestionType> questionTypes) {
this.questionName = questionName;
this.questionText = questionText;
this.answerText = answerText;
this.questionDifficulty = questionDifficulty;
this.questionTypes = questionTypes;
}
Expand All @@ -43,4 +48,15 @@ public Set<QuestionType> getQuestionTypes() {
return this.questionTypes;
}

@Override
public String toString() {
return "InterviewQuestion{" +
"id='" + id + '\'' +
", questionName='" + questionName + '\'' +
", questionText='" + questionText + '\'' +
", answerText='" + answerText + '\'' +
", questionDifficulty=" + questionDifficulty +
", questionTypes=" + questionTypes +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class InterviewQuestionController {
@Autowired
private InterviewQuestionRepository interviewQuestionRepository;

@GetMapping(value="/api/questions/random", produces = "application/json")
@GetMapping(value = "/api/questions/random", produces = "application/json")
public InterviewQuestion getRandom() {
return interviewQuestionRepository.getRandom();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package com.mcitmocks.mcitmocks.InterviewQuestion;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.util.HashSet;
import java.io.File;
import java.io.IOException;
import java.util.List;

@Component
public class InterviewQuestionLoader implements CommandLineRunner {
Expand All @@ -18,22 +22,17 @@ public void run(String... args) throws Exception {
seedInterviewQuestions();
}

private void seedInterviewQuestions() {
HashSet<QuestionType> questionTypes1 = new HashSet<>();
questionTypes1.add(QuestionType.ARRAY);
InterviewQuestion question1 = new InterviewQuestion("Two Sum", QuestionDifficulty.EASY, questionTypes1);
interviewQuestionRepository.save(question1);

HashSet<QuestionType> questionTypes2 = new HashSet<>();
questionTypes2.add(QuestionType.LINKED_LIST);
questionTypes2.add(QuestionType.RECURSION);
InterviewQuestion question2 = new InterviewQuestion("Reverse Linked List", QuestionDifficulty.EASY, questionTypes2);
interviewQuestionRepository.save(question2);

HashSet<QuestionType> questionTypes3 = new HashSet<>();
questionTypes3.add(QuestionType.TREE);
questionTypes3.add(QuestionType.RECURSION);
InterviewQuestion question3 = new InterviewQuestion("Binary Tree Inorder Traversal", QuestionDifficulty.EASY, questionTypes3);
interviewQuestionRepository.save(question3);
private static List<InterviewQuestion> readJsonQuestions() throws IOException {
ObjectMapper mapper = new ObjectMapper();
return mapper.readValue(new File("src/main/java/com/mcitmocks/mcitmocks/InterviewQuestion/mock-questions.json"), new TypeReference<List<InterviewQuestion>>() {
});
}

private void seedInterviewQuestions() throws IOException {
readJsonQuestions().forEach(interviewQuestionRepository::save);
}

public static void main(String[] args) throws IOException {
readJsonQuestions().forEach(System.out::println);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[
{
"questionName": "Two Sum",
"questionText": "Hello world",
"answerText": "Hello to you too",
"questionDifficulty": "EASY",
"questionTypes": [
"ARRAY"
]
},
{
"questionName": "Reverse Linked List",
"questionText": "Hello world",
"answerText": "Hello to you too",
"questionDifficulty": "EASY",
"questionTypes": [
"LINKED_LIST",
"RECURSION"
]
},
{
"questionName": "Binary Tree Inorder Traversal",
"questionText": "Hello world",
"answerText": "Hello to you too",
"questionDifficulty": "EASY",
"questionTypes": [
"TREE",
"RECURSION"
]
}
]