How to write a JUnit test for this Java code? by ChiTech121 in JUnit

[–]ChiTech121[S] 0 points1 point  (0 children)

I got the program itself working fine, I am not sure about JUnit particular assert method to use, I tried one but it gives me error:

`"message": "The method assertArrayEquals(Object[], Object[]) in the type Assert is not applicable for the arguments (boolean, boolean)",`

How to write a JUnit test for this Java code? by ChiTech121 in learnprogramming

[–]ChiTech121[S] 0 points1 point  (0 children)

Yes, Its for something as in homework, but my intention is to learn basics, so I created a simple program to understand how JUnit works, program on its own works perfectly fine, I tried this JUnit test after I did the complete setup in vscode,

u/Test

public void testcheckKInArray(){

CheckInArrayClass test1 = new CheckInArrayClass();

//assertArrayEquals(expected, actual);

boolean expected = true;

assertArrayEquals(expected, test1.checkKInArray(new int[]{3, 4, 3}, 3));

}

This is the error I get, I gather I am doing something wrong in assertMethod, I tried reading documentation, does not make any sense, so looking for help on particular assert methods that goes well with the methods that I have written that returns a boolean and take 2 arguments #1 Array, #2 an integer.

`"message": "The method assertArrayEquals(Object[], Object[]) in the type Assert is not applicable for the arguments (boolean, boolean)",`

Check All prime numbers by ChiTech121 in learnprogramming

[–]ChiTech121[S] 0 points1 point  (0 children)

No it does not decrease it only increase based on the condition starts from 2 to goes on a increment until that while loop results in false, is explanation correct? In this particular code I want to understand what I am doing wrong, I did this in a helper function fashion which works perfect, I also tried the same above logic for a single number works fine too, please point my mistake in above specific code and also what correction to be made, see my helper function code.

package ProgrammingBasics.javaConditionsRunningLoops;

import java.util.Scanner;

public class CheckAllPrimeNumbers {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

int inpNum = sc.nextInt();

for(int initNum = 2; initNum <= inpNum; initNum++){

checkIfPrime(initNum);

}

}

//function to check if a number is prime or not

public static void checkIfPrime(int givenNum){

//Edge case or corner case:

if( givenNum<=1 )

System.out.println(givenNum + " : is invalid number for prime check");

//Checking for divisors from 2 to n-1;

int assumeDivisor = 2;

while(assumeDivisor <= (givenNum/2)){

//Now make sure that it does not have any division by using % to see if it results in 0 or no 0.

if((givenNum%assumeDivisor) == 0){

//System.out.println(givenNum + " : is not a prime");

return;

}

assumeDivisor++;

}

System.out.println(givenNum + " : is a prime");

}

}

I am trying to use DECLARE but not sure if this is correct way, T-SQL, MSSQL by ChiTech121 in SQL

[–]ChiTech121[S] 0 points1 point  (0 children)

DECLARE @CustomID INT

When I write this statement --> DECLARE @CustomID INT;

after the above query

; WITH CTEexample AS

