import java.util.ArrayList;
import java.util.List;
class StudentDTO {
    private Long id;
    private String name;
    private List<Long> courseIds;
    public StudentDTO(Long id, String name, List<Long> courseIds) {
        this.id = id;
        this.name = name;
        this.courseIds = courseIds;
    }
    public Long getId() {
        return id;
    }
    public String getName() {
        return name;
    }
    public List<Long> getCourseIds() {
        return courseIds;
    }
}
class Course {
    private Long courseId;
    public Course(Long courseId) {
        this.courseId = courseId;
    }
    public void setCourseId(Long courseId) {
        this.courseId = courseId;
    }
    public Long getCourseId() {
        return courseId;
    }
}
class Student {
    private Long id;
    private String name;
    private List<Course> courses;
    public Student(Long id, String name, List<Course> courses) {
        this.id = id;
        this.name = name;
        this.courses = courses;
    }
    public Long getId() {
        return id;
    }
    public String getName() {
        return name;
    }
    public List<Course> getCourses() {
        return courses;
    }
}
public class DTOToEntityConverter {
    public static Student toStudent(StudentDTO studentDTO) {
        List<Course> courses = new ArrayList<>();
        List<Long> courseIds = studentDTO.getCourseIds();
        if (courseIds != null) {
            for (Long courseId : courseIds) {
                Course course = new Course(courseId);
                courses.add(course);
            }
        }
        return new Student(studentDTO.getId(), studentDTO.getName(), courses);
    }
    public static void main(String[] args) {
        List<Long> courseIds = new ArrayList<>();
        courseIds.add(101L);
        courseIds.add(102L);
        StudentDTO studentDTO = new StudentDTO(1L, "张三", courseIds);
        Student student = toStudent(studentDTO);
        System.out.println("学生ID: " + student.getId() + ", 名字: " + student.getName() + ", 课程数量: " + student.getCourses().size());
    }
}

