Copilot Code Generation Instructions
General Guidelines
- Follow the user's requirements carefully & to the letter.
- First think step-by-step - describe your plan for what to build in pseudocode, written out in great detail.
- Confirm, then write code!
- Always write correct, up to date, bug free, fully functional and working, secure, performant and efficient code.
- Fully implement all requested functionality.
- Ensure code is complete! Verify thoroughly finalized.
- Be concise. Minimize any other prose.
- Output modified codeblocks with // or # file name comment prior to it with a few lines before and after modification, so the user knows what to modify.
- Stick to the current architecture choices unless the user suggests a new method.
- use .env to store the secret key
- Use meaningful variable names.
- Include comments for complex logic.
- generate test code use @Nest annotation to identity test method
- generate test code use BDD scenario
- The package declaration should be at the top of the file
- Include all required imports, and ensure proper naming of key components ,make sure add at line after package declaration.
- move The package declaration to the top of the file,move the package
Preferred Libraries
- Use
requests for HTTP requests.
Example Code For Test
// class to be test
public class AllowanceSettingComparator implements Comparator<AllowanceSettingViewEntity> {
@Override
public int compareDetail(AllowanceSettingViewEntity o1, AllowanceSettingViewEntity o2) {
// Compare product code first
}
public Integer compareCount(AllowanceSettingViewEntity o1, AllowanceSettingViewEntity o2) {
Integer o1Count = getCountNumber(o1);
Integer o2Count = getCountNumber(o2);
//符合比數多的 排在前面
return o2Count.compareTo(o1Count);
}
}
// text example
class AllowanceSettingComparatorTest {
private AllowanceSettingComparator comparator;
private AllowanceSettingViewEntity entity1;
private AllowanceSettingViewEntity entity2;
private AllowCustomerResponseDataItem item;
@BeforeEach
void setUp() {
item = new AllowCustomerResponseDataItem();
item.setGroupCode("group");
item.setOuCode("ou");
item.setCustNo("cust");
entity1 = Mockito.mock(AllowanceSettingViewEntity.class);
entity2 = Mockito.mock(AllowanceSettingViewEntity.class);
comparator = new AllowanceSettingComparator(item);
MockitoAnnotations.initMocks(this);
}
@Nested
class compareCountTest {
@Test
void compareShouldReturnDateCompareWhenEntitiesAreEqual() {
}
}
@Nested
class compareDetailTest {
@Test
void compareShouldReturnZeroWhenAllFieldsAreEqual() {
// Arrange
Date date = new Date();
Mockito.when(entity1.getCreatedDate()).thenReturn(date);
Date date2 = new Date();
// ACT
int result = comparator.compareDetail(entity1, entity2);
// Assert
assertEquals(date.compareTo(date2), result);
}
}
}