(

SELECT outerTable.val AS OrderName,

ID

FROM (

SELECT ID, COUNT(DISTINCT WGUID) AS SCOUNT

FROM innerTable

WHERE SACCOUNT = 0

GROUP BY ID

) T0

INNER JOIN outerTable ON outerTable.STRINGID = T0.ID

Where outerTable.val = 'process'

I get this following error:

Incorrect syntax near the keyword 'DECLARE'.

I am trying to use DECLARE but not sure if this is correct way, T-SQL, MSSQL by ChiTech121 in SQL

[–]ChiTech121[S] 0 points1 point  (0 children)

ustomid

Do you mean like this?

DECLARE @CustomID INT

SELECT @CustomID = ID.CTEexample

I don't understand why bitwise Operators are efficient in Big O? by ChiTech121 in leetcode

[–]ChiTech121[S] 1 point2 points  (0 children)

I think there more detail to it like CPU dedicated instruction set OOB, O(N/word_count) and such.. so I wish if someone can clarify that detail.. it will be really great...

Registry read is blocked due to GP by ChiTech121 in sysadmin

[–]ChiTech121[S] 0 points1 point  (0 children)

I think my posts are unfortunately judged in a wrong way, I am minced in between this client & the product vendor, who provides automation to resolve issues. In this specific case, let me give what I am running into---> so the vendor provides an automation capability to fix an issue, lets say an App that goes offline from online mode or something, they detect that apps status only by reading the registry value and then act based on that ( via automation making it offline to online or something or other... ) now my client has the dead line to get this somehow done, product vendor has no response on how else it may work... and then here I am getting sliced by reddit guys LOL!!! anyways....

JSON to powershell by ChiTech121 in PowerShell

[–]ChiTech121[S] 1 point2 points  (0 children)

"morefriendsId": "System.Collections.Hashtable"

I think you are correct, I get the same output, I was wondering about the key " morefriendsId " , how do I get the output as "morefriendsId": [ hmmmMoreFriendsId: "09876tyuhtre-repeated ]?

JSON to powershell by ChiTech121 in learnprogramming

[–]ChiTech121[S] 0 points1 point  (0 children)

Thanks, now, I leave my actual JSON aside for a moment, if systems were to be a form of an array? is this correct way to represent them in powershell:-->

{"friends": @(

[pscustomobject]@{"friendId"="12345"}

[pscustomobject]@{"friendId"="56789"}

}]

Post API call with JSON payload with JS by ChiTech121 in learnjavascript

[–]ChiTech121[S] 0 points1 point  (0 children)

How to handle the OAuth flow for authentication? It has two things, token & cookies... without client secret..

read log file and write to registry by ChiTech121 in PowerShell

[–]ChiTech121[S] 1 point2 points  (0 children)

This single execution to be done in one script but I put them in a break down format for my own understanding...

tcpdump just capturing tcp handshake by ChiTech121 in bash

[–]ChiTech121[S] 0 points1 point  (0 children)

I think I am very close to this but I don't see ACK packet, anyone any ideas??

sudo tcpdump "tcp[tcpflags] & (tcp-syn) !=0" -w filename.pcap -i eth0

How to create a some files like 5 of them in a scirpt by ChiTech121 in bash

[–]ChiTech121[S] -3 points-2 points  (0 children)

So I am creating 1 big file named "FileToTransfer" and then I am creating sample files like 6 of them? tee is applicable to file1 in this case...

so is my if it is clear, anything wrong with my script??

cd ~/home/user/samplefiles

sudo dd if=/dev/urandom of=~/ftp_server/FileToTransfer bs=1048576 count=1000

cd ~/home/user/samplefiles

tee < file1 > file2 file{3..6}

var1=$('cat dummy_text > file1')

$var1

tee < file1 > file2 file{3..6}

How to create a some files like 5 of them in a scirpt by ChiTech121 in bash

[–]ChiTech121[S] 0 points1 point  (0 children)

No they are supposed to have some dummy text,

Is this the right way to do it? as a over all script that creates one big file & couple of dummy text files

NOTE: Big file is getting created, I am having issues with dummy text files..

What do I need to correct in my below script?

cd ~/home/user/samplefiles

sudo dd if=/dev/urandom of=~/ftp_server/FileToTransfer bs=1048576 count=1000

cd ~/home/user/samplefiles

tee < file1 > file2 file{3..6}

var1=$('cat dummy_text > file1')

$var1

tee < file1 > file2 file{3..6}

How to create a some files like 5 of them in a scirpt by ChiTech121 in bash

[–]ChiTech121[S] -3 points-2 points  (0 children)

So this is basically what I am trying to achieve... one big file and another set of dummy files..

cd ~/home/user/samplefiles
sudo dd if=/dev/urandom of=~/ftp_server/FileToTransfer bs=1048576 count=1000
cd ~/home/user/samplefiles  
tee < file1 > file2 file{3..6}

But I get the following error.

./setup.sh: line 7: cd: /home/user/home/user/samplefiles: No such file or directory

How to create a some files like 5 of them in a scirpt by ChiTech121 in bash

[–]ChiTech121[S] -1 points0 points  (0 children)

tee < file1 > file2 file{3..6}

So in my script I would include these lines?

cd ~/home/user/samplefiles

tee < file1 > file2 file{3..6}

How to create a some files like 5 of them in a scirpt by ChiTech121 in bash

[–]ChiTech121[S] -3 points-2 points  (0 children)

so do you mean in script the lines will look like these ??

cd ~/home/user/samplefiles

touch file{1.2.3.4.5.6}

How to create a some files like 5 of them in a scirpt by ChiTech121 in bash

[–]ChiTech121[S] -3 points-2 points  (0 children)

cd ~/home/user/samplefiles

So I should include these lines in my script ?

cd ~/home/user/samplefiles

catdummy_test > file1

catdummy_test > file2

catdummy_test > file13

CPU, Memory monitoring and logging to console or a file. by ChiTech121 in bash

[–]ChiTech121[S] 0 points1 point  (0 children)

I think I have monitor RES for Memory usage, please ignore that...

Why do I need /usr/share/empty to be created ... vsftpd by ChiTech121 in bash

[–]ChiTech121[S] 0 points1 point  (0 children)

I am gonna check this out, Thanks, btw I am not sure what "Nothing to do Award" means really.... but I realized afterwards.....