请编写一个Java函数，该函数能够将一个学生的数据传输对象（DTO）转换为学生实体对象。学生DTO包含学生的基本信息和他们所选课程的ID列表。学生实体对象除了包含基本信息外，还需要包含课程实体对象的列表。课程实体对象仅包含课程ID。注意，如果课程ID列表为空，则学生实体对象中的课程列表也应为空。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.util.ArrayList;
import java.util.List;
class StudentDTO {
    private Long id;
    private String name;
    private List<Long> courseIds;
    public StudentDTO(Long id, String name, List<Long> courseIds) {
    }
    public Long getId() {
    }
    public String getName() {
    }
    public List<Long> getCourseIds() {
    }
}
class Course {
    private Long courseId;
    public Course(Long courseId) {
    }
    public void setCourseId(Long courseId) {
    }
    public Long getCourseId() {
    }
}
class Student {
    private Long id;
    private String name;
    private List<Course> courses;
    public Student(Long id, String name, List<Course> courses) {
    }
    public Long getId() {
    }
    public String getName() {
    }
    public List<Course> getCourses() {
    }
}
public class DTOToEntityConverter {
    public static Student toStudent(StudentDTO studentDTO) {
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import java.util.ArrayList;
import java.util.List;
class StudentDTOTest {
    @Test
    void testGetId() {
        List<Long> courseIds = new ArrayList<>();
        StudentDTO studentDTO = new StudentDTO(1L, "张三", courseIds);
        assertEquals(1L, studentDTO.getId());
    }
    @Test
    void testGetName() {
        List<Long> courseIds = new ArrayList<>();
        StudentDTO studentDTO = new StudentDTO(1L, "张三", courseIds);
        assertEquals("张三", studentDTO.getName());
    }
    @Test
    void testGetCourseIds() {
        List<Long> courseIds = new ArrayList<>();
        courseIds.add(101L);
        courseIds.add(102L);
        StudentDTO studentDTO = new StudentDTO(1L, "张三", courseIds);
        assertEquals(2, studentDTO.getCourseIds().size());
        assertTrue(studentDTO.getCourseIds().contains(101L));
        assertTrue(studentDTO.getCourseIds().contains(102L));
    }
}
class CourseTest {
    @Test
    void testGetCourseId() {
        Course course = new Course(101L);
        assertEquals(101L, course.getCourseId());
    }
    @Test
    void testSetCourseId() {
        Course course = new Course(101L);
        course.setCourseId(102L);
        assertEquals(102L, course.getCourseId());
    }
}
class StudentTest {
    @Test
    void testGetId() {
        List<Course> courses = new ArrayList<>();
        Student student = new Student(1L, "张三", courses);
        assertEquals(1L, student.getId());
    }
    @Test
    void testGetName() {
        List<Course> courses = new ArrayList<>();
        Student student = new Student(1L, "张三", courses);
        assertEquals("张三", student.getName());
    }
    @Test
    void testGetCourses() {
        List<Course> courses = new ArrayList<>();
        courses.add(new Course(101L));
        courses.add(new Course(102L));
        Student student = new Student(1L, "张三", courses);
        assertEquals(2, student.getCourses().size());
        assertEquals(101L, student.getCourses().get(0).getCourseId());
        assertEquals(102L, student.getCourses().get(1).getCourseId());
    }
}
class DTOToEntityConverterTest {
    @Test
    void testToStudent() {
        List<Long> courseIds = new ArrayList<>();
        courseIds.add(101L);
        courseIds.add(102L);
        StudentDTO studentDTO = new StudentDTO(1L, "张三", courseIds);
        Student student = DTOToEntityConverter.toStudent(studentDTO);
        assertNotNull(student);
        assertEquals(1L, student.getId());
        assertEquals("张三", student.getName());
        assertEquals(2, student.getCourses().size());
        assertEquals(101L, student.getCourses().get(0).getCourseId());
        assertEquals(102L, student.getCourses().get(1).getCourseId());
    }
}


import java.util.ArrayList;
public class SimpleTextEditor {
    private ArrayList<String> textHistory = new ArrayList<>();
    private String currentText = "";
    public void addText(String text) {
        textHistory.add(currentText);
        currentText += text;
    }
    public void undo() {
        if (!textHistory.isEmpty()) {
            currentText = textHistory.remove(textHistory.size() - 1);
        }
    }
    public String getText() {
        return currentText;
    }
    public static void main(String[] args) {
        SimpleTextEditor editor = new SimpleTextEditor();
        editor.addText("Hello");
        editor.addText(", World!");
        System.out.println(editor.getText());
        editor.undo();
        System.out.println(editor.getText());
        editor.undo();
        System.out.println(editor.getText());
    }
}

请编写一个Java程序，实现一个简单的文本编辑器的撤销功能。这个文本编辑器只支持添加文字和撤销操作。具体要求如下：

- 编辑器初始时为空。
- 提供一个方法 `addText`，接受一个字符串参数，将其追加到编辑器的现有文本中。
- 提供一个方法 `undo`，撤销最近一次的 `addText` 操作。
- 提供一个方法 `getText`，返回编辑器当前的文本内容。
- 使用 `ArrayList<String>` 来存储每次添加的文本，以支持撤销操作。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.util.ArrayList;
public class SimpleTextEditor {
    private ArrayList<String> textHistory = new ArrayList<>();
    private String currentText = "";
    public void addText(String text) {
    }
    public void undo() {
    }
    public String getText() {
    }
}
```

Question: Write a piece of python code to achieve the following function.
Find the maximum perfect square number that is less than the nth Fibonacci number.
The function's name is max_square_number, and the input is an integer n.

Answer:
```python
def max_square_number(n):
 if n <= 2:
 return 0 # For the first two numbers in the Fibonacci sequence, no complete square numbers can be used.

 fibs = [0, 1] # Store the first two numbers of the Fibonacci sequence
 squares = [] # Store the list of perfect square numbers

 max_square = 0
 i = 2

 while i <= n:
 fibs.append(fibs[i-1] + fibs[i-2]) # Calculate the next Fibonacci number
 i += 1

 fib = fibs[-1]
 perfect_squares = [i**2 for i in range(1, int(math.sqrt(fib)) + 1)]
 max_square = max(filter(lambda x: x < fib, perfect_squares))
 return max_square
```

----------------

import org.junit.Test;
import static org.junit.Assert.*;
public class SimpleTextEditorTest {
    @Test
    public void testAddText() {
        SimpleTextEditor editor = new SimpleTextEditor();
        editor.addText("Hello");
        assertEquals("Hello", editor.getText());
    }
    @Test
    public void testAddTextMultipleTimes() {
        SimpleTextEditor editor = new SimpleTextEditor();
        editor.addText("Hello");
        editor.addText(", World!");
        assertEquals("Hello, World!", editor.getText());
    }
    @Test
    public void testUndo() {
        SimpleTextEditor editor = new SimpleTextEditor();
        editor.addText("Hello");
        editor.addText(", World!");
        editor.undo();
        assertEquals("Hello", editor.getText());
    }
    @Test
    public void testUndoMultipleTimes() {
        SimpleTextEditor editor = new SimpleTextEditor();
        editor.addText("Hello");
        editor.addText(", World!");
        editor.undo();
        editor.undo();
        assertEquals("", editor.getText());
    }
    @Test
    public void testUndoEmptyHistory() {
        SimpleTextEditor editor = new SimpleTextEditor();
        editor.undo();
        assertEquals("", editor.getText());
    }
}


import java.util.HashMap;
import java.util.Map;
class Book {
    String title;
    String author;
    int year;
    public Book(String title, String author, int year) {
        this.title = title;
        this.author = author;
        this.year = year;
    }
    @Override
    public String toString() {
        return "书名: " + title + ", 作者: " + author + ", 出版年份: " + year;
    }
}
public class LibrarySystem {
    private Map<Integer, Book> bookDatabase;
    public LibrarySystem() {
        bookDatabase = new HashMap<>();
        bookDatabase.put(1, new Book("Java编程思想", "Bruce Eckel", 2006));
        bookDatabase.put(2, new Book("Effective Java", "Joshua Bloch", 2008));
        bookDatabase.put(3, new Book("深入理解Java虚拟机", "周志明", 2013));
    }
    public String findBookDetails(int bookId) {
        if (bookDatabase.containsKey(bookId)) {
            return bookDatabase.get(bookId).toString();
        } else {
            return "抱歉，找不到ID为 " + bookId + " 的图书。";
        }
    }
    public static void main(String[] args) {
        LibrarySystem library = new LibrarySystem();
        System.out.println(library.findBookDetails(1));
        System.out.println(library.findBookDetails(4));
    }
}

请编写一个Java程序，用于模拟一个图书馆系统中的图书查询功能。该功能应允许用户根据图书ID查询图书的详细信息，包括书名、作者和出版年份。请确保程序能够处理异常情况，例如当给定的图书ID不存在时，应返回一个友好的错误信息。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.util.HashMap;
import java.util.Map;
class Book {
    String title;
    String author;
    int year;
    public Book(String title, String author, int year) {
    }
    @Override
    public String toString() {
    }
}
public class LibrarySystem {
    private Map<Integer, Book> bookDatabase;
    public LibrarySystem() {
    }
    public String findBookDetails(int bookId) {
    }
}
```

import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
public class LibrarySystemTest {
    private LibrarySystem library;
    @Before
    public void setUp() {
        library = new LibrarySystem();
    }
    @Test
    public void testFindBookDetails_ValidID() {
        String expected = "书名: Java编程思想, 作者: Bruce Eckel, 出版年份: 2006";
        String actual = library.findBookDetails(1);
        assertEquals(expected, actual);
    }
    @Test
    public void testFindBookDetails_InvalidID() {
        String expected = "抱歉，找不到ID为 4 的图书。";
        String actual = library.findBookDetails(4);
        assertEquals(expected, actual);
    }
    @Test
    public void testFindBookDetails_AnotherValidID() {
        String expected = "书名: Effective Java, 作者: Joshua Bloch, 出版年份: 2008";
        String actual = library.findBookDetails(2);
        assertEquals(expected, actual);
    }
    @Test
    public void testFindBookDetails_YetAnotherValidID() {
        String expected = "书名: 深入理解Java虚拟机, 作者: 周志明, 出版年份: 2013";
        String actual = library.findBookDetails(3);
        assertEquals(expected, actual);
    }
    @Test
    public void testFindBookDetails_DifferentInvalidID() {
        String expected = "抱歉，找不到ID为 5 的图书。";
        String actual = library.findBookDetails(5);
        assertEquals(expected, actual);
    }
}


import java.util.HashMap;
import java.util.Map;
public class BookManager {
    private static Map<Long, String> bookDatabase = new HashMap<>();
    static {
        bookDatabase.put(1L, "张三");
        bookDatabase.put(2L, "李四");
    }
    public static String fetchAuthorName(Long bookId) {
        String authorName = bookDatabase.get(bookId);
        if (authorName == null) {
            return "图书ID不存在";
        }
        return authorName;
    }
    public static void checkFunction() {
        System.out.println(fetchAuthorName(1L).equals("张三") ? "测试1通过" : "测试1失败");
        System.out.println(fetchAuthorName(2L).equals("李四") ? "测试2通过" : "测试2失败");
        System.out.println(fetchAuthorName(3L).equals("图书ID不存在") ? "测试3通过" : "测试3失败");
    }
    public static void main(String[] args) {
        checkFunction();
    }
}

请编写一个Java函数，该函数用于从一个简单的图书管理系统中获取指定图书的作者名字。假设我们有一个`Book`类，其中包含图书的ID（`bookId`）和作者名字（`authorName`）。你需要实现一个名为`fetchAuthorName`的函数，该函数接收一个图书ID作为参数，并返回对应图书的作者名字。如果该图书ID不存在，则返回一个明确的提示字符串，比如"图书ID不存在"。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.util.HashMap;
import java.util.Map;

public class BookManager {
    private static Map<Long, String> bookDatabase = new HashMap<>();
    static {
        bookDatabase.put(1L, "张三");
        bookDatabase.put(2L, "李四");
    }
    public static String fetchAuthorName(Long bookId) {
    }
    public static void checkFunction() {
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class BookManagerTest {
    @Test
    public void testFetchAuthorName_ValidBookId1() {
        String result = BookManager.fetchAuthorName(1L);
        assertEquals("张三", result);
    }
    @Test
    public void testFetchAuthorName_ValidBookId2() {
        String result = BookManager.fetchAuthorName(2L);
        assertEquals("李四", result);
    }
    @Test
    public void testFetchAuthorName_InvalidBookId() {
        String result = BookManager.fetchAuthorName(3L);
        assertEquals("图书ID不存在", result);
    }
    @Test
    public void testFetchAuthorName_NullBookId() {
        String result = BookManager.fetchAuthorName(null);
        assertEquals("图书ID不存在", result);
    }
    @Test
    public void testFetchAuthorName_DifferentInvalidBookId() {
        String result = BookManager.fetchAuthorName(99L);
        assertEquals("图书ID不存在", result);
    }
}


import javax.swing.JComponent;
import javax.swing.JLabel;
public class DataViewUpdater {
    public void updateViewStatus(JComponent errorDisplay, JComponent dataDisplay, boolean isDataRequestSuccessful) {
        if (isDataRequestSuccessful) {
            errorDisplay.setVisible(false);
            dataDisplay.setVisible(true);
        } else {
            errorDisplay.setVisible(true);
            dataDisplay.setVisible(false);
        }
    }
    public static void main(String[] args) {
        JLabel errorLabel = new JLabel("错误：无法加载数据。");
        JLabel dataLabel = new JLabel("数据加载成功！");
        DataViewUpdater updater = new DataViewUpdater();
        updater.updateViewStatus(errorLabel, dataLabel, true);
        System.out.println("数据请求成功时的可见性状态：");
        System.out.println("错误消息可见性：" + errorLabel.isVisible());
        System.out.println("数据视图可见性：" + dataLabel.isVisible());
        updater.updateViewStatus(errorLabel, dataLabel, false);
        System.out.println("数据请求失败时的可见性状态：");
        System.out.println("错误消息可见性：" + errorLabel.isVisible());
        System.out.println("数据视图可见性：" + dataLabel.isVisible());
    }
}

请编写一个Java方法，用于在图形用户界面中切换显示状态。当用户请求数据时，我们需要隐藏错误消息，并显示数据视图。请确保你的代码能够根据提供的指令动态地更新UI组件的可见性状态。你的方法应该名为`updateViewStatus`，并且接收两个参数：`errorDisplay`和`dataDisplay`，这两个参数分别代表错误消息和数据视图的UI组件。请使用Java Swing库中的`JComponent`类来代表这些UI组件，并且在方法中，你需要根据情况设置这些组件的可见性。如果数据请求成功，隐藏错误消息并显示数据视图；如果数据请求失败，执行相反的操作。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import javax.swing.JComponent;
import javax.swing.JLabel;
public class DataViewUpdater {
    public void updateViewStatus(JComponent errorDisplay, JComponent dataDisplay, boolean isDataRequestSuccessful) {
    }
}
```

import javax.swing.JComponent;
import javax.swing.JLabel;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class DataViewUpdaterTest {
    @Test
    public void testUpdateViewStatus_DataRequestSuccessful() {
        JLabel errorLabel = new JLabel("错误：无法加载数据。");
        JLabel dataLabel = new JLabel("数据加载成功！");
        DataViewUpdater updater = new DataViewUpdater();
        updater.updateViewStatus(errorLabel, dataLabel, true);
        assertFalse(errorLabel.isVisible());
        assertTrue(dataLabel.isVisible());
    }
    @Test
    public void testUpdateViewStatus_DataRequestFailed() {
        JLabel errorLabel = new JLabel("错误：无法加载数据。");
        JLabel dataLabel = new JLabel("数据加载成功！");
        DataViewUpdater updater = new DataViewUpdater();
        updater.updateViewStatus(errorLabel, dataLabel, false);
        assertTrue(errorLabel.isVisible());
        assertFalse(dataLabel.isVisible());
    }
    @Test
    public void testUpdateViewStatus_InitiaVisibility() {
        JLabel errorLabel = new JLabel("错误：无法加载数据。");
        JLabel dataLabel = new JLabel("数据加载成功！");
        errorLabel.setVisible(true);
        dataLabel.setVisible(false);
        DataViewUpdater updater = new DataViewUpdater();
        updater.updateViewStatus(errorLabel, dataLabel, true);
        assertFalse(errorLabel.isVisible());
        assertTrue(dataLabel.isVisible());
        updater.updateViewStatus(errorLabel, dataLabel, false);
        assertTrue(errorLabel.isVisible());
        assertFalse(dataLabel.isVisible());
    }
}


import java.util.HashMap;
import java.util.Map;
public class EntityTypeInformation {
    public static String getEntityTypeInformation(String projectName, String entityTypeName) {
        EntityTypeFetcher entityTypeFetcher = new EntityTypeFetcher();
        return entityTypeFetcher.fetchEntityType(projectName, entityTypeName);
    }
    static class EntityTypeFetcher {
        public String fetchEntityType(String projectName, String entityTypeName) {
            Map<String, String> mockData = new HashMap<>();
            mockData.put("ProjectA:EntityType1", "信息1");
            mockData.put("ProjectB:EntityType2", "信息2");
            return mockData.getOrDefault(projectName + ":" + entityTypeName, "未找到信息");
        }
    }
    public static void checkFunction() {
        String result1 = getEntityTypeInformation("ProjectA", "EntityType1");
        System.out.println("查询结果1: " + result1);
        assert "信息1".equals(result1) : "测试1失败";
        String result2 = getEntityTypeInformation("ProjectB", "EntityType2");
        System.out.println("查询结果2: " + result2);
        assert "信息2".equals(result2) : "测试2失败";
        String result3 = getEntityTypeInformation("ProjectC", "EntityType3");
        System.out.println("查询结果3: " + result3);
        assert "未找到信息".equals(result3) : "测试3失败";
    }
    public static void main(String[] args) {
        checkFunction();
    }
}

请编写一个Java方法，该方法能够查询并返回一个特定项目中的实体类型信息。该方法应该接收两个字符串参数：`项目名`和`实体类型名`，并返回一个表示实体类型信息的字符串。假设你已经有了一个名为`EntityTypeFetcher`的客户端类，该类有一个名为`fetchEntityType`的方法，该方法接受一个项目名和实体类型名作为参数，并返回关于该实体类型的信息。请确保在你的解决方案中导入必要的包。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.util.HashMap;
import java.util.Map;
public class EntityTypeInformation {
    public static String getEntityTypeInformation(String projectName, String entityTypeName) {
    }
    static class EntityTypeFetcher {
        public String fetchEntityType(String projectName, String entityTypeName) {
        }
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class EntityTypeInformationTest {
    @Test
    public void testGetEntityTypeInformation_ExistingProjectAndEntityType() {
        String result = EntityTypeInformation.getEntityTypeInformation("ProjectA", "EntityType1");
        assertEquals("信息1", result);
    }
    @Test
    public void testGetEntityTypeInformation_ExistingProjectAndDifferentEntityType() {
        String result = EntityTypeInformation.getEntityTypeInformation("ProjectB", "EntityType2");
        assertEquals("信息2", result);
    }
    @Test
    public void testGetEntityTypeInformation_NonExistingProjectAndEntityType() {
        String result = EntityTypeInformation.getEntityTypeInformation("ProjectC", "EntityType3");
        assertEquals("未找到信息", result);
    }
    @Test
    public void testGetEntityTypeInformation_EmptyProjectName() {
        String result = EntityTypeInformation.getEntityTypeInformation("", "EntityType1");
        assertEquals("未找到信息", result);
    }
    @Test
    public void testGetEntityTypeInformation_EmptyEntityTypeName() {
        String result = EntityTypeInformation.getEntityTypeInformation("ProjectA", "");
        assertEquals("未找到信息", result);
    }
}


import java.lang.IllegalArgumentException;
public class RectangleCalculator {
    public static int calculateArea(int width, int height) {
        if (width < 0 || height < 0) {
            throw new IllegalArgumentException("宽度和高度必须非负。");
        }
        return width * height;
    }
    public static void main(String[] args) {
        int width = 5;
        int height = 10;
        int area = calculateArea(width, height);
        System.out.println("矩形的面积是: " + area);
        checkCalculateArea();
    }
    private static void checkCalculateArea() {
        assert calculateArea(5, 10) == 50 : "计算错误";
        assert calculateArea(0, 0) == 0 : "计算错误";
        try {
            calculateArea(-1, 10);
            System.out.println("应该抛出异常，但没有抛出。");
        } catch (IllegalArgumentException e) {
            System.out.println("正确抛出异常，因为输入了负值。");
        }
    }
}

请编写一个Java程序，实现一个名为`RectangleCalculator`的类，该类中包含一个方法`calculateArea`，用于计算矩形的面积。方法接收两个整型参数：矩形的宽`width`和高`height`，并返回计算得到的面积。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.lang.IllegalArgumentException;
public class RectangleCalculator {
    public static int calculateArea(int width, int height) {
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class RectangleCalculatorTest {
    @Test
    public void testCalculateAreaPositiveValues() {
        int width = 5;
        int height = 10;
        int expectedArea = 50;
        int actualArea = RectangleCalculator.calculateArea(width, height);
        assertEquals(expectedArea, actualArea);
    }
    @Test
    public void testCalculateAreaZeroValues() {
        int width = 0;
        int height = 0;
        int expectedArea = 0;
        int actualArea = RectangleCalculator.calculateArea(width, height);
        assertEquals(expectedArea, actualArea);
    }
    @Test
    public void testCalculateAreaNegativeWidth() {
        int width = -1;
        int height = 10;
        assertThrows(IllegalArgumentException.class, () -> {
            RectangleCalculator.calculateArea(width, height);
        });
    }
    @Test
    public void testCalculateAreaNegativeHeight() {
        int width = 10;
        int height = -1;
        assertThrows(IllegalArgumentException.class, () -> {
            RectangleCalculator.calculateArea(width, height);
        });
    }
    @Test
    public void testCalculateAreaBothNegative() {
        int width = -5;
        int height = -10;
        assertThrows(IllegalArgumentException.class, () -> {
            RectangleCalculator.calculateArea(width, height);
        });
    }
}


import java.util.Arrays;
import java.util.List;
class UserNotFoundException extends RuntimeException {
    public UserNotFoundException(String message) {
        super(message);
    }
}
public class UserCheckService {
    private List<Long> existingUserIds = Arrays.asList(1001L, 1002L, 1003L, 1004L);
    public void checkUserExistence(long userId) {
        if (!existingUserIds.contains(userId)) {
            throw new UserNotFoundException("用户记录未找到，ID: " + userId);
        }
    }
    public static void main(String[] args) {
        UserCheckService service = new UserCheckService();
        try {
            service.checkUserExistence(1005L);
        } catch (UserNotFoundException e) {
            System.out.println(e.getMessage());
        }
        try {
            service.checkUserExistence(1002L);
            System.out.println("用户存在检查通过");
        } catch (UserNotFoundException e) {
            System.out.println(e.getMessage());
        }
    }
}

假设你正在开发一个电商平台的后端服务，你需要编写一个方法来检查用户是否存在于数据库中。如果用户不存在，你的方法应该抛出一个自定义的异常，提示“用户记录未找到”。请根据这个需求，设计一个Java方法，并确保包含必要的导入语句。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.util.Arrays;
import java.util.List;
class UserNotFoundException extends RuntimeException {
    public UserNotFoundException(String message) {
    }
}
public class UserCheckService {
    private List<Long> existingUserIds = Arrays.asList(1001L, 1002L, 1003L, 1004L);
    public void checkUserExistence(long userId) {
    }
}
```

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class UserCheckServiceTest {
    private final UserCheckService service = new UserCheckService();
    @Test
    public void testUserExists() {
        Assertions.assertDoesNotThrow(() -> service.checkUserExistence(1001L));
    }
    @Test
    public void testUserNotFoundThrowsException() {
        Assertions.assertThrows(UserNotFoundException.class, () -> service.checkUserExistence(1005L));
    }
    @Test
    public void testUserNotFoundExceptionMessage() {
        UserNotFoundException exception = Assertions.assertThrows(UserNotFoundException.class, () -> service.checkUserExistence(1006L));
        Assertions.assertEquals("用户记录未找到，ID: 1006", exception.getMessage());
    }
    @Test
    public void testUserExistenceOnBoundary() {
        Assertions.assertDoesNotThrow(() -> service.checkUserExistence(1004L));
    }
    @Test
    public void testUserExistenceForNonExistingIdNegative() {
        Assertions.assertThrows(UserNotFoundException.class, () -> service.checkUserExistence(-1L));
    }
}


import java.lang.Math;
public class ImageScaler {
    public static int computeScaleFactor(int originalWidth, int originalHeight, int targetWidth, int targetHeight) {
        int scaleFactor = 1;
        if (originalHeight > targetHeight || originalWidth > targetWidth) {
            int halfHeight = originalHeight / 2;
            int halfWidth = originalWidth / 2;
            while ((halfHeight / scaleFactor) >= targetHeight && (halfWidth / scaleFactor) >= targetWidth) {
                scaleFactor *= 2;
            }
        }
        return scaleFactor;
    }
    public static void main(String[] args) {
        int scaleFactor = computeScaleFactor(4000, 3000, 800, 600);
        System.out.println("Recommended scale factor: " + scaleFactor);
    }
}

如何设计一个Java方法来计算加载到内存中的图片的合适缩放比例？假设你需要加载一张图片，但是为了节省内存，你希望根据图片的原始尺寸和目标显示尺寸来计算一个缩放比例。这个缩放比例应该是2的幂（例如，1、2、4、8...），以确保图片在缩放时不会失去太多的质量。同时，计算出的缩放比例应该能够确保缩放后的图片的宽度和高度都不会小于目标尺寸。请你设计一个方法来实现这个功能。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.lang.Math;
public class ImageScaler {
    public static int computeScaleFactor(int originalWidth, int originalHeight, int targetWidth, int targetHeight) {
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class ImageScalerTest {
    @Test
    public void testComputeScaleFactor_NoScalingNeeded() {
        int result = ImageScaler.computeScaleFactor(800, 600, 800, 600);
        assertEquals(1, result);
    }
    @Test
    public void testComputeScaleFactor_ScalingDown() {
        int result = ImageScaler.computeScaleFactor(4000, 3000, 800, 600);
        assertEquals(4, result);
    }
    @Test
    public void testComputeScaleFactor_ScalingDownToDifferentAspectRatio() {
        int result = ImageScaler.computeScaleFactor(4000, 3000, 1000, 800);
        assertEquals(2, result);
    }
    @Test
    public void testComputeScaleFactor_ExactFit() {
        int result = ImageScaler.computeScaleFactor(2000, 1000, 1000, 500);
        assertEquals(2, result);
    }
    @Test
    public void testComputeScaleFactor_OneDimensionFits() {
        int result = ImageScaler.computeScaleFactor(2000, 1000, 2000, 500);
        assertEquals(1, result);
    }
}


import java.util.Objects;
public class UserProfile {
    private String description;
    public UserProfile(String description) {
        this.description = description;
    }
    public String getDescription() {
        if (Objects.isNull(description)) {
            setDescription("暂无描述");
        }
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    public static void checkDescription() {
        UserProfile userWithDescription = new UserProfile("爱好编程");
        UserProfile userWithoutDescription = new UserProfile(null);
        System.out.println("有描述的用户描述信息: " + userWithDescription.getDescription());
        System.out.println("无描述的用户描述信息: " + userWithoutDescription.getDescription());
    }
    public static void main(String[] args) {
        checkDescription();
    }
}

请编写一个Java方法，该方法用于处理用户的个人描述信息。在我们的应用中，用户的描述信息可能尚未设置，即可能为null。如果用户的描述信息为null，我们希望自动为其生成一个默认的描述信息“暂无描述”。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.util.Objects;
public class UserProfile {
    private String description;
    public UserProfile(String description) {
    }
    public String getDescription() {
    }
    public void setDescription(String description) {
    }
    public static void checkDescription() {
    }
}
```

import org.junit.Test;
import static org.junit.Assert.*;
public class UserProfileTest {
    @Test
    public void testGetDescription_whenDescriptionIsNotNull() {
        UserProfile userProfile = new UserProfile("爱好编程");
        assertEquals("爱好编程", userProfile.getDescription());
    }
    @Test
    public void testGetDescription_whenDescriptionIsNull() {
        UserProfile userProfile = new UserProfile(null);
        assertEquals("暂无描述", userProfile.getDescription());
    }
    @Test
    public void testSetDescription() {
        UserProfile userProfile = new UserProfile(null);
        userProfile.setDescription("新描述");
        assertEquals("新描述", userProfile.getDescription());
    }
    @Test
    public void testGetDescription_afterSettingDescription() {
        UserProfile userProfile = new UserProfile(null);
        userProfile.setDescription("新的描述");
        assertEquals("新的描述", userProfile.getDescription());
    }
    @Test
    public void testGetDescription_initialNonNullThenSetNull() {
        UserProfile userProfile = new UserProfile("原描述");
        userProfile.setDescription(null);
        assertEquals("暂无描述", userProfile.getDescription());
    }
}


import java.util.HashMap;
import java.util.Map;
class ProductService {
    private Map<String, Double> productPrices = new HashMap<>();
    public ProductService() {
        productPrices.put("A123", 99.99);
        productPrices.put("B456", 199.99);
        productPrices.put("C789", 299.99);
    }
    public void updateProductPrice(String productId, double newPrice) {
        if (newPrice < 0) {
            throw new IllegalArgumentException("价格不能为负数。");
        }
        productPrices.put(productId, newPrice);
    }
    public double getProductPrice(String productId) {
        return productPrices.getOrDefault(productId, -1.0);
    }
}
public class UpdatePriceDemo {
    public static void main(String[] args) {
        ProductService productService = new ProductService();
        try {
            productService.updateProductPrice("A123", 109.99);
            System.out.println("更新后的价格: " + productService.getProductPrice("A123"));
            productService.updateProductPrice("B456", -99.99);
        } catch (IllegalArgumentException e) {
            System.out.println(e.getMessage());
        }
    }
}

请编写一个Java方法，用于更新一个在线商店的商品价格信息。该方法应该接收两个参数：一个是商品的ID（字符串类型），另一个是新的价格（浮点数类型）。假设我们已经有了一个名为`ProductService`的类，该类中有一个名为`updateProductPrice`的方法，可以用来更新商品价格。此外，还需要确保在更新价格之前，新的价格不是负数。如果价格是负数，方法应该抛出一个`IllegalArgumentException`。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.util.HashMap;
import java.util.Map;
class ProductService {
    private Map<String, Double> productPrices = new HashMap<>();
    public ProductService() {
    }
    public void updateProductPrice(String productId, double newPrice) {
    }
    public double getProductPrice(String productId) {
    }
}
```

import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
class ProductServiceTest {
    private ProductService productService;
    @BeforeEach
    public void setUp() {
        productService = new ProductService();
    }
    @Test
    public void testUpdateProductPriceSuccessfully() {
        productService.updateProductPrice("A123", 109.99);
        assertEquals(109.99, productService.getProductPrice("A123"));
    }
    @Test
    public void testUpdateProductPriceWithNegativeValue() {
        Exception exception = assertThrows(IllegalArgumentException.class, () -> {
            productService.updateProductPrice("B456", -99.99);
        });
        assertEquals("价格不能为负数。", exception.getMessage());
    }
    @Test
    public void testGetProductPriceForNonExistingProduct() {
        assertEquals(-1.0, productService.getProductPrice("X999"));
    }
    @Test
    public void testInitialProductPrice() {
        assertEquals(99.99, productService.getProductPrice("A123"));
        assertEquals(199.99, productService.getProductPrice("B456"));
        assertEquals(299.99, productService.getProductPrice("C789"));
    }
    @Test
    public void testUpdatePriceMultipleTimes() {
        productService.updateProductPrice("A123", 109.99);
        productService.updateProductPrice("A123", 119.99);
        assertEquals(119.99, productService.getProductPrice("A123"));
    }
}


import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
class ImageConfig {
    private boolean centerCrop;
    private int priority;
    public ImageConfig() {
    }
    public ImageConfig centerCrop() {
        this.centerCrop = true;
        return this;
    }
    public ImageConfig priority(int priority) {
        this.priority = priority;
        return this;
    }
    public boolean isCenterCrop() {
        return centerCrop;
    }
    public int getPriority() {
        return priority;
    }
}
public class ImageLoader {
    private static ImageConfig imageConfig;
    private static final Lock lock = new ReentrantLock();
    public static ImageConfig getImageConfig() {
        if (imageConfig == null) {
            lock.lock();
            try {
                if (imageConfig == null) {
                    imageConfig = new ImageConfig()
                            .centerCrop()
                            .priority(1);
                }
            } finally {
                lock.unlock();
            }
        }
        return imageConfig;
    }
    public static void main(String[] args) {
        ImageConfig config = ImageLoader.getImageConfig();
        System.out.println("CenterCrop: " + config.isCenterCrop());
        System.out.println("Priority: " + config.getPriority());
    }
}

请编写一个Java方法，该方法用于创建并返回一个配置了图像加载参数的`ImageConfig`对象。如果该对象已经被创建，则方法应直接返回现有的对象，否则应创建一个新的对象，并设置以下参数：将图像裁剪为适应视图的中心，并设置加载优先级为普通。请确保该方法是线程安全的。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
class ImageConfig {
    private boolean centerCrop;
    private int priority;
    public ImageConfig() {
    }
    public ImageConfig centerCrop() {
        return this;
    }
    public ImageConfig priority(int priority) {
        return this;
    }
    public boolean isCenterCrop() {
        return centerCrop;
    }
    public int getPriority() {
        return priority;
    }
}
public class ImageLoader {
    private static ImageConfig imageConfig;
    private static final Lock lock = new ReentrantLock();
    public static ImageConfig getImageConfig() {
        return imageConfig;
    }
}
```

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
class ImageLoaderTest {
    @BeforeEach
    void resetConfig() {
        try {
            java.lang.reflect.Field field = ImageLoader.class.getDeclaredField("imageConfig");
            field.setAccessible(true);
            field.set(null, null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    @Test
    void testGetImageConfigNotNull() {
        ImageConfig config = ImageLoader.getImageConfig();
        Assertions.assertNotNull(config);
    }
    @Test
    void testGetImageConfigCenterCrop() {
        ImageConfig config = ImageLoader.getImageConfig();
        Assertions.assertTrue(config.isCenterCrop());
    }
    @Test
    void testGetImageConfigPriority() {
        ImageConfig config = ImageLoader.getImageConfig();
        Assertions.assertEquals(1, config.getPriority());
    }
    @Test
    void testGetImageConfigSingleton() {
        ImageConfig config1 = ImageLoader.getImageConfig();
        ImageConfig config2 = ImageLoader.getImageConfig();
        Assertions.assertSame(config1, config2);
    }
    @Test
    void testGetImageConfigThreadSafety() throws InterruptedException {
        ExecutorService executorService = Executors.newFixedThreadPool(10);
        for (int i = 0; i < 10; i++) {
            executorService.execute(() -> {
                ImageConfig config = ImageLoader.getImageConfig();
                Assertions.assertTrue(config.isCenterCrop());
                Assertions.assertEquals(1, config.getPriority());
            });
        }
        executorService.shutdown();
        while (!executorService.isTerminated()) {
            Thread.sleep(100);
        }
    }
}


import java.util.Objects;
class AppInstallAdMapper {
    private String title;
    public AppInstallAdMapper(String title) {
        this.title = title;
    }
    public String getTitle() {
        return title;
    }
}
public class Advertisement {
    private AppInstallAdMapper adMapper;
    public Advertisement(AppInstallAdMapper adMapper) {
        this.adMapper = adMapper;
    }
    public String getAdTitle() {
        return adMapper.getTitle();
    }
}
class Main {
    public static void main(String[] args) {
        AppInstallAdMapper mapper = new AppInstallAdMapper("安装最新游戏");
        Advertisement ad = new Advertisement(mapper);
        checkAdTitle(ad.getAdTitle(), "安装最新游戏");
    }
    public static void checkAdTitle(String actualTitle, String expectedTitle) {
        if (Objects.equals(actualTitle, expectedTitle)) {
            System.out.println("广告标题检查通过: " + actualTitle);
        } else {
            System.out.println("广告标题检查失败: 实际标题 - " + actualTitle + ", 预期标题 - " + expectedTitle);
        }
    }
}

请编写一个Java程序，其中包含一个名为`Advertisement`的类，该类用于管理应用安装广告的信息。该类应该有一个私有成员变量`adMapper`，它是`AppInstallAdMapper`类的实例。`AppInstallAdMapper`类有一个方法`getTitle()`，用于获取广告的标题。在`Advertisement`类中，实现一个公共方法`getAdTitle()`，该方法调用`adMapper`的`getTitle()`方法并返回广告标题。

请确保你的代码包含所有必要的导入语句，并提供一个`checkAdTitle`函数来验证`getAdTitle`方法的正确性。给定的数据点是广告标题为"安装最新游戏"。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.util.Objects;
class AppInstallAdMapper {
    private String title;
    public AppInstallAdMapper(String title) {
    }
    public String getTitle() {
    }
}
public class Advertisement {
    private AppInstallAdMapper adMapper;
    public Advertisement(AppInstallAdMapper adMapper) {
    }
    public String getAdTitle() {
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
class AppInstallAdMapperTest {
    @Test
    void testGetTitle() {
        AppInstallAdMapper mapper = new AppInstallAdMapper("测试标题1");
        assertEquals("测试标题1", mapper.getTitle());
    }
}
class AdvertisementTest {
    @Test
    void testGetAdTitle() {
        AppInstallAdMapper mapper = new AppInstallAdMapper("广告标题1");
        Advertisement ad = new Advertisement(mapper);
        assertEquals("广告标题1", ad.getAdTitle());
    }
    @Test
    void testGetAdTitleWithDifferentTitle() {
        AppInstallAdMapper mapper = new AppInstallAdMapper("广告标题2");
        Advertisement ad = new Advertisement(mapper);
        assertEquals("广告标题2", ad.getAdTitle());
    }
    @Test
    void testGetAdTitleWithEmptyTitle() {
        AppInstallAdMapper mapper = new AppInstallAdMapper("");
        Advertisement ad = new Advertisement(mapper);
        assertEquals("", ad.getAdTitle());
    }
}


import java.lang.reflect.Field;
class Employee {
    private double salary;
    public Employee(double salary) {
        this.salary = salary;
    }
    public double getSalary() {
        return salary;
    }
}
public class SalaryModifier {
    public static void modifySalary(Employee employee, double newSalary) {
        try {
            Class<?> employeeClass = employee.getClass();
            Field salaryField = employeeClass.getDeclaredField("salary");
            salaryField.setAccessible(true);
            salaryField.set(employee, newSalary);
        } catch (NoSuchFieldException | IllegalAccessException e) {
            e.printStackTrace();
        }
    }
    public static void check() {
        Employee employee = new Employee(3000.0);
        System.out.println("原始薪资: " + employee.getSalary());
        modifySalary(employee, 5000.0);
        System.out.println("修改后薪资: " + employee.getSalary());
    }
    public static void main(String[] args) {
        check();
    }
}

请设计一个Java程序，用于演示如何通过反射机制修改一个类的私有成员变量的值。在这个例子中，我们有一个名为`Employee`的类，它有一个私有成员变量`salary`。请编写一个方法，该方法能够修改任意`Employee`对象的`salary`字段的值。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.lang.reflect.Field;
class Employee {
    private double salary;
    public Employee(double salary) {

    }
    public double getSalary() {

    }
}
public class SalaryModifier {
    public static void modifySalary(Employee employee, double newSalary) {

    }
    public static void check() {

    }
}
```

import org.junit.Test;
import static org.junit.Assert.*;
public class SalaryModifierTest {
    @Test
    public void testModifySalary() {
        Employee employee = new Employee(3000.0);
        SalaryModifier.modifySalary(employee, 5000.0);
        assertEquals(5000.0, employee.getSalary(), 0.001);
    }
    @Test
    public void testModifySalaryToZero() {
        Employee employee = new Employee(3000.0);
        SalaryModifier.modifySalary(employee, 0.0);
        assertEquals(0.0, employee.getSalary(), 0.001);
    }
    @Test
    public void testModifySalaryToNegative() {
        Employee employee = new Employee(3000.0);
        SalaryModifier.modifySalary(employee, -1000.0);
        assertEquals(-1000.0, employee.getSalary(), 0.001);
    }
    @Test
    public void testModifySalaryTwice() {
        Employee employee = new Employee(3000.0);
        SalaryModifier.modifySalary(employee, 5000.0);
        assertEquals(5000.0, employee.getSalary(), 0.001);
        SalaryModifier.modifySalary(employee, 8000.0);
        assertEquals(8000.0, employee.getSalary(), 0.001);
    }
    @Test
    public void testModifySalaryWithLargeValue() {
        Employee employee = new Employee(3000.0);
        SalaryModifier.modifySalary(employee, 1_000_000.0);
        assertEquals(1_000_000.0, employee.getSalary(), 0.001);
    }
}


import java.util.HashMap;
import java.util.Map;
public class StudentScoreFinder {
    public String findScoreById(Map<String, Integer> scores, String studentId) {
        if (scores.containsKey(studentId)) {
            int score = scores.get(studentId);
            return String.format("{\"id\": \"%s\", \"score\": \"%d\"}", studentId, score);
        } else {
            return "{\"error\": \"Student not found\"}";
        }
    }
    public static void main(String[] args) {
        StudentScoreFinder finder = new StudentScoreFinder();
        Map<String, Integer> scores = new HashMap<>();
        scores.put("1001", 90);
        scores.put("1002", 85);
        scores.put("1003", 95);
        System.out.println(finder.findScoreById(scores, "1001"));
        System.out.println(finder.findScoreById(scores, "1004"));
    }
}

请编写一个Java方法，该方法接收两个参数：一个是学生的成绩列表，另一个是要查询的学生ID。该方法的目的是找到特定学生的成绩并以JSON格式返回。如果找到该学生的成绩，返回的JSON应包含学生的ID和成绩；如果没有找到，返回的JSON应说明未找到该学生的成绩。请注意，所有的键和值都应该用双引号括起来。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.util.HashMap;
import java.util.Map;
public class StudentScoreFinder {
    public String findScoreById(Map<String, Integer> scores, String studentId) {
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.HashMap;
import java.util.Map;
public class StudentScoreFinderTest {
    @Test
    public void testFindScoreById_studentExists() {
        StudentScoreFinder finder = new StudentScoreFinder();
        Map<String, Integer> scores = new HashMap<>();
        scores.put("1001", 90);
        String result = finder.findScoreById(scores, "1001");
        assertEquals("{\"id\": \"1001\", \"score\": \"90\"}", result);
    }
    @Test
    public void testFindScoreById_studentNotFound() {
        StudentScoreFinder finder = new StudentScoreFinder();
        Map<String, Integer> scores = new HashMap<>();
        String result = finder.findScoreById(scores, "1004");
        assertEquals("{\"error\": \"Student not found\"}", result);
    }
    @Test
    public void testFindScoreById_anotherStudentExists() {
        StudentScoreFinder finder = new StudentScoreFinder();
        Map<String, Integer> scores = new HashMap<>();
        scores.put("1001", 90);
        scores.put("1002", 85);
        String result = finder.findScoreById(scores, "1002");
        assertEquals("{\"id\": \"1002\", \"score\": \"85\"}", result);
    }
    @Test
    public void testFindScoreById_emptyMap() {
        StudentScoreFinder finder = new StudentScoreFinder();
        Map<String, Integer> scores = new HashMap<>();
        String result = finder.findScoreById(scores, "1001");
        assertEquals("{\"error\": \"Student not found\"}", result);
    }
    @Test
    public void testFindScoreById_multipleStudents() {
        StudentScoreFinder finder = new StudentScoreFinder();
        Map<String, Integer> scores = new HashMap<>();
        scores.put("1001", 90);
        scores.put("1002", 85);
        scores.put("1003", 95);
        String result1 = finder.findScoreById(scores, "1001");
        String result2 = finder.findScoreById(scores, "1002");
        String result3 = finder.findScoreById(scores, "1003");
        assertEquals("{\"id\": \"1001\", \"score\": \"90\"}", result1);
        assertEquals("{\"id\": \"1002\", \"score\": \"85\"}", result2);
        assertEquals("{\"id\": \"1003\", \"score\": \"95\"}", result3);
    }
}


import java.io.*;
public class UserInfoProcessor {
    public void processUsername(String username) {
        switch (username != null ? 1 : 0) {
            case 1:
                System.out.println(username.length());
                break;
            case 0:
                System.out.println("用户名为空");
                break;
            default:
                System.out.println("未知情况");
                break;
        }
    }
    public static void main(String[] args) {
        UserInfoProcessor processor = new UserInfoProcessor();
        processor.processUsername(null);
        processor.processUsername("Alice");
    }
}

请编写一个Java程序，该程序包含一个名为`UserInfoProcessor`的类和一个名为`processUsername`的方法。该方法应该接受一个可能为`null`的字符串作为用户名，并根据用户名是否为`null`来执行不同的操作。如果用户名不为`null`，则输出用户名的长度；如果用户名为`null`，则输出提示信息“用户名为空”。请确保代码能够处理潜在的空指针异常，并且在方法中使用`switch`语句来模拟不同的情况。

```java
import java.io.*;

public class UserInfoProcessor {

    public void processUsername(String username) {
        // 方法实现
    }
}
```

请确保你的程序能够正确地执行上述功能。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.io.*;
public class UserInfoProcessor {
    public void processUsername(String username) {
    }
}
```

import org.junit.Test;
import static org.junit.Assert.*;
import java.io.*;
public class UserInfoProcessorTest {
    @Test
    public void testProcessUsernameWithNull() throws Exception {
        UserInfoProcessor processor = new UserInfoProcessor();
        ByteArrayOutputStream outContent = new ByteArrayOutputStream();
        System.setOut(new PrintStream(outContent));
        processor.processUsername(null);
        assertEquals("用户名为空\n", outContent.toString());
    }
    @Test
    public void testProcessUsernameWithValidUsername() throws Exception {
        UserInfoProcessor processor = new UserInfoProcessor();
        ByteArrayOutputStream outContent = new ByteArrayOutputStream();
        System.setOut(new PrintStream(outContent));
        processor.processUsername("Alice");
        assertEquals("5\n", outContent.toString());
    }
    @Test
    public void testProcessUsernameWithEmptyString() throws Exception {
        UserInfoProcessor processor = new UserInfoProcessor();
        ByteArrayOutputStream outContent = new ByteArrayOutputStream();
        System.setOut(new PrintStream(outContent));
        processor.processUsername("");
        assertEquals("0\n", outContent.toString());
    }
    @Test
    public void testProcessUsernameWithSpecialCharacters() throws Exception {
        UserInfoProcessor processor = new UserInfoProcessor();
        ByteArrayOutputStream outContent = new ByteArrayOutputStream();
        System.setOut(new PrintStream(outContent));
        processor.processUsername("!@#");
        assertEquals("3\n", outContent.toString());
    }
    @Test
    public void testProcessUsernameWithWhitespace() throws Exception {
        UserInfoProcessor processor = new UserInfoProcessor();
        ByteArrayOutputStream outContent = new ByteArrayOutputStream();
        System.setOut(new PrintStream(outContent));
        processor.processUsername("   ");
        assertEquals("3\n", outContent.toString());
    }
}


import java.text.DecimalFormat;
public class TemperatureConverter {
    public double convertToFahrenheit(double celsius) {
        return celsius * 9 / 5 + 32;
    }
    public static void checkConversion() {
        TemperatureConverter converter = new TemperatureConverter();
        DecimalFormat df = new DecimalFormat("#.##");
        double[][] testData = {{0, 32}, {-40, -40}, {100, 212}};
        for (double[] testPair : testData) {
            double celsius = testPair[0];
            double expectedFahrenheit = testPair[1];
            double actualFahrenheit = converter.convertToFahrenheit(celsius);
            assert df.format(actualFahrenheit).equals(df.format(expectedFahrenheit)) :
                "测试失败: 输入摄氏温度 " + celsius + " 应该转换为华氏温度 " + expectedFahrenheit + ", 但得到 " + actualFahrenheit;
        }
        System.out.println("所有测试通过！");
    }
    public static void main(String[] args) {
        checkConversion();
    }
}

请编写一个Java程序，实现一个名为`TemperatureConverter`的类，该类中包含一个方法`convertToFahrenheit(double celsius)`，该方法接收一个摄氏温度值作为参数，并返回其对应的华氏温度值。华氏温度应该按照以下公式计算：华氏温度 = 摄氏温度 * 9/5 + 32。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.text.DecimalFormat;
public class TemperatureConverter {
    public double convertToFahrenheit(double celsius) {
    }
    public static void checkConversion() {
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class TemperatureConverterTest {
    @Test
    public void testConvertToFahrenheit() {
        TemperatureConverter converter = new TemperatureConverter();
        assertEquals(32.0, converter.convertToFahrenheit(0), 0.01);
        assertEquals(-40.0, converter.convertToFahrenheit(-40), 0.01);
        assertEquals(212.0, converter.convertToFahrenheit(100), 0.01);
    }
    @Test
    public void testConvertToFahrenheitEdgeCase1() {
        TemperatureConverter converter = new TemperatureConverter();
        assertEquals(98.6, converter.convertToFahrenheit(37), 0.01);
    }
    @Test
    public void testConvertToFahrenheitEdgeCase2() {
        TemperatureConverter converter = new TemperatureConverter();
        assertEquals(-459.67, converter.convertToFahrenheit(-273.15), 0.01);
    }
    @Test
    public void testConvertToFahrenheitEdgeCase3() {
        TemperatureConverter converter = new TemperatureConverter();
        assertEquals(134.06, converter.convertToFahrenheit(56.7), 0.01);
    }
}


import java.util.Objects;
public class LoginChecker {
    public static boolean checkLogin(String username, String password) {
        String queryResult = simulateDatabaseQuery(username, password);
        return Objects.nonNull(queryResult);
    }
    private static String simulateDatabaseQuery(String username, String password) {
        if ("admin".equals(username) && "123456".equals(password)) {
            return "查询结果";
        } else {
            return null;
        }
    }
    public static void main(String[] args) {
        System.out.println(checkLogin("admin", "123456"));
        System.out.println(checkLogin("user", "password"));
    }
}

请设计一个Java方法，用于检查用户是否可以成功登录。在这个场景中，我们假设有一个数据库表`users`，其中包含用户名（`username`）和密码（`password`）字段。你需要编写一个方法`checkLogin`，它接收两个字符串参数：`username`和`password`。这个方法应该返回一个布尔值，表示给定的用户名和密码是否与数据库中的记录匹配。为了简化问题，我们不会真的连接数据库，而是模拟数据库查询的过程。如果用户名和密码组合正确，假设查询将返回一个非空字符串；如果不正确，则返回`null`。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.util.Objects;
public class LoginChecker {
    public static boolean checkLogin(String username, String password) {
    }
    private static String simulateDatabaseQuery(String username, String password) {
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class LoginCheckerTest {
    @Test
    public void testValidLogin() {
        assertTrue(LoginChecker.checkLogin("admin", "123456"));
    }
    @Test
    public void testInvalidUsername() {
        assertFalse(LoginChecker.checkLogin("invalidUser", "123456"));
    }
    @Test
    public void testInvalidPassword() {
        assertFalse(LoginChecker.checkLogin("admin", "wrongPassword"));
    }
    @Test
    public void testInvalidUsernameAndPassword() {
        assertFalse(LoginChecker.checkLogin("invalidUser", "wrongPassword"));
    }
    @Test
    public void testNullInputs() {
        assertFalse(LoginChecker.checkLogin(null, null));
    }
}


import java.util.Objects;
public class Validator {
    public static <T> T ensureNotNull(T object, String errorMessageTemplate, Object... errorMessageArgs) {
        if (object == null) {
            throw new IllegalArgumentException(String.format(errorMessageTemplate, errorMessageArgs));
        }
        return object;
    }
    public static void main(String[] args) {
        try {
            ensureNotNull(null, "传入的对象不能为null, 参数：%s", "测试参数");
        } catch (IllegalArgumentException e) {
            System.out.println(e.getMessage());
        }
        try {
            String result = ensureNotNull("非空字符串", "传入的对象不能为null");
            System.out.println("检查通过，返回值：" + result);
        } catch (IllegalArgumentException e) {
            System.out.println(e.getMessage());
        }
    }
}

请编写一个Java方法，该方法用于验证传入的对象是否为非空。如果对象为空，则抛出一个带有自定义错误信息的`IllegalArgumentException`异常。该方法应该能够接受任意类型的对象，并允许用户自定义错误信息模板及其参数。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.util.Objects;
public class Validator {
    public static <T> T ensureNotNull(T object, String errorMessageTemplate, Object... errorMessageArgs) {
    }
}
```

import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
public class ValidatorTest {
    @Test
    public void testEnsureNotNull_withNullObject_shouldThrowException() {
        assertThrows(IllegalArgumentException.class, () -> {
            Validator.ensureNotNull(null, "传入的对象不能为null, 参数：%s", "测试参数");
        });
    }
    @Test
    public void testEnsureNotNull_withValidObject_shouldReturnObject() {
        String input = "非空字符串";
        String result = Validator.ensureNotNull(input, "传入的对象不能为null");
        assertEquals(input, result);
    }
    @Test
    public void testEnsureNotNull_withNullObjectAndNoArgs_shouldThrowException() {
        assertThrows(IllegalArgumentException.class, () -> {
            Validator.ensureNotNull(null, "传入的对象不能为null");
        });
    }
    @Test
    public void testEnsureNotNull_withEmptyErrorMessage_shouldReturnObject() {
        String input = "任意字符串";
        String result = Validator.ensureNotNull(input, "");
        assertEquals(input, result);
    }
    @Test
    public void testEnsureNotNull_withValidObjectAndArguments_shouldReturnObject() {
        String input = "有效对象";
        String result = Validator.ensureNotNull(input, "传入的对象不能为null, 参数：%s", "任意参数");
        assertEquals(input, result);
    }
}


import java.math.BigDecimal;
class UserAddress {
    private String floor;
    private String fullAddress;
    private String instruction;
    private String tag;
    private BigDecimal latitude;
    private BigDecimal longitude;
    public void setFloor(String floor) {
        this.floor = floor;
    }
    public void setFullAddress(String fullAddress) {
        this.fullAddress = fullAddress;
    }
    public void setInstruction(String instruction) {
        this.instruction = instruction;
    }
    public void setTag(String tag) {
        this.tag = tag;
    }
    public void setLatitude(BigDecimal latitude) {
        this.latitude = latitude;
    }
    public void setLongitude(BigDecimal longitude) {
        this.longitude = longitude;
    }
    public String getFloor() {
        return floor;
    }
    public String getFullAddress() {
        return fullAddress;
    }
    public String getInstruction() {
        return instruction;
    }
    public String getTag() {
        return tag;
    }
    public BigDecimal getLatitude() {
        return latitude;
    }
    public BigDecimal getLongitude() {
        return longitude;
    }
}
class UserAddressUpdateInfo {
    private String floor;
    private String completeAddress;
    private String instruction;
    private String tag;
    private BigDecimal latitude;
    private BigDecimal longitude;
    public UserAddressUpdateInfo(String floor, String completeAddress, String instruction, String tag, BigDecimal latitude, BigDecimal longitude) {
        this.floor = floor;
        this.completeAddress = completeAddress;
        this.instruction = instruction;
        this.tag = tag;
        this.latitude = latitude;
        this.longitude = longitude;
    }
    public String getFloor() {
        return floor;
    }
    public String getCompleteAddress() {
        return completeAddress;
    }
    public String getInstruction() {
        return instruction;
    }
    public String getTag() {
        return tag;
    }
    public BigDecimal getLatitude() {
        return latitude;
    }
    public BigDecimal getLongitude() {
        return longitude;
    }
}
public class AddressUpdater {
    public static UserAddress updateAddress(UserAddressUpdateInfo updateInfo, UserAddress currentAddress) {
        currentAddress.setFloor(updateInfo.getFloor());
        currentAddress.setFullAddress(updateInfo.getCompleteAddress());
        currentAddress.setInstruction(updateInfo.getInstruction());
        currentAddress.setTag(updateInfo.getTag());
        currentAddress.setLatitude(updateInfo.getLatitude());
        currentAddress.setLongitude(updateInfo.getLongitude());
        return currentAddress;
    }
    public static void main(String[] args) {
        UserAddress currentAddress = new UserAddress();
        UserAddressUpdateInfo updateInfo = new UserAddressUpdateInfo("12", "1234 Main St, Anytown", "Leave at door", "Home", new BigDecimal("40.712776"), new BigDecimal("-74.005974"));
        UserAddress updatedAddress = updateAddress(updateInfo, currentAddress);
        System.out.println("Floor: " + updatedAddress.getFloor());
        System.out.println("Full Address: " + updatedAddress.getFullAddress());
        System.out.println("Instruction: " + updatedAddress.getInstruction());
        System.out.println("Tag: " + updatedAddress.getTag());
        System.out.println("Latitude: " + updatedAddress.getLatitude());
        System.out.println("Longitude: " + updatedAddress.getLongitude());
    }
}

请编写一个Java方法，用于将一个用户的地址更新信息应用到用户的现有地址记录上。这个方法应该接受两个参数：一个是包含更新信息的`UserAddressUpdateInfo`对象，另一个是用户当前的`UserAddress`对象。更新信息中可能包含楼层、完整地址、备注、标签、纬度和经度。请确保你的方法能够更新所有提供的信息，并返回更新后的`UserAddress`对象。

注意：不需要处理送货时间偏好字段。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.math.BigDecimal;
class UserAddress {
    private String floor;
    private String fullAddress;
    private String instruction;
    private String tag;
    private BigDecimal latitude;
    private BigDecimal longitude;
    public void setFloor(String floor) {
    }
    public void setFullAddress(String fullAddress) {
    }
    public void setInstruction(String instruction) {
    }
    public void setTag(String tag) {
    }
    public void setLatitude(BigDecimal latitude) {
    }
    public void setLongitude(BigDecimal longitude) {
    }
    public String getFloor() {
        return null;
    }
    public String getFullAddress() {
        return null;
    }
    public String getInstruction() {
        return null;
    }
    public String getTag() {
        return null;
    }
    public BigDecimal getLatitude() {
        return null;
    }
    public BigDecimal getLongitude() {
        return null;
    }
}
class UserAddressUpdateInfo {
    private String floor;
    private String completeAddress;
    private String instruction;
    private String tag;
    private BigDecimal latitude;
    private BigDecimal longitude;
    public UserAddressUpdateInfo(String floor, String completeAddress, String instruction, String tag, BigDecimal latitude, BigDecimal longitude) {
    }
    public String getFloor() {
        return null;
    }
    public String getCompleteAddress() {
        return null;
    }
    public String getInstruction() {
        return null;
    }
    public String getTag() {
        return null;
    }
    public BigDecimal getLatitude() {
        return null;
    }
    public BigDecimal getLongitude() {
        return null;
    }
}
public class AddressUpdater {
    public static UserAddress updateAddress(UserAddressUpdateInfo updateInfo, UserAddress currentAddress) {
        return null;
    }
}
```

import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.math.BigDecimal;
class UserAddressTest {
    private UserAddress userAddress;
    @BeforeEach
    void setUp() {
        userAddress = new UserAddress();
    }
    @Test
    void testSetAndGetFloor() {
        userAddress.setFloor("10");
        assertEquals("10", userAddress.getFloor());
    }
    @Test
    void testSetAndGetFullAddress() {
        userAddress.setFullAddress("1234 Main St, Anytown");
        assertEquals("1234 Main St, Anytown", userAddress.getFullAddress());
    }
    @Test
    void testSetAndGetInstruction() {
        userAddress.setInstruction("Leave at door");
        assertEquals("Leave at door", userAddress.getInstruction());
    }
    @Test
    void testSetAndGetTag() {
        userAddress.setTag("Home");
        assertEquals("Home", userAddress.getTag());
    }
    @Test
    void testSetAndGetLatitude() {
        BigDecimal latitude = new BigDecimal("40.712776");
        userAddress.setLatitude(latitude);
        assertEquals(latitude, userAddress.getLatitude());
    }
    @Test
    void testSetAndGetLongitude() {
        BigDecimal longitude = new BigDecimal("-74.005974");
        userAddress.setLongitude(longitude);
        assertEquals(longitude, userAddress.getLongitude());
    }
}
class UserAddressUpdateInfoTest {
    private UserAddressUpdateInfo updateInfo;
    @BeforeEach
    void setUp() {
        updateInfo = new UserAddressUpdateInfo("12", "1234 Main St, Anytown", "Leave at door", "Home", new BigDecimal("40.712776"), new BigDecimal("-74.005974"));
    }
    @Test
    void testGetFloor() {
        assertEquals("12", updateInfo.getFloor());
    }
    @Test
    void testGetCompleteAddress() {
        assertEquals("1234 Main St, Anytown", updateInfo.getCompleteAddress());
    }
    @Test
    void testGetInstruction() {
        assertEquals("Leave at door", updateInfo.getInstruction());
    }
    @Test
    void testGetTag() {
        assertEquals("Home", updateInfo.getTag());
    }
    @Test
    void testGetLatitude() {
        assertEquals(new BigDecimal("40.712776"), updateInfo.getLatitude());
    }
    @Test
    void testGetLongitude() {
        assertEquals(new BigDecimal("-74.005974"), updateInfo.getLongitude());
    }
}
class AddressUpdaterTest {
    @Test
    void testUpdateAddress() {
        UserAddress currentAddress = new UserAddress();
        UserAddressUpdateInfo updateInfo = new UserAddressUpdateInfo("12", "1234 Main St, Anytown", "Leave at door", "Home", new BigDecimal("40.712776"), new BigDecimal("-74.005974"));
        UserAddress updatedAddress = AddressUpdater.updateAddress(updateInfo, currentAddress);
        assertEquals("12", updatedAddress.getFloor());
        assertEquals("1234 Main St, Anytown", updatedAddress.getFullAddress());
        assertEquals("Leave at door", updatedAddress.getInstruction());
        assertEquals("Home", updatedAddress.getTag());
        assertEquals(new BigDecimal("40.712776"), updatedAddress.getLatitude());
        assertEquals(new BigDecimal("-74.005974"), updatedAddress.getLongitude());
    }
}


public class CurrencyConverter {
    public static double convertUsdToEur(double usdAmount) {
        final double exchangeRate = 0.85;
        return usdAmount * exchangeRate;
    }
    public static void main(String[] args) {
        double usdAmount1 = 100;
        double usdAmount2 = 50;
        System.out.println("100美元等于" + convertUsdToEur(usdAmount1) + "欧元");
        System.out.println("50美元等于" + convertUsdToEur(usdAmount2) + "欧元");
    }
}

请编写一个Java程序，实现一个简单的货币转换器。该转换器应该能够将美元转换成欧元。假设1美元等于0.85欧元。请定义一个名为`CurrencyConverter`的类，并在其中实现一个名为`convertUsdToEur`的方法，该方法接收一个表示美元金额的`double`类型参数，并返回转换后的欧元金额。

请遵循以下指导原则：
- 使用清晰的变量命名。
- 确保代码自包含且清晰。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
public class CurrencyConverter {
    public static double convertUsdToEur(double usdAmount) {
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class CurrencyConverterTest {
    @Test
    public void testConvertUsdToEur_withPositiveAmount() {
        double usdAmount = 100;
        double expectedEurAmount = 85;
        assertEquals(expectedEurAmount, CurrencyConverter.convertUsdToEur(usdAmount));
    }
    @Test
    public void testConvertUsdToEur_withZeroAmount() {
        double usdAmount = 0;
        double expectedEurAmount = 0;
        assertEquals(expectedEurAmount, CurrencyConverter.convertUsdToEur(usdAmount));
    }
    @Test
    public void testConvertUsdToEur_withNegativeAmount() {
        double usdAmount = -50;
        double expectedEurAmount = -42.5;
        assertEquals(expectedEurAmount, CurrencyConverter.convertUsdToEur(usdAmount));
    }
    @Test
    public void testConvertUsdToEur_withFractionalAmount() {
        double usdAmount = 123.45;
        double expectedEurAmount = 104.9325;
        assertEquals(expectedEurAmount, CurrencyConverter.convertUsdToEur(usdAmount), 0.0001);
    }
    @Test
    public void testConvertUsdToEur_withSmallAmount() {
        double usdAmount = 0.01;
        double expectedEurAmount = 0.0085;
        assertEquals(expectedEurAmount, CurrencyConverter.convertUsdToEur(usdAmount), 0.0001);
    }
}


import java.util.HashMap;
import java.util.Map;
public class BookManager {
    private Map<String, String> books = new HashMap<>();
    public BookManager() {
        books.put("978-3-16-148410-0", "Java编程思想");
        books.put("978-4-16-148410-1", "Effective Java");
        books.put("978-5-16-148410-2", "深入理解Java虚拟机");
    }
    public boolean removeBookByIsbn(String isbn) {
        if (books.containsKey(isbn)) {
            books.remove(isbn);
            return true;
        } else {
            return false;
        }
    }
    public static void checkFunction() {
        BookManager manager = new BookManager();
        System.out.println("删除存在的图书（预期返回true）：" + manager.removeBookByIsbn("978-3-16-148410-0"));
        System.out.println("删除不存在的图书（预期返回false）：" + manager.removeBookByIsbn("978-0-00-000000-0"));
    }
    public static void main(String[] args) {
        checkFunction();
    }
}

请编写一个Java程序，实现一个简单的图书管理系统中的图书删除功能。该系统应该允许用户通过输入图书的ISBN号来删除图书。如果图书存在并且成功删除，则返回`true`；如果图书不存在，则返回`false`。请确保你的代码是自包含的，并且所有使用到的包都在代码片段的开头导入。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.util.HashMap;
import java.util.Map;
public class BookManager {
    private Map<String, String> books = new HashMap<>();
    public BookManager() {
    }
    public boolean removeBookByIsbn(String isbn) {
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class BookManagerTest {
    @Test
    public void testRemoveBookByIsbn_BookExists() {
        BookManager manager = new BookManager();
        assertTrue(manager.removeBookByIsbn("978-3-16-148410-0"));
    }
    @Test
    public void testRemoveBookByIsbn_BookDoesNotExist() {
        BookManager manager = new BookManager();
        assertFalse(manager.removeBookByIsbn("978-0-00-000000-0"));
    }
    @Test
    public void testRemoveBookByIsbn_RemoveTwice() {
        BookManager manager = new BookManager();
        manager.removeBookByIsbn("978-3-16-148410-0");
        assertFalse(manager.removeBookByIsbn("978-3-16-148410-0"));
    }
    @Test
    public void testRemoveBookByIsbn_NullIsbn() {
        BookManager manager = new BookManager();
        assertFalse(manager.removeBookByIsbn(null));
    }
    @Test
    public void testRemoveBookByIsbn_EmptyIsbn() {
        BookManager manager = new BookManager();
        assertFalse(manager.removeBookByIsbn(""));
    }
}


import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class BookSearchSystem {
    private List<Book> booksDatabase = new ArrayList<>();
    public BookSearchSystem() {
        booksDatabase.add(new Book("Java编程思想", "科技", "Bruce Eckel"));
        booksDatabase.add(new Book("三体", "小说", "刘慈欣"));
        booksDatabase.add(new Book("Effective Java", "科技", "Joshua Bloch"));
        booksDatabase.add(new Book("教育心理学", "教育", "某教育学者"));
    }
    public List<Book> searchBooks(String type, String keyword, int page, int limit) {
        return booksDatabase.stream()
                .filter(book -> book.getType().equals(type) && (book.getName().contains(keyword) || book.getAuthor().contains(keyword)))
                .skip((long) (page - 1) * limit)
                .limit(limit)
                .collect(Collectors.toList());
    }
    public void check() {
        System.out.println("搜索结果1: " + searchBooks("科技", "Java", 1, 2));
        System.out.println("搜索结果2: " + searchBooks("小说", "三体", 1, 1));
    }
    public static void main(String[] args) {
        new BookSearchSystem().check();
    }
    static class Book {
        private String name;
        private String type;
        private String author;
        public Book(String name, String type, String author) {
            this.name = name;
            this.type = type;
            this.author = author;
        }
        @Override
        public String toString() {
            return "Book{" +
                    "name='" + name + '\'' +
                    ", type='" + type + '\'' +
                    ", author='" + author + '\'' +
                    '}';
        }
        public String getName() {
            return name;
        }
        public String getType() {
            return type;
        }
        public String getAuthor() {
            return author;
        }
    }
}

请编写关于图书搜索功能要求的描述课题：

实现一个简单的图书管理系统中的图书搜索功能。该功能需要根据图书的类型和关键字进行搜索，并支持分页显示结果。具体要求如下：

- 能够根据图书的类别（例如：小说、科技、教育等）和关键字（如书名或作者名的一部分）对图书进行搜索。
- 搜索结果应支持分页显示，即每页显示固定数量的图书信息。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class BookSearchSystem {
    private List<Book> booksDatabase = new ArrayList<>();
    public BookSearchSystem() {
    }
    public List<Book> searchBooks(String type, String keyword, int page, int limit) {
    }
    public void check() {
    }
    static class Book {
        private String name;
        private String type;
        private String author;
        public Book(String name, String type, String author) {
        }
        @Override
        public String toString() {
        }
        public String getName() {
        }
        public String getType() {
        }
        public String getAuthor() {
        }
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
public class BookSearchSystemTest {
    @Test
    public void testSearchBooksTechnologyByJavaKeyword() {
        BookSearchSystem system = new BookSearchSystem();
        List<BookSearchSystem.Book> result = system.searchBooks("科技", "Java", 1, 2);
        assertEquals(2, result.size());
        assertTrue(result.stream().allMatch(book -> book.getType().equals("科技")));
    }
    @Test
    public void testSearchBooksNovelByThreeBodyKeyword() {
        BookSearchSystem system = new BookSearchSystem();
        List<BookSearchSystem.Book> result = system.searchBooks("小说", "三体", 1, 1);
        assertEquals(1, result.size());
        assertEquals("三体", result.get(0).getName());
    }
    @Test
    public void testSearchBooksEducationByKeyword() {
        BookSearchSystem system = new BookSearchSystem();
        List<BookSearchSystem.Book> result = system.searchBooks("教育", "某教育学者", 1, 1);
        assertEquals(1, result.size());
        assertEquals("教育心理学", result.get(0).getName());
    }
    @Test
    public void testSearchExceedingLimit() {
        BookSearchSystem system = new BookSearchSystem();
        List<BookSearchSystem.Book> result = system.searchBooks("科技", "Java", 1, 3);
        assertEquals(2, result.size());
    }
    @Test
    public void testSearchWithPagination() {
        BookSearchSystem system = new BookSearchSystem();
        List<BookSearchSystem.Book> result = system.searchBooks("科技", "Java", 2, 1);
        assertEquals(1, result.size());
        assertEquals("Effective Java", result.get(0).getName());
    }
}


import java.util.HashMap;
import java.util.Map;
public class DiscountCategoryDecider {
    public static String determineDiscountCategory(int age, boolean isMember) {
        if (isMember) {
            return age > 60 ? "高级折扣" : "普通折扣";
        } else {
            return "无折扣";
        }
    }
    public static void main(String[] args) {
        Map<String, Object> testCases = new HashMap<>();
        testCases.put("高级折扣", new Object[]{65, true});
        testCases.put("普通折扣", new Object[]{45, true});
        testCases.put("无折扣", new Object[]{70, false});
        testCases.forEach((expected, params) -> {
            Object[] arr = (Object[]) params;
            int age = (int) arr[0];
            boolean isMember = (boolean) arr[1];
            String result = determineDiscountCategory(age, isMember);
            System.out.println("预期结果: " + expected + ", 实际结果: " + result + "。测试" + (expected.equals(result) ? "通过" : "未通过"));
        });
    }
}

请根据用户的年龄和会员状态决定他们的折扣类别。如果用户是会员并且年龄超过60岁，则他们应该被归类到高级折扣类别。否则，如果他们是会员但年龄不超过60岁，则归为普通折扣类别。非会员不享受任何折扣。请确保能够根据提供的用户信息返回正确的折扣类别。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.util.HashMap;
import java.util.Map;
public class DiscountCategoryDecider {
    public static String determineDiscountCategory(int age, boolean isMember) {
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class DiscountCategoryDeciderTest {
    @Test
    public void testSeniorMemberDiscount() {
        assertEquals("高级折扣", DiscountCategoryDecider.determineDiscountCategory(65, true));
    }
    @Test
    public void testRegularMemberDiscount() {
        assertEquals("普通折扣", DiscountCategoryDecider.determineDiscountCategory(45, true));
    }
    @Test
    public void testNoMemberSeniorDiscount() {
        assertEquals("无折扣", DiscountCategoryDecider.determineDiscountCategory(70, false));
    }
    @Test
    public void testNonSeniorMemberDiscount() {
        assertEquals("普通折扣", DiscountCategoryDecider.determineDiscountCategory(30, true));
    }
    @Test
    public void testNonSeniorNonMemberDiscount() {
        assertEquals("无折扣", DiscountCategoryDecider.determineDiscountCategory(30, false));
    }
}


import java.util.ArrayList;
import java.util.Objects;
class BookEntry {
    String title;
    String author;
    public BookEntry(String title, String author) {
        this.title = title;
        this.author = author;
    }
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof BookEntry)) return false;
        BookEntry bookEntry = (BookEntry) o;
        return Objects.equals(title, bookEntry.title) &&
                Objects.equals(author, bookEntry.author);
    }
    @Override
    public int hashCode() {
        return Objects.hash(title, author);
    }
}
public class BookManager {
    ArrayList<BookEntry> bookEntries = new ArrayList<>();
    public void manageBooks(ArrayList<BookEntry> newEntries, boolean update) {
        if (update) {
            bookEntries.clear();
            bookEntries.addAll(newEntries);
        } else {
            for (BookEntry entry : newEntries) {
                if (!bookEntries.contains(entry)) {
                    bookEntries.add(entry);
                }
            }
        }
    }
    public static void checkFunction() {
        BookManager manager = new BookManager();
        ArrayList<BookEntry> entries = new ArrayList<>();
        entries.add(new BookEntry("Book1", "Author1"));
        entries.add(new BookEntry("Book2", "Author2"));
        manager.manageBooks(entries, false);
        System.out.println("After first addition: " + manager.bookEntries.size());
        ArrayList<BookEntry> newEntries = new ArrayList<>();
        newEntries.add(new BookEntry("Book1", "Author1"));
        newEntries.add(new BookEntry("Book3", "Author3"));
        manager.manageBooks(newEntries, false);
        System.out.println("After second addition without update: " + manager.bookEntries.size());
        manager.manageBooks(newEntries, true);
        System.out.println("After update: " + manager.bookEntries.size());
    }
    public static void main(String[] args) {
        checkFunction();
    }
}

请编写一个Java程序，实现一个简单的图书管理系统。在这个系统中，你需要管理一系列的图书条目。每个图书条目包含书名和作者名。你需要实现一个方法，该方法接收一个新的图书条目列表和一个布尔值。如果布尔值为真，则更新现有条目；如果为假，则只添加不存在的条目。确保你的实现能够避免重复添加相同的条目。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.util.ArrayList;
import java.util.Objects;
class BookEntry {
    String title;
    String author;
    public BookEntry(String title, String author) {
    }
    @Override
    public boolean equals(Object o) {
    }
    @Override
    public int hashCode() {
    }
}
public class BookManager {
    ArrayList<BookEntry> bookEntries = new ArrayList<>();
    public void manageBooks(ArrayList<BookEntry> newEntries, boolean update) {
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import java.util.ArrayList;
class BookEntryTest {
    @Test
    void testEqualsAndHashCode() {
        BookEntry entry1 = new BookEntry("Title1", "Author1");
        BookEntry entry2 = new BookEntry("Title1", "Author1");
        BookEntry entry3 = new BookEntry("Title2", "Author2");
        assertEquals(entry1, entry2);
        assertNotEquals(entry1, entry3);
        assertEquals(entry1.hashCode(), entry2.hashCode());
        assertNotEquals(entry1.hashCode(), entry3.hashCode());
    }
}
class BookManagerTest {
    @Test
    void testManageBooksAddWithoutUpdate() {
        BookManager manager = new BookManager();
        ArrayList<BookEntry> entries = new ArrayList<>();
        entries.add(new BookEntry("Book1", "Author1"));
        entries.add(new BookEntry("Book2", "Author2"));
        manager.manageBooks(entries, false);
        assertEquals(2, manager.bookEntries.size());
    }
    @Test
    void testManageBooksAddWithDuplicatesWithoutUpdate() {
        BookManager manager = new BookManager();
        ArrayList<BookEntry> entries = new ArrayList<>();
        entries.add(new BookEntry("Book1", "Author1"));
        entries.add(new BookEntry("Book2", "Author2"));
        manager.manageBooks(entries, false);
        ArrayList<BookEntry> newEntries = new ArrayList<>();
        newEntries.add(new BookEntry("Book1", "Author1"));
        newEntries.add(new BookEntry("Book3", "Author3"));
        manager.manageBooks(newEntries, false);
        assertEquals(3, manager.bookEntries.size());
    }
    @Test
    void testManageBooksWithUpdate() {
        BookManager manager = new BookManager();
        ArrayList<BookEntry> entries = new ArrayList<>();
        entries.add(new BookEntry("Book1", "Author1"));
        entries.add(new BookEntry("Book2", "Author2"));
        manager.manageBooks(entries, false);
        ArrayList<BookEntry> newEntries = new ArrayList<>();
        newEntries.add(new BookEntry("Book1", "Author1"));
        newEntries.add(new BookEntry("Book3", "Author3"));
        manager.manageBooks(newEntries, true);
        assertEquals(2, manager.bookEntries.size());
        assertEquals(new BookEntry("Book1", "Author1"), manager.bookEntries.get(0));
        assertEquals(new BookEntry("Book3", "Author3"), manager.bookEntries.get(1));
    }
    @Test
    void testEmptyManageBooksWithUpdate() {
        BookManager manager = new BookManager();
        ArrayList<BookEntry> entries = new ArrayList<>();
        manager.manageBooks(entries, true);
        assertEquals(0, manager.bookEntries.size());
    }
    @Test
    void testInitialEmptyManager() {
        BookManager manager = new BookManager();
        assertEquals(0, manager.bookEntries.size());
    }
}


import java.util.List;
class VoteButton {
    String text;
    String callbackData;
    public VoteButton(String text, String callbackData) {
        this.text = text;
        this.callbackData = callbackData;
    }
    public void setCallbackData(String callbackData) {
        this.callbackData = callbackData;
    }
    public String getText() {
        return text;
    }
    public String getCallbackData() {
        return callbackData;
    }
}
class VoteSystem {
    public List<List<VoteButton>> generateVoteButtons() {
        VoteButton agree = new VoteButton("赞成", "voteYes");
        VoteButton disagree = new VoteButton("反对", "voteNo");
        return List.of(List.of(agree, disagree));
    }
}
public class Main {
    public static void main(String[] args) {
        VoteSystem voteSystem = new VoteSystem();
        List<List<VoteButton>> buttons = voteSystem.generateVoteButtons();
        for (List<VoteButton> buttonList : buttons) {
            for (VoteButton button : buttonList) {
                System.out.println("按钮文本: " + button.getText() + ", 回调数据: " + button.getCallbackData());
            }
        }
    }
}

请编写一个Java方法，该方法用于生成一个简单的投票系统，允许用户通过点击按钮来选择“赞成”或“反对”。该方法应返回一个包含两个按钮（"赞成"和"反对"）的对象。每个按钮都应该有一个标记，分别为"voteYes"和"voteNo"，以便于后续处理用户的选择。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.util.List;
class VoteButton {
    String text;
    String callbackData;
    public VoteButton(String text, String callbackData) {
    }
    public void setCallbackData(String callbackData) {
    }
    public String getText() {
        return null;
    }
    public String getCallbackData() {
        return null;
    }
}
class VoteSystem {
    public List<List<VoteButton>> generateVoteButtons() {
        return null;
    }
}
```

import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import java.util.List;
class VoteButtonTest {
    @Test
    void testVoteButtonConstructor() {
        VoteButton button = new VoteButton("测试文本", "测试回调");
        assertEquals("测试文本", button.getText());
        assertEquals("测试回调", button.getCallbackData());
    }
    @Test
    void testSetCallbackData() {
        VoteButton button = new VoteButton("测试文本", "初始回调");
        button.setCallbackData("修改后的回调");
        assertEquals("修改后的回调", button.getCallbackData());
    }
    @Test
    void testGetText() {
        VoteButton button = new VoteButton("测试文本", "测试回调");
        assertEquals("测试文本", button.getText());
    }
    @Test
    void testGetCallbackData() {
        VoteButton button = new VoteButton("测试文本", "测试回调");
        assertEquals("测试回调", button.getCallbackData());
    }
}
class VoteSystemTest {
    @Test
    void testGenerateVoteButtons() {
        VoteSystem voteSystem = new VoteSystem();
        List<List<VoteButton>> buttons = voteSystem.generateVoteButtons();
        assertEquals(1, buttons.size());
        assertEquals(2, buttons.get(0).size());
        VoteButton agree = buttons.get(0).get(0);
        assertEquals("赞成", agree.getText());
        assertEquals("voteYes", agree.getCallbackData());
        VoteButton disagree = buttons.get(0).get(1);
        assertEquals("反对", disagree.getText());
        assertEquals("voteNo", disagree.getCallbackData());
    }
}


import java.util.HashMap;
import java.util.Map;
public class StudentInfoManager {
    private Map<String, Integer> studentScores;
    public StudentInfoManager() {
        studentScores = new HashMap<>();
    }
    public void addOrUpdateStudent(String name, Integer score) {
        studentScores.put(name, score);
    }
    public Integer queryScoreByName(String name) {
        return studentScores.get(name);
    }
    public void deleteStudent(String name) {
        studentScores.remove(name);
    }
    public static void main(String[] args) {
        StudentInfoManager manager = new StudentInfoManager();
        manager.addOrUpdateStudent("张三", 90);
        manager.addOrUpdateStudent("李四", 85);
        System.out.println("张三的成绩: " + manager.queryScoreByName("张三"));
        manager.addOrUpdateStudent("张三", 95);
        System.out.println("张三更新后的成绩: " + manager.queryScoreByName("张三"));
        manager.deleteStudent("李四");
        System.out.println("删除李四后，查询李四的成绩: " + manager.queryScoreByName("李四"));
    }
}

请设计一个名为`学生信息管理系统`的Java类，该类能够实现以下功能：

- 添加学生信息，包括学生姓名和成绩。
- 根据学生姓名查询成绩。
- 更新学生的成绩。
- 删除学生信息。

请确保你的代码能够处理学生信息的添加、查询、更新和删除操作。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.util.HashMap;
import java.util.Map;
public class StudentInfoManager {
    private Map<String, Integer> studentScores;
    public StudentInfoManager() {
    }
    public void addOrUpdateStudent(String name, Integer score) {
    }
    public Integer queryScoreByName(String name) {
    }
    public void deleteStudent(String name) {
    }
}
```

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class StudentInfoManagerTest {
    private StudentInfoManager manager;
    @BeforeEach
    public void setUp() {
        manager = new StudentInfoManager();
    }
    @Test
    public void testAddOrUpdateStudent() {
        manager.addOrUpdateStudent("张三", 90);
        Integer score = manager.queryScoreByName("张三");
        assertEquals(90, score);
    }
    @Test
    public void testUpdateExistingStudent() {
        manager.addOrUpdateStudent("张三", 90);
        manager.addOrUpdateStudent("张三", 95);
        Integer score = manager.queryScoreByName("张三");
        assertEquals(95, score);
    }
    @Test
    public void testQueryScoreByName() {
        manager.addOrUpdateStudent("李四", 85);
        Integer score = manager.queryScoreByName("李四");
        assertEquals(85, score);
    }
    @Test
    public void testDeleteStudent() {
        manager.addOrUpdateStudent("李四", 85);
        manager.deleteStudent("李四");
        Integer score = manager.queryScoreByName("李四");
        assertNull(score);
    }
    @Test
    public void testDeleteNonExistingStudent() {
        manager.deleteStudent("王五");
        Integer score = manager.queryScoreByName("王五");
        assertNull(score);
    }
}


import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class FileCopier {
    public static void copyTextFile(String sourcePath, String targetPath) throws IOException {
        FileReader fileReader = null;
        FileWriter fileWriter = null;
        try {
            fileReader = new FileReader(sourcePath);
            fileWriter = new FileWriter(targetPath);
            int character;
            while ((character = fileReader.read()) != -1) {
                fileWriter.write(character);
            }
        } finally {
            if (fileReader != null) {
                fileReader.close();
            }
            if (fileWriter != null) {
                fileWriter.close();
            }
        }
    }
    public static void main(String[] args) {
        try {
            copyTextFile("source.txt", "target.txt");
            System.out.println("文件复制成功！");
        } catch (IOException e) {
            System.out.println("在复制文件时发生错误：" + e.getMessage());
        }
    }
}

请编写一个Java方法，用于将一个文本文件的内容复制到另一个新的文本文件中。该方法应接收两个参数：源文件路径和目标文件路径。确保在复制过程中，如果目标文件不存在，则自动创建该文件。请注意，需要处理可能出现的所有IO异常，并确保所有使用的资源在操作完成后都被正确关闭。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class FileCopier {
    public static void copyTextFile(String sourcePath, String targetPath) throws IOException {
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import java.io.File;
import java.io.FileWriter;
import java.io.FileReader;
import java.io.IOException;
public class FileCopierTest {
    @Test
    public void testCopyTextFile_Success() throws IOException {
        String sourcePath = "testSource.txt";
        String targetPath = "testTarget.txt";
        try (FileWriter fileWriter = new FileWriter(sourcePath)) {
            fileWriter.write("Hello World!");
        }
        FileCopier.copyTextFile(sourcePath, targetPath);
        StringBuilder content = new StringBuilder();
        try (FileReader fileReader = new FileReader(targetPath)) {
            int character;
            while ((character = fileReader.read()) != -1) {
                content.append((char) character);
            }
        }
        assertEquals("Hello World!", content.toString());
    }
    @Test
    public void testCopyTextFile_EmptyFile() throws IOException {
        String sourcePath = "testEmptySource.txt";
        String targetPath = "testEmptyTarget.txt";
        new File(sourcePath).createNewFile();
        FileCopier.copyTextFile(sourcePath, targetPath);
        File targetFile = new File(targetPath);
        assertTrue(targetFile.exists());
        assertEquals(0, targetFile.length());
    }
    @Test
    public void testCopyTextFile_NonExistingSourceFile() {
        String sourcePath = "nonExistingSource.txt";
        String targetPath = "shouldNotExist.txt";
        assertThrows(IOException.class, () -> {
            FileCopier.copyTextFile(sourcePath, targetPath);
        });
    }
    @Test
    public void testCopyTextFile_TargetFileExists() throws IOException {
        String sourcePath = "testSourceOverwrite.txt";
        String targetPath = "testTargetOverwrite.txt";
        try (FileWriter sourceWriter = new FileWriter(sourcePath)) {
            sourceWriter.write("New Content");
        }
        try (FileWriter targetWriter = new FileWriter(targetPath)) {
            targetWriter.write("Old Content");
        }
        FileCopier.copyTextFile(sourcePath, targetPath);
        StringBuilder content = new StringBuilder();
        try (FileReader fileReader = new FileReader(targetPath)) {
            int character;
            while ((character = fileReader.read()) != -1) {
                content.append((char) character);
            }
        }
        assertEquals("New Content", content.toString());
    }
    @Test
    public void testCopyTextFile_SpecialCharacters() throws IOException {
        String sourcePath = "testSpecialCharactersSource.txt";
        String targetPath = "testSpecialCharactersTarget.txt";
        String specialContent = "Spécial Chârâctèrs! 中文字符";
        try (FileWriter fileWriter = new FileWriter(sourcePath)) {
            fileWriter.write(specialContent);
        }
        FileCopier.copyTextFile(sourcePath, targetPath);
        StringBuilder content = new StringBuilder();
        try (FileReader fileReader = new FileReader(targetPath)) {
            int character;
            while ((character = fileReader.read()) != -1) {
                content.append((char) character);
            }
        }
        assertEquals(specialContent, content.toString());
    }
}


import java.util.UUID;
import java.util.regex.Pattern;
public class UserIdentifierGenerator {
    public static String generateUserId(String email, String phone) {
        if (email != null && !email.isEmpty() && isValidEmail(email)) {
            return email;
        } else if (phone != null && !phone.isEmpty()) {
            return phone;
        } else {
            String uuid = UUID.randomUUID().toString();
            return uuid.replaceAll("-", "");
        }
    }
    private static boolean isValidEmail(String email) {
        String emailRegex = "^[a-zA-Z0-9_+&*-]+(?:\\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,7}$";
        Pattern pattern = Pattern.compile(emailRegex);
        return pattern.matcher(email).matches();
    }
    public static void main(String[] args) {
        System.out.println(generateUserId("example@example.com", "1234567890"));
        System.out.println(generateUserId("", "1234567890"));
        System.out.println(generateUserId("", ""));
        System.out.println(generateUserId(null, null));
        System.out.println(generateUserId("invalidEmail@", "1234567890"));
    }
}

请编写一个Java函数，该函数用于生成一个唯一的用户标识符。如果可能，首先尝试使用用户的邮箱地址作为标识符。如果邮箱地址为空或者格式不正确，那么请使用用户的手机号码。如果手机号码也不可用，那么生成一个随机的UUID作为用户标识符。请确保UUID中不包含任何短横线。请在实现中考虑到异常处理，并且确保返回的标识符是一个非空的字符串。
请用Java实现不包含Main函数的完整代码，并遵循如下类型定义：

```java
import java.util.UUID;
import java.util.regex.Pattern;
public class UserIdentifierGenerator {
    public static String generateUserId(String email, String phone) {
    }
    private static boolean isValidEmail(String email) {
    }
}
```

import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
public class UserIdentifierGeneratorTest {
    @Test
    public void testGenerateUserIdWithValidEmail() {
        String email = "example@example.com";
        String phone = "1234567890";
        String result = UserIdentifierGenerator.generateUserId(email, phone);
        assertEquals(email, result);
    }
    @Test
    public void testGenerateUserIdWithInvalidEmailAndValidPhone() {
        String email = "invalidEmail@";
        String phone = "1234567890";
        String result = UserIdentifierGenerator.generateUserId(email, phone);
        assertEquals(phone, result);
    }
    @Test
    public void testGenerateUserIdWithEmptyEmailAndPhone() {
        String email = "";
        String phone = "";
        String result = UserIdentifierGenerator.generateUserId(email, phone);
        assertNotNull(result);
        assertNotEquals(email, result);
        assertNotEquals(phone, result);
    }
    @Test
    public void testGenerateUserIdWithNullEmailAndPhone() {
        String email = null;
        String phone = null;
        String result = UserIdentifierGenerator.generateUserId(email, phone);
        assertNotNull(result);
    }
    @Test
    public void testGenerateUserIdWithEmptyEmailAndValidPhone() {
        String email = "";
        String phone = "1234567890";
        String result = UserIdentifierGenerator.generateUserId(email, phone);
        assertEquals(phone, result);
    }
}