Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

W1D3 JCB добавить проверку на соответствие публичных методов тем что указаны в задании #188

Open
cardinalnsk opened this issue Dec 22, 2023 · 0 comments

Comments

@cardinalnsk
Copy link

cardinalnsk commented Dec 22, 2023

ListNode в нашем случае является DoubleLinkedList или другими словами NoSQL БД, хранящая в себе некотрые данные.
Соответсвенно, создание публичных методов которые могут допустим менять value неприемлимо.
Примерный вариант реализации теста

  @Test
  @DisplayName("Checking public methods from a task")
  public void testPublicMethods() {
    var listNodeClass = ListNode.class;
    var expectedPublicMethodNames = Stream.of("toString", "getValue", "setPrev", "setNext", "getNext", "getPrev")
            .sorted()
            .toList();
    
    var actualPublicMethodNames = Arrays.stream(listNodeClass.getDeclaredMethods())
            .filter(method -> method.getModifiers() == Modifier.PUBLIC)
            .map(Method::getName)
            .sorted()
            .toList();

    Truth.assertWithMessage("ListNode security compromised")
            .that(actualPublicMethodNames).isEqualTo(expectedPublicMethodNames);
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant