Skip to content

Commit d6a41df

Browse files
anchoulsonewhl
authored andcommitted
Fixed comments
1 parent a20c83a commit d6a41df

File tree

5 files changed

+64
-74
lines changed

5 files changed

+64
-74
lines changed

ExtractingCode/WhatIsExtractVariableRefactoring/ExtractMagicConstantsPractice/test/ExtractMagicNumbersTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ static void beforeAll() throws IOException {
2424
public void testExtractedConstant() throws Exception {
2525
setUp();
2626
myFixture.configureByText("Task.java", sourceText);
27-
String elementValue = "299792458.0";
28-
Assertions.assertTrue(hasConstantWithGivenValue(elementValue),
29-
"Please, create constant values for " + elementValue);
30-
elementValue = "6.62607015e-34";
31-
Assertions.assertTrue(hasConstantWithGivenValue(elementValue),
32-
"Please, create constant values for " + elementValue);
27+
String speedOfLight = "299792458.0";
28+
Assertions.assertTrue(hasConstantWithGivenValue(speedOfLight),
29+
"Please, create constant values for " + speedOfLight);
30+
String planckConstant = "6.62607015e-34";
31+
Assertions.assertTrue(hasConstantWithGivenValue(planckConstant),
32+
"Please, create constant values for " + planckConstant);
3333
String propertyName = "waveLength";
3434
Assertions.assertTrue(hasLocalVariable(propertyName),
3535
"Please, create property for " + propertyName);

InliningCode/WhatIsInlineVariableRefactoring/InlineVariablesPractice/test/InliningVariableTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ public void testVariablesInlined() throws Exception {
2525
setUp();
2626
myFixture.configureByText("Task.java", sourceText);
2727
Assertions.assertFalse(hasLocalVariable("fileExists"),
28-
"Please, identify unnecessary variables");
28+
"Please, inline the \"fileExists\" variable");
2929
Assertions.assertFalse(hasLocalVariable("content"),
30-
"Please, identify unnecessary variables");
30+
"Please, inline the \"content\" variable");
3131
}
3232
}

RefactoringToDesignPatterns/StrategyPatternPractice/Practice/test/StrategyPatternTest.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -193,76 +193,76 @@ public void paymentProcessorClassTest() throws Exception {
193193
Class<?> clazz = paymentProcessorClass.checkBaseDefinition();
194194
paymentProcessorClass.checkDeclaredMethods(clazz);
195195
paymentProcessorClass.checkFieldsDefinition(clazz, true);
196-
}, "Please, create a PaymentProcessor class with a constructor parameter paymentStrategy and processOrderPayment method");
197-
198-
setUp();
199-
myFixture.configureByText("PaymentProcessor.java", paymentProcessorText);
200-
Assertions.assertTrue(hasExpressionWithParent("paymentStrategy.processPayment", "processOrderPayment", true),
201-
"Please, invoke the processPayment method from paymentStrategy in processOrderPayment method.");
196+
}, "Please, create a PaymentProcessor class with a constructor parameter paymentStrategy and processOrderPayment method");
202197
}
203198

204199
@Test
205200
public void bitcoinPaymentClassTest() {
206201
Assertions.assertDoesNotThrow(() -> {
207202
Class<?> clazz = bitcoinClass.checkBaseDefinition();
208203
bitcoinClass.checkDeclaredMethods(clazz);
209-
}, "Please, create a BitcoinPayment class with processPayment method");
204+
}, "Please, create a BitcoinPayment class with processPayment method");
210205
}
211206

212207
@Test
213208
public void creditCardPaymentClassTest() {
214209
Assertions.assertDoesNotThrow(() -> {
215210
Class<?> clazz = creditClass.checkBaseDefinition();
216211
creditClass.checkDeclaredMethods(clazz);
217-
}, "Please, create a CreditCardPayment class with processPayment method");
212+
}, "Please, create a CreditCardPayment class with processPayment method");
218213
}
219214

220215
@Test
221216
public void payPalPaymentClassTest() {
222217
Assertions.assertDoesNotThrow(() -> {
223218
Class<?> clazz = payPalClass.checkBaseDefinition();
224219
payPalClass.checkDeclaredMethods(clazz);
225-
}, "Please, create a PayPalPayment class with processPayment method");
220+
}, "Please, create a PayPalPayment class with processPayment method");
226221
}
227222

228223
@Test
229224
public void orderClassTest() {
230225
Assertions.assertDoesNotThrow(() -> {
231226
Class<?> clazz = orderClass.checkBaseDefinition();
232227
orderClass.checkFieldsDefinition(clazz, true);
233-
}, "Please, transform the Order class into a class that only stores two fields: totalAmount: Double and date: LocalDate. Implement getters for these fields.");
228+
}, "Please, transform the Order class into a class that only stores two fields: totalAmount: Double and date: LocalDate. Implement getters for these fields.");
234229
}
235230

236231
@Test
237-
public void mainClassTest() throws Exception {
232+
public void testCreatedInstancesInMainMethod() throws Exception {
238233
setUp();
239234
myFixture.configureByText("Main.java", mainText);
240235
String expression = "new CreditCardPayment()";
241236
String parent = "main";
242237
Assertions.assertTrue(hasExpressionWithParent(expression, parent, true),
243-
"Please, create an instance of PaymentProcessor for CreditCardPayment in the main method");
238+
"Please, create an instance of PaymentProcessor for CreditCardPayment in the main method");
244239
expression = "new PayPalPayment()";
245-
parent = "main";
246240
Assertions.assertTrue(hasExpressionWithParent(expression, parent, true),
247-
"Please, create an instance of PaymentProcessor for PayPalPayment in the main method");
241+
"Please, create an instance of PaymentProcessor for PayPalPayment in the main method");
248242
expression = "new BitcoinPayment()";
249-
parent = "main";
250243
Assertions.assertTrue(hasExpressionWithParent(expression, parent, true),
251-
"Please, create an instance of PaymentProcessor for BitcoinPayment in the main method");
244+
"Please, create an instance of PaymentProcessor for BitcoinPayment in the main method");
245+
}
246+
247+
@Test
248+
public void testInvokedMethodsOfPaymentClassesInMainMethod() throws Exception {
249+
setUp();
250+
myFixture.configureByText("Main.java", mainText);
252251
String method = "creditCardPayment.processOrderPayment(order1.getTotalAmount())";
252+
String mainMethod = "main";
253253
Assertions.assertEquals(
254254
findMethodUsages(method),
255-
List.of("main"),
255+
List.of(mainMethod),
256256
"Please, invoke the " + method + " method of Credit Card Payment and pass in the totalAmount from the first order within the main method");
257257
method = "paypalPayment.processOrderPayment(order2.getTotalAmount())";
258258
Assertions.assertEquals(
259259
findMethodUsages(method),
260-
List.of("main"),
260+
List.of(mainMethod),
261261
"Please, invoke the " + method + " method of PayPal Payment and pass in the totalAmount from the second order within the main method");
262262
method = "bitcoinPayment.processOrderPayment(order3.getTotalAmount())";
263263
Assertions.assertEquals(
264264
findMethodUsages(method),
265-
List.of("main"),
265+
List.of(mainMethod),
266266
"Please, invoke the " + method + " method of Bitcoin Payment and pass in the totalAmount from the third order within the main method");
267267
}
268268
}

RenamingCode/RenameRefactoringInIDE/FixTyposPractice/task-info.yaml

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,24 @@ type: edu
22
custom_name: "Fix typos, change the code to comply with naming rules and camelCase\
33
\ convention"
44
files:
5-
- name: src/main/java/jetbrains/refactoring/course/renaming/University.java
6-
visible: true
7-
placeholders:
8-
- offset: 77
9-
length: 816
10-
placeholder_text: |-
11-
public class University {
12-
private final ArrayList<Student> students = new ArrayList<>();
13-
14-
public void admitStudent(String name, int age, double averageScore) {
15-
Student student = new Student(name, age, averageScore);
16-
students.add(student);
17-
}
18-
19-
public void updateStudentInfo(int index, String newName, int newAge, double newScore) {
20-
if (index >= 0 && index < students.size()) {
21-
Student student = students.get(index);
22-
student.SetName(newName);
23-
student.setaGe(newAge);
24-
student.setAvergeScore(newScore);
25-
}
26-
}
27-
28-
public String getStudentGradeStatus(int index) {
29-
if (index >= 0 && index < students.size()) {
30-
return students.get(index).getgradestatus();
31-
}
32-
return "Invalid index";
33-
}
34-
}
355
- name: src/main/java/jetbrains/refactoring/course/renaming/Student.java
366
visible: true
377
placeholders:
388
- offset: 48
399
length: 892
4010
placeholder_text: |-
4111
public class Student {
42-
12+
4313
private String name;
4414
private int age;
4515
private double averageScore;
46-
16+
4717
public Student(String name, int age, double averageScore) {
4818
this.name = name;
4919
this.age = age;
5020
this.averageScore = averageScore;
5121
}
52-
22+
5323
public String getgradestatus() {
5424
if (averageScore >= 90.0 && averageScore <= 100.0) {
5525
return "Excellent";
@@ -61,18 +31,48 @@ files:
6131
return "Fail";
6232
}
6333
}
64-
34+
6535
public void SetName(String newName) {
6636
this.name = newName;
6737
}
68-
38+
6939
public void setaGe(int newAge) {
7040
this.age = newAge;
7141
}
72-
42+
7343
public void setAvergeScore(double newScore) {
7444
this.averageScore = newScore;
7545
}
7646
}
47+
- name: src/main/java/jetbrains/refactoring/course/renaming/University.java
48+
visible: true
49+
placeholders:
50+
- offset: 77
51+
length: 816
52+
placeholder_text: |-
53+
public class University {
54+
private final ArrayList<Student> students = new ArrayList<>();
55+
56+
public void admitStudent(String name, int age, double averageScore) {
57+
Student student = new Student(name, age, averageScore);
58+
students.add(student);
59+
}
60+
61+
public void updateStudentInfo(int index, String newName, int newAge, double newScore) {
62+
if (index >= 0 && index < students.size()) {
63+
Student student = students.get(index);
64+
student.SetName(newName);
65+
student.setaGe(newAge);
66+
student.setAvergeScore(newScore);
67+
}
68+
}
69+
70+
public String getStudentGradeStatus(int index) {
71+
if (index >= 0 && index < students.size()) {
72+
return students.get(index).getgradestatus();
73+
}
74+
return "Invalid index";
75+
}
76+
}
7777
- name: test/RenamingTest.java
7878
visible: false

build.gradle.kts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ plugins {
1010
java
1111
val kotlinVersion = "1.9.0"
1212
id("org.jetbrains.kotlin.jvm") version kotlinVersion apply false
13-
id("org.jlleitschuh.gradle.ktlint") version "10.0.0"
1413
}
1514

1615
intellij {
@@ -110,7 +109,7 @@ configure(subprojects.filter { it.name != "common" }) {
110109
}
111110
}
112111

113-
configure(subprojects.filter { it.name.endsWith("Practice") }) {
112+
configure(subprojects.filter { it.name.endsWith("Practice") || it.name.endsWith("task") }) {
114113
plugins.apply("org.jetbrains.intellij")
115114

116115
intellij {
@@ -126,12 +125,3 @@ configure(subprojects.filter { it.name.endsWith("Practice") }) {
126125
testImplementation("org.jetbrains.academy.test.system:core:$testSystemVersion")
127126
}
128127
}
129-
130-
configure(subprojects.filter { it.name == "CodeStyleAndFormatting-CodeSchemasAndEditorConfig-ReformatTheCodeAccordingToStyleSettingsPractice" }) {
131-
apply {
132-
plugin("org.jlleitschuh.gradle.ktlint")
133-
}
134-
tasks.withType<KotlinCompile> {
135-
dependsOn("ktlintCheck")
136-
}
137-
}

0 commit comments

Comments
 (